Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
OpenAI Provider
Use OpenAI’s GPT models including GPT-4o, GPT-4, and GPT-3.5 with PraisonAI TypeScript.
Environment Variables
export OPENAI_API_KEY=sk-...
| Variable | Required | Description |
|---|
OPENAI_API_KEY | Yes | Your OpenAI API key |
OPENAI_ORG_ID | No | Organization ID (optional) |
OPENAI_BASE_URL | No | Custom base URL (for proxies) |
Supported Modalities
| Modality | Supported |
|---|
| Text/Chat | ✅ |
| Embeddings | ✅ |
| Image | ✅ |
| Audio | ✅ |
| Speech | ✅ |
| Tools | ✅ |
Quick Start
import { Agent } from 'praisonai';
const agent = new Agent({
name: 'Assistant',
instructions: 'You are a helpful assistant.',
llm: 'openai/gpt-4o-mini'
});
const response = await agent.chat('Hello!');
console.log(response);
Available Models
| Model | Description | Context |
|---|
gpt-4o | Latest multimodal model | 128K |
gpt-4o-mini | Fast, affordable | 128K |
gpt-4-turbo | High capability | 128K |
gpt-4 | Original GPT-4 | 8K |
gpt-3.5-turbo | Fast, cost-effective | 16K |
o1 | Reasoning model | 128K |
o1-mini | Fast reasoning | 128K |
Advanced Configuration
import { Agent } from 'praisonai';
const agent = new Agent({
name: 'CustomAgent',
instructions: 'You are an expert analyst.',
llm: 'openai/gpt-4o',
llmConfig: {
temperature: 0.7,
maxTokens: 4096,
topP: 0.9,
}
});
import { Agent } from 'praisonai';
const searchTool = {
name: 'search',
description: 'Search the web',
parameters: {
type: 'object',
properties: {
query: { type: 'string', description: 'Search query' }
},
required: ['query']
},
execute: async ({ query }) => {
return `Results for: ${query}`;
}
};
const agent = new Agent({
name: 'SearchAgent',
instructions: 'Search for information when asked.',
llm: 'openai/gpt-4o-mini',
tools: [searchTool]
});
Streaming
import { Agent } from 'praisonai';
const agent = new Agent({
name: 'StreamAgent',
instructions: 'You are helpful.',
llm: 'openai/gpt-4o-mini'
});
for await (const chunk of agent.stream('Tell me a story')) {
process.stdout.write(chunk);
}
Multi-Agent Workflow
import { Agent, AgentTeam } from 'praisonai';
const researcher = new Agent({
name: 'Researcher',
instructions: 'Research topics thoroughly.',
llm: 'openai/gpt-4o'
});
const writer = new Agent({
name: 'Writer',
instructions: 'Write clear summaries.',
llm: 'openai/gpt-4o-mini'
});
const agents = new AgentTeam({
agents: [researcher, writer],
tasks: [
{ agent: researcher, description: 'Research {topic}' },
{ agent: writer, description: 'Summarize the research' }
]
});
const result = await agents.start({ topic: 'AI trends' });
Troubleshooting
Invalid API Key
Error: Authentication failed
Solution: Verify your OPENAI_API_KEY is set correctly and has not expired.
Rate Limits
Error: Rate limit exceeded
Solution: Implement retry logic or upgrade your OpenAI plan.
Model Not Found
Solution: Check the model name is correct. Use gpt-4o-mini instead of gpt-4-mini.