Use 60+ AI providers with your Agents – AI SDK v6 compatible
PraisonAI TypeScript supports 60+ AI providers through AI SDK v6. Switch between providers by changing the llm parameter – all providers use the same unified API.
import { Agent } from 'praisonai';
const agent = new Agent({
instructions: 'You are helpful.',
llm: 'gpt-4o-mini'
});
await agent.chat('Hello');
With Configurationtypescript
import { Agent } from 'praisonai';
const agent = new Agent({
instructions: 'You are helpful.',
llm: 'anthropic/claude-sonnet-4',
verbose: true
});
Provider Support Matrix
tools, outputSchema, and stream work on every supported provider:
Feature
openai/...
anthropic/...
google/...
groq/...
mistral/...
ollama/...
Other AI SDK providers
tools
✅
✅
✅
✅
✅
✅
✅
outputSchema
✅ (native)
✅
✅
✅
✅
✅
✅
stream
✅
✅
✅
✅
✅
✅
✅
Tools + outputSchema together
✅
✅
✅
✅
✅
✅
✅
On OpenAI, outputSchema uses response_format: json_schema; on other providers it routes through the AI SDK backend’s generateObject({ schema }). Both paths return a JSON string that matches the schema.
Agent with Different Models
Tools & Structured Output on any provider
typescript
import { Agent } from 'praisonai';
const getWeather = (city: string) => `Weather in ${city}: 20C, sunny`;
const agent = new Agent({
instructions: 'Report the weather using the tool.',
llm: 'anthropic/claude-3-5-sonnet-latest',
tools: [getWeather],
});
await agent.start('Weather in Paris?');
typescript
import { Agent } from 'praisonai';
// OpenAI (default)
const openaiAgent = new Agent({
instructions: 'You are helpful.',
llm: 'gpt-4o-mini'
});
// Anthropic Claude
const claudeAgent = new Agent({
instructions: 'You are helpful.',
llm: 'anthropic/claude-3-5-sonnet'
});
// Google Gemini
const geminiAgent = new Agent({
instructions: 'You are helpful.',
llm: 'google/gemini-2.0-flash'
});
// All work the same way
await openaiAgent.chat('Hello!');
await claudeAgent.chat('Hello!');
await geminiAgent.chat('Hello!');
Multi-Agent with Mixed Providers
Use different models for different Agent roles:
typescript
import { Agent, AgentTeam } from 'praisonai';
// Fast model for quick tasks
const triageAgent = new Agent({
name: 'Triage',
instructions: 'Quickly categorize incoming requests.',
llm: 'gpt-4o-mini' // Fast and cheap
});
// Powerful model for complex reasoning
const analysisAgent = new Agent({
name: 'Analyst',
instructions: 'Perform deep analysis of complex problems.',
llm: 'anthropic/claude-sonnet-4' // Best reasoning
});
// Creative model for content
const writerAgent = new Agent({
name: 'Writer',
instructions: 'Write engaging content.',
llm: 'gpt-4o' // Good for creative tasks
});
const agents = new AgentTeam([triageAgent, analysisAgent, writerAgent]);
await agents.start();
Agent Model Selection by Task
typescript
import { Agent } from 'praisonai';
function createAgentForTask(taskType: string) {
const modelMap: Record<string, string> = {
'quick': 'gpt-4o-mini',
'reasoning': 'anthropic/claude-sonnet-4',
'creative': 'gpt-4o',
'code': 'anthropic/claude-3-5-sonnet',
'multimodal': 'google/gemini-2.0-flash'
};
return new Agent({
instructions: `You handle ${taskType} tasks.`,
llm: modelMap[taskType] || 'gpt-4o-mini'
});
}
const codeAgent = createAgentForTask('code');
await codeAgent.chat('Write a function to sort an array');
Agent with Streaming
typescript
import { Agent } from 'praisonai';
const agent = new Agent({
instructions: 'You tell stories.',
llm: 'gpt-4o',
stream: true // Enable streaming
});
// Response streams to console
await agent.chat('Tell me a short story about a robot');
Environment-Based Model Selection
typescript
import { Agent } from 'praisonai';
// Model from environment variable
const agent = new Agent({
instructions: 'You are helpful.',
llm: process.env.PRAISONAI_MODEL || 'gpt-4o-mini'
});
// Or use different models per environment
const model = process.env.NODE_ENV === 'production'
? 'gpt-4o' // Better quality in prod
: 'gpt-4o-mini'; // Cheaper in dev
const prodAgent = new Agent({
instructions: 'You are helpful.',
llm: model
});
Model String Formats
PraisonAI resolves the vendor from your model string — a bare claude- or gemini- name routes to Anthropic or Google without a prefix.
You write
Resolves to
Notes
gpt-4o-mini
OpenAI
Default for anything not recognised
claude-3-5-sonnet-latest
Anthropic
Bare prefix inference — no anthropic/ required
gemini-2.0-flash
Google
Bare prefix inference — no google/ required
openai/gpt-4o
OpenAI
Explicit prefix (wins over baseURL)
anthropic/claude-3-5-sonnet-latest
Anthropic
Explicit prefix (wins over baseURL)
google/gemini-2.0-flash
Google
Explicit prefix (wins over baseURL)
groq/llama-3.3-70b-versatile
Groq
Explicit prefix (required — llama-* is not inferred)
Prefix Inference vs Aliases
Two different mechanisms decide where a model string goes.
Prefix inference — the parser reads a bare name and infers the provider:
Bare prefix
Inferred provider
claude-*
anthropic
gemini-*
google
gpt-*
openai
Convenience aliases — short names used only inside the provider-registry lookup:
Alias
Provider
oai
openai
grok
xai
vertex
google-vertex
aws, bedrock
amazon-bedrock
together
togetherai
flux, bfl
black-forest-labs
local, ollama
ollama
nim, nvidia
nvidia-nim
Per-agent API key and baseURL
Pass credentials per agent — as of PraisonAI PR #4483 the constructor-time apiKey is honoured across providers, not only for OpenAI. Env vars remain a fallback.
typescript
import { Agent } from 'praisonai';
const agent = new Agent({
instructions: 'You are helpful.',
llm: 'claude-3-5-sonnet-latest',
apiKey: process.env.MY_ANTHROPIC_KEY, // no ANTHROPIC_API_KEY needed
baseURL: 'https://gateway.example.com/v1', // optional, per-agent
});
OpenAI-Compatible Providers
Use any OpenAI-compatible API:
typescript
import { Agent } from 'praisonai';
// Local LM Studio
const lmStudioAgent = new Agent({
instructions: 'You are helpful.',
llm: 'openai-compatible/local-model',
llmConfig: {
baseUrl: 'http://localhost:1234/v1',
apiKey: 'not-needed'
}
});
// Custom OpenAI-compatible endpoint
const customAgent = new Agent({
instructions: 'You are helpful.',
llm: 'openai-compatible/my-model',
llmConfig: {
baseUrl: process.env.CUSTOM_API_BASE,
apiKey: process.env.CUSTOM_API_KEY
}
});
Local Providers (Ollama, LM Studio)
typescript
import { Agent } from 'praisonai';
// Ollama (local)
const ollamaAgent = new Agent({
instructions: 'You are helpful.',
llm: 'ollama/llama3.2',
llmConfig: {
baseUrl: 'http://localhost:11434'
}
});
// LM Studio
const lmStudioAgent = new Agent({
instructions: 'You are helpful.',
llm: 'lm-studio/local-model',
llmConfig: {
baseUrl: 'http://localhost:1234/v1'
}
});
// NVIDIA NIM
const nimAgent = new Agent({
instructions: 'You are helpful.',
llm: 'nvidia/nemotron-super'
});
Agent with Custom Provider Config
For advanced use cases:
typescript
import { Agent, createProvider } from 'praisonai';
// Create custom provider with options
const customProvider = createProvider('openai/gpt-4o', {
maxRetries: 3,
timeout: 60000
});
// Use in Agent (advanced)
const agent = new Agent({
instructions: 'You are helpful.',
llm: 'gpt-4o' // Simple string is usually sufficient
});
await agent.chat('Hello!');
Custom Provider Extension
Register your own provider:
typescript
import { registerProvider, BaseProvider } from 'praisonai';
class MyCustomProvider extends BaseProvider {
async generateText(options) {
// Your implementation
return { text: 'response', usage: { totalTokens: 10 } };
}
}
// Register globally
registerProvider('my-provider', MyCustomProvider);
// Use in Agent
const agent = new Agent({
instructions: 'You are helpful.',
llm: 'my-provider/my-model'
});
ProviderConfig Options
Custom transport and browser support are configurable on ProviderConfig.
Option
Type
Default
Description
fetch
typeof fetch
undefined
Custom fetch — lets a host route egress through native code (e.g. a Tauri command). Implies dangerouslyAllowBrowser.
dangerouslyAllowBrowser
boolean
auto-detected
Force-enable the OpenAI SDK’s browser guard. Auto-true in browser-like runtimes.