Skip to main content

OpenAI

OpenAI provides GPT models including GPT-4o for conversational AI.

Setup

1. Get API Key

  1. Go to OpenAI Platform
  2. Sign in or create an account
  3. Navigate to API keys
  4. Create a new secret key

2. Configure Environment

LLM_PROVIDER=openai
OPENAI_API_KEY=sk-...your-api-key
OPENAI_MODEL=gpt-4o

Available Models

ModelContextBest ForCost (Input)
gpt-4o128KBest quality$2.50/1M
gpt-4o-mini128KCost effective$0.15/1M
gpt-4-turbo128KPrevious gen$10.00/1M
o1200KReasoning$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:

  1. Use Gemini for RAG + OpenAI for generation (hybrid)
  2. Use external vector database (Pinecone, etc.)
  3. 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:

ComponentTokensCost
System + context~2500$0.00625
User messages~200$0.0005
Responses~1200$0.012
Total~3900~$0.02