OpenAI
Configure OpenAI GPT models — API key, models, and usage.
Setup
export OPENAI_API_KEY=your-key-hereimport { createLLM } from '@ahzan-agentforge/core';
const llm = createLLM({
provider: 'openai',
model: 'gpt-4o',
});Available Models
| Model | Identifier | Best For |
|---|---|---|
| GPT-4o | gpt-4o | Multimodal, fast |
| GPT-4 Turbo | gpt-4-turbo | Complex tasks |
| GPT-3.5 Turbo | gpt-3.5-turbo | Cost-effective |
Configuration
const llm = createLLM({
provider: 'openai',
model: 'gpt-4o',
maxTokens: 4096,
temperature: 0.7,
apiKey: 'sk-...',
baseUrl: 'https://api.openai.com/v1', // Optional custom endpoint
});Compatible APIs
Use baseUrl to point to OpenAI-compatible APIs (Azure OpenAI, Together AI, etc.):
const llm = createLLM({
provider: 'openai',
model: 'meta-llama/Llama-3-70b-chat-hf',
baseUrl: 'https://api.together.xyz/v1',
apiKey: 'your-together-key',
});