LLM & Agentic Model Comparison
A guide to the different AI models you can use with your chat app, including pricing, API key setup, and code examples.
Quick Comparison Table
| Model | Provider | Cost (per 1M tokens) | Speed | Best For |
|---|---|---|---|---|
| GPT-4o | OpenAI | $2.50 in / $10 out | Fast | Best overall quality, coding, reasoning |
| GPT-4o-mini | OpenAI | $0.15 in / $0.60 out | Fastest | Budget apps, high volume, default choice |
| Claude 3.5 Sonnet | Anthropic | $3.00 in / $15 out | Fast | Complex reasoning, long context, safety |
| Claude 3 Haiku | Anthropic | $0.25 in / $1.25 out | Fastest | Quick responses, classification |
| Gemini 2.0 Flash | $0.10 in / $0.40 out | Fast | Cheapest, multimodal (images+text) | |
| DeepSeek V3 | DeepSeek | $0.27 in / $1.10 out | Fast | Strong reasoning, open-weight |
| Llama 3.1 70B | Meta (via Groq) | Free tier / $0.59 in / $0.79 out | Very fast | Open source, privacy, self-host |
| Mistral Large | Mistral | $2.00 in / $6.00 out | Fast | EU compliance, multilingual |
Provider Details
1. OpenAI (GPT-4o, GPT-4o-mini)
Best for: Default choice. Great quality, easy API, huge community.
Getting an API key:
1. Go to https://platform.openai.com/api-keys
2. Click "Create new secret key"
3. Copy the key (starts with sk-...)
4. Add to .env:
OPENAI_API_KEY=sk-...
Free credit: New accounts get $5-50 free credit (varies).
Code example:
from openai import OpenAI
import os
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
response = client.chat.completions.create(
model="gpt-4o-mini", # or "gpt-4o" for higher quality
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)
Pricing example: 1,000 chat conversations × 500 input tokens + 500 output tokens = ($0.15 × 0.5M + $0.60 × 0.5M) = $0.075 + $0.30 = $0.38
2. Anthropic (Claude 3.5 Sonnet, Claude 3 Haiku)
Best for: Complex reasoning tasks, long documents, safety-conscious apps.
Getting an API key:
1. Go to https://console.anthropic.com/
2. Sign up and go to API Keys
3. Create a key (starts with sk-ant-...)
4. Add to .env:
ANTHROPIC_API_KEY=sk-ant-...
Free credit: New accounts get $5-10 free credit.
Code example:
from anthropic import Anthropic
import os
client = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
response = client.messages.create(
model="claude-3-haiku-20240307", # or "claude-3-5-sonnet-20241022"
max_tokens=1000,
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(response.content[0].text)
3. Google (Gemini 2.0 Flash)
Best for: Cheapest option, good quality, handles images + text.
Getting an API key:
1. Go to https://aistudio.google.com/apikey
2. Click "Create API key"
3. Copy the key
4. Add to .env:
GOOGLE_API_KEY=AIza...
Free tier: Very generous — 1,500 requests/day free.
Code example:
import google.generativeai as genai
import os
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
model = genai.GenerativeModel("gemini-2.0-flash")
response = model.generate_content("Hello!")
print(response.text)
4. DeepSeek
Best for: Strong reasoning at a low price. Open-weight model (you can download it).
Getting an API key:
1. Go to https://platform.deepseek.com/
2. Sign up and go to API Keys
3. Create a key
4. Add to .env:
DEEPSEEK_API_KEY=sk-...
Code example:
from openai import OpenAI # DeepSeek uses OpenAI-compatible API
import os
client = OpenAI(
api_key=os.getenv("DEEPSEEK_API_KEY"),
base_url="https://api.deepseek.com"
)
response = client.chat.completions.create(
model="deepseek-chat",
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)
5. Meta Llama 3 (via Groq)
Best for: Open source, extremely fast inference (Groq has custom hardware).
Getting an API key:
1. Go to https://console.groq.com/keys
2. Create a free API key
3. Add to .env:
GROQ_API_KEY=gsk_...
Free tier: Very generous — 30 requests/minute, 14,400/day free.
Code example:
from openai import OpenAI # Groq uses OpenAI-compatible API
import os
client = OpenAI(
api_key=os.getenv("GROQ_API_KEY"),
base_url="https://api.groq.com/openai/v1"
)
response = client.chat.completions.create(
model="llama-3.1-70b-versatile",
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)
6. Mistral
Best for: EU data sovereignty requirements, multilingual apps.
Getting an API key:
1. Go to https://console.mistral.ai/
2. Sign up and go to API Keys
3. Create a key
4. Add to .env:
MISTRAL_API_KEY=...
Code example:
from mistralai import Mistral
import os
client = Mistral(api_key=os.getenv("MISTRAL_API_KEY"))
response = client.chat.complete(
model="mistral-large-latest",
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)
How to Swap Models in Your Chat App
In backend/app/routes.py, the chat endpoint calls an LLM. To swap providers:
Current code (OpenAI):
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=messages
)
Swap to Anthropic:
# Change the import at the top
from anthropic import Anthropic
client = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
# Change the API call
response = client.messages.create(
model="claude-3-haiku-20240307",
max_tokens=1000,
messages=messages
)
reply = response.content[0].text
Swap to DeepSeek:
# Keep OpenAI import, change client setup
client = OpenAI(
api_key=os.getenv("DEEPSEEK_API_KEY"),
base_url="https://api.deepseek.com"
)
# Same call structure
response = client.chat.completions.create(
model="deepseek-chat",
messages=messages
)
reply = response.choices[0].message.content
Cost Estimation Guide
| Usage Level | Model | Monthly Cost |
|---|---|---|
| Personal (100 chats/day) | GPT-4o-mini | ~$0.40/month |
| Personal (100 chats/day) | GPT-4o | ~$6/month |
| Small app (1,000 chats/day) | GPT-4o-mini | ~$4/month |
| Small app (1,000 chats/day) | Claude 3 Haiku | ~$5/month |
| Production (100K chats/day) | GPT-4o-mini | ~$400/month |
| Production (100K chats/day) | Gemini Flash | ~$200/month |
Formula: (Avg input tokens + Avg output tokens) × Total conversations × Token cost
Example: If each chat uses 500 input + 300 output tokens, and you use GPT-4o-mini: - Per chat: (0.0005M × $0.15) + (0.0003M × $0.60) = $0.000075 + $0.00018 = $0.000255 - 10,000 chats: $2.55