🌐 Web Development: React, Next.js, PWAs & E-commerce solutions📱 Mobile Apps: React Native & Flutter for iOS/Android💻 Desktop Apps: Cross-platform Electron applications🍽️ RestaurantPOS Pro: Complete restaurant management system🛍️ RetailPOS Elite: Smart retail point of sale solution📋 WaitlistPro: Smart waitlist management platform🛠️ Developer Tools: Powerful SDKs, APIs & libraries for seamless integration🎯 Code Playground: Live JavaScript, Python & Java execution📚 Programming Academy: Interactive quizzes for 17+ languages⚙️ Backend & APIs: RESTful, GraphQL & microservices architecture🚀 DevOps: CI/CD pipelines, Docker, Kubernetes & cloud deployment🔧 App Management: Performance monitoring, security updates & maintenance🌐 Web Development: React, Next.js, PWAs & E-commerce solutions📱 Mobile Apps: React Native & Flutter for iOS/Android💻 Desktop Apps: Cross-platform Electron applications🍽️ RestaurantPOS Pro: Complete restaurant management system🛍️ RetailPOS Elite: Smart retail point of sale solution📋 WaitlistPro: Smart waitlist management platform🛠️ Developer Tools: Powerful SDKs, APIs & libraries for seamless integration🎯 Code Playground: Live JavaScript, Python & Java execution📚 Programming Academy: Interactive quizzes for 17+ languages⚙️ Backend & APIs: RESTful, GraphQL & microservices architecture🚀 DevOps: CI/CD pipelines, Docker, Kubernetes & cloud deployment🔧 App Management: Performance monitoring, security updates & maintenance
Back to Documentation

Universal AI SDK

Unified SDK for ALL major AI providers

Installation

npm install @jutech-devs/universal-ai

Supported Providers

🤖 OpenAI

  • • gpt-4o, gpt-4o-mini
  • • o1-preview, o1-mini
  • • gpt-4-turbo, gpt-4, gpt-4-32k
  • • gpt-3.5-turbo, gpt-3.5-turbo-16k
  • • text-davinci-003, code-davinci-002

🧠 Anthropic Claude

  • • claude-3-5-sonnet-20241022
  • • claude-3-5-haiku-20241022
  • • claude-3-opus-20240229
  • • claude-3-sonnet-20240229
  • • claude-2.1, claude-2.0

🔍 Google Gemini

  • • gemini-2.0-flash-exp
  • • gemini-1.5-pro-002, gemini-1.5-pro
  • • gemini-1.5-flash-002, gemini-1.5-flash
  • • gemini-1.5-flash-8b
  • • gemini-pro, gemini-pro-vision

🚀 Groq (Ultra-Fast)

  • • llama-3.3-70b-versatile
  • • llama-3.2-90b-text-preview
  • • llama-3.1-70b-versatile
  • • mixtral-8x7b-32768
  • • gemma2-9b-it, gemma-7b-it

🎯 Cohere

  • • command-r-plus, command-r
  • • command, command-nightly
  • • command-light

🌟 Mistral AI

  • • mistral-large-latest
  • • mistral-medium-latest
  • • open-mistral-7b, open-mixtral-8x7b
  • • codestral-latest, codestral-2405

🤖 xAI (Grok)

  • • grok-beta
  • • grok-vision-beta

🧮 DeepSeek

  • • deepseek-chat
  • • deepseek-coder
  • • deepseek-reasoner

Quick Start

import { UniversalAI } from '@jutech-devs/universal-ai';

// OpenAI
const openai = new UniversalAI({
  provider: 'openai',
  apiKey: process.env.OPENAI_API_KEY,
  model: 'gpt-4'
});

// Anthropic Claude
const claude = new UniversalAI({
  provider: 'anthropic',
  apiKey: process.env.ANTHROPIC_API_KEY,
  model: 'claude-3-5-sonnet-20241022'
});

const messages = [
  { role: 'user', content: 'Explain quantum computing' }
];

const response = await openai.chat(messages);
console.log(response.content);

React Hooks

useAI Hook

import { useAI } from '@jutech-devs/universal-ai';

function ChatComponent() {
  const {
    messages,
    isLoading,
    error,
    sendMessage,
    clearMessages,
    models
  } = useAI({
    provider: 'openai',
    apiKey: 'your-api-key',
    model: 'gpt-4'
  });

  return (
    <div>
      {messages.map((msg, i) => (
        <div key={i}>{msg.content}</div>
      ))}
      <button 
        onClick={() => sendMessage('Hello!')}
        disabled={isLoading}
      >
        Send Message
      </button>
    </div>
  );
}

useAIStream Hook

import { useAIStream } from '@jutech-devs/universal-ai';

function StreamingChat() {
  const {
    messages,
    streamingContent,
    isLoading,
    sendMessage
  } = useAIStream({
    provider: 'openai',
    apiKey: 'your-api-key',
    model: 'gpt-4'
  });

  return (
    <div>
      {messages.map((msg, i) => (
        <div key={i}>{msg.content}</div>
      ))}
      {streamingContent && (
        <div className="streaming">{streamingContent}</div>
      )}
    </div>
  );
}

Advanced Features

Custom System Prompts

import { createSystemMessage, createUserMessage } from '@jutech-devs/universal-ai';

const messages = [
  createSystemMessage('You are a helpful coding assistant.'),
  createUserMessage('How do I create a React component?'),
];

const response = await ai.chat(messages);

Token Usage Tracking

const response = await ai.chat(messages);

if (response.usage) {
  console.log(`Tokens used: ${response.usage.totalTokens}`);
  console.log(`Prompt tokens: ${response.usage.promptTokens}`);
  console.log(`Completion tokens: ${response.usage.completionTokens}`);
}

Function Calling & Tools

import { ToolRegistry, builtInTools } from '@jutech-devs/universal-ai';

const registry = new ToolRegistry();
builtInTools.forEach(tool => registry.register(tool));

// Custom tool
const weatherTool = {
  name: 'get_weather',
  description: 'Get current weather for a location',
  parameters: {
    type: 'object',
    properties: {
      location: { type: 'string', description: 'City name' },
    },
    required: ['location'],
  },
  handler: async ({ location }) => {
    return { temperature: 22, condition: 'sunny' };
  },
};

registry.register(weatherTool);

const ai = new UniversalAI({
  provider: 'openai',
  apiKey: 'your-key',
  model: 'gpt-4',
  tools: registry.getAll(),
});

Multi-Modal Support

import { createUserMessage } from '@jutech-devs/universal-ai';

// Image input
const message = createUserMessage([
  { type: 'text', data: 'What do you see in this image?' },
  { type: 'image', data: 'data:image/jpeg;base64,...', mimeType: 'image/jpeg' },
]);

// Audio input
const audioMessage = createUserMessage([
  { type: 'text', data: 'Transcribe this audio:' },
  { type: 'audio', data: 'data:audio/wav;base64,...', mimeType: 'audio/wav' },
]);

const response = await ai.chat([message]);

Configuration Options

OptionTypeDefaultDescription
providerstringrequiredAI provider name
apiKeystringrequiredProvider API key
modelstringrequiredModel name
temperaturenumber0.7Response creativity (0-1)
maxTokensnumberundefinedMax response tokens
topPnumberundefinedNucleus sampling (0-1)
baseURLstringundefinedCustom API endpoint
toolsarray[]Function calling tools

API Methods

ai.chat(messages)

Send chat messages and get a response.

ai.stream(messages)

Stream responses in real-time.

ai.getModels()

Get available models for the current provider.

ai.updateConfig(config)

Update configuration options.

Pricing

Completely Free & Open Source

  • • 100% free to use - no limits
  • • All 65+ AI models supported
  • • All 8 providers included
  • • Use your own API keys
  • • No usage tracking or restrictions
  • • MIT License
  • • Community support

💡 How it works:

You provide your own API keys from OpenAI, Anthropic, Google, etc. The SDK is just a unified interface - you pay the providers directly for usage.