Universal AI Layer for TypeScript
Stop juggling different AI API docs. Write once, switch providers seamlessly. Use OpenAI, Google Gemini, DeepSeek, Mistral, and Anthropic Claude with one unified interface.
Major AI Providers
Gzipped Bundle Size
Code Changes to Switch
Latest Version
Framework Agnostic AI Toolkit
The open-source SDK designed to help developers build AI-powered applications with React, Next.js, Node.js, and more.
Single Interface
Write once, switch providers. Same code works across OpenAI, Google Gemini, DeepSeek, Mistral, and Anthropic Claude.
Type-Safe
Full TypeScript support with proper types for all providers and operations. Catch errors at compile time.
Lightning Fast
Only 15KB gzipped. Minimal dependencies—just dotenv for environment variables. Zero bloat.
Streaming Built-in
Real-time responses without custom parsing. Unified StreamOutput format across all providers.
Automatic Fallback
Provider fails? Automatically retry with others. Reliable production behavior by default.
LLM Council
Run same prompt across multiple models and have a judge synthesize the best answer for complex decisions.
Supported Providers
Switch between major AI providers with one line of code. No code changes required.
OpenAI
GPT-4, GPT-4 Turbo, GPT-4o and more
Google Gemini
Gemini 2.5, Gemini Pro, and variants
DeepSeek
DeepSeek-Chat and models
Mistral
Mistral-Small, Medium, Large
Anthropic Claude
Claude 3, 3.5 Sonnet, Opus, Haiku
Just configure the API keys you need. You don't have to set up all providers.
Quick Start
Get up and running in 5 minutes. Just one import and you're ready.
$ npm install dev-ai-sdkimport { genChat } from 'dev-ai-sdk';
// 1. Create a client with your API keys
const ai = new genChat({
openai: {
apiKey: process.env.OPENAI_API_KEY,
},
});
// 2. Generate text
const result = await ai.generate({
openai: {
model: 'gpt-4o-mini',
prompt: 'What is the capital of France?',
},
});
// 3. Use the result
console.log(result.data); // "The capital of France is Paris."
console.log(result.provider); // "openai"
console.log(result.model); // "gpt-4o-mini"What's Next?
- →Try streaming responses for real-time data
- →Enable automatic fallback for reliability
- →Use LLM Council for better decisions
Common Patterns
Explore powerful patterns you can implement today
Streaming Responses
Get real-time responses without custom parsing
const stream = await ai.generate({
google: {
model: 'gemini-2.5-flash',
prompt: 'Write a haiku...',
stream: true,
},
});
for await (const chunk of stream) {
console.log(chunk.text);
if (chunk.done) {
console.log(`Completed from ${chunk.provider}`);
}
}Automatic Fallback
Reliability by default with provider fallback
const ai = new genChat({
openai: { apiKey: process.env.OPENAI_API_KEY },
google: { apiKey: process.env.GOOGLE_API_KEY },
fallback: true,
});
const result = await ai.generate({
openai: {
model: 'gpt-4o-mini',
prompt: 'What is 2+2?',
},
});
// Uses Google if OpenAI fails
console.log(result.provider);LLM Council
Get answers from multiple models
const decision = await ai.councilGenerate({
members: [
{ google: { model: 'gemini-2.5-flash-lite' } },
{ mistral: { model: 'mistral-small-latest' } },
],
judge: { openai: { model: 'gpt-4o-mini' } },
prompt: 'Top 3 languages for 2025?',
});
console.log(decision.finalAnswer);
console.log(decision.memberResponses);
console.log(decision.reasoning);Want to learn more?
View Full DocumentationReady to get started?
Join developers building AI apps with unified provider support.