OpenAI
OpenAI provides GPT models including GPT-4o for conversational AI.
Setup
1. Get API Key
- Go to OpenAI Platform
- Sign in or create an account
- Navigate to API keys
- Create a new secret key
2. Configure Environment
LLM_PROVIDER=openai
OPENAI_API_KEY=sk-...your-api-key
OPENAI_MODEL=gpt-4o
Available Models
| Model | Context | Best For | Cost (Input) |
|---|---|---|---|
gpt-4o | 128K | Best quality | $2.50/1M |
gpt-4o-mini | 128K | Cost effective | $0.15/1M |
gpt-4-turbo | 128K | Previous gen | $10.00/1M |
o1 | 200K | Reasoning | $15.00/1M |
Configuration Options
# Required
OPENAI_API_KEY=sk-...
# Model selection
OPENAI_MODEL=gpt-4o
# Optional
OPENAI_ORGANIZATION=org-... # For org accounts
OPENAI_BASE_URL=https://... # For proxies/Azure
Using with RAG
OpenAI doesn't have native File Search like Gemini. For RAG:
- Use Gemini for RAG + OpenAI for generation (hybrid)
- Use external vector database (Pinecone, etc.)
- Use OpenAI Assistants API (requires additional setup)
Troubleshooting
"Invalid API key"
- Check your key at OpenAI Platform
- Ensure you have billing set up
- Check for rate limits
"Model not found"
- Ensure you have access to the model
- Some models require specific access (o1, etc.)
Cost Estimation
For a typical 3-minute session with GPT-4o:
| Component | Tokens | Cost |
|---|---|---|
| System + context | ~2500 | $0.00625 |
| User messages | ~200 | $0.0005 |
| Responses | ~1200 | $0.012 |
| Total | ~3900 | ~$0.02 |