AI API Pricing Comparison: OpenAI, Anthropic, Google, and More
How Token Pricing Works
Every AI API provider charges by the token. Tokens are the smallest unit of text the model processes. In English, one token averages about 4 characters or 0.75 words. A 1,000 word document uses roughly 1,300 tokens. A typical chatbot conversation (user question plus AI response) uses 500 to 2,000 tokens total.
Input tokens and output tokens are priced separately. Input tokens include everything you send to the model: the system prompt, the conversation history, any retrieved context from your knowledge base, and the user's latest message. Output tokens are what the model generates in response. Input tokens always cost less than output tokens because the model does more computational work when generating new text than when reading existing text.
This distinction matters for cost optimization. A chatbot that sends 3,000 tokens of knowledge base context with every query but only generates a 200 token response spends most of its budget on input tokens. Understanding this ratio helps you pick the most cost effective provider for your specific use case.
Anthropic (Claude) Pricing
Anthropic offers three model tiers under the Claude brand:
Input: $0.25 per million tokens. Output: $1.25 per million tokens. The fastest and cheapest Claude model, optimized for high volume tasks like customer support, content classification, and data extraction. Handles straightforward conversations with quality comparable to frontier models from two years ago.
Input: $3.00 per million tokens. Output: $15.00 per million tokens. The workhorse model for most applications. Strong at complex reasoning, nuanced writing, code generation, and multi-step tasks. Best balance of capability and cost for production applications.
Input: $15.00 per million tokens. Output: $75.00 per million tokens. The most capable Claude model, used for tasks requiring advanced reasoning, complex analysis, or the highest quality output. Most applications do not need this tier.
Anthropic also offers prompt caching, which stores frequently used prompt prefixes (like system prompts and knowledge base context) on their servers. Cached tokens cost 90% less than regular input tokens. For chatbots that send the same context with every message, this reduces the effective input cost dramatically. A 3,000 token system prompt that normally costs $0.009 per call at Sonnet rates drops to $0.0009 per call when cached.
Batch API processing gives an additional 50% discount on both input and output tokens. If your workload can tolerate a few hours of delay (email processing, content generation, data analysis), batch pricing makes Anthropic's models extremely cost effective.
OpenAI (GPT) Pricing
Input: $0.15 per million tokens. Output: $0.60 per million tokens. OpenAI's budget model, comparable to Claude Haiku. Good for high volume, straightforward tasks.
Input: $2.50 per million tokens. Output: $10.00 per million tokens. The standard production model, comparable to Claude Sonnet. Handles most business applications well.
Input: $10.00 to $15.00 per million tokens. Output: $30.00 to $60.00 per million tokens. OpenAI's most capable models, with o3 adding extended reasoning for complex problem solving at additional compute cost.
OpenAI offers similar prompt caching and batch API discounts. Their Assistants API bundles conversation management and file retrieval but charges additional fees for storage and retrieval operations on top of token costs.
Google (Gemini) Pricing
Input: $0.075 per million tokens. Output: $0.30 per million tokens. The cheapest option among the major providers. Extremely competitive for high-volume, simple tasks. Google subsidizes aggressively to gain market share.
Input: $1.25 per million tokens. Output: $5.00 per million tokens. Comparable to Sonnet and GPT-4o for most tasks, with the added advantage of a very large context window (up to 2 million tokens).
Input: $7.00 per million tokens. Output: $21.00 per million tokens. Google's most capable model, priced lower than Anthropic and OpenAI's frontier offerings.
Google's pricing advantage comes with context window generosity. Gemini models accept up to 2 million tokens of input, meaning you can include entire documents or long conversation histories without truncation. For applications that need to process large documents, this can eliminate the need for a separate RAG pipeline, simplifying your architecture and reducing development costs.
Open Source Model Costs
Running open source models (Llama 3, Mistral, Qwen, DeepSeek) eliminates per-token API fees entirely. Instead, you pay for GPU compute. The cost depends on the model size and your infrastructure choice:
- 7B to 8B parameter models (Llama 3 8B, Mistral 7B): Run on a single GPU with 24GB VRAM. Cloud GPU cost: $0.40 to $0.80 per hour. Community GPU marketplaces like Vast.ai offer rates as low as $0.15 per hour for comparable hardware.
- 70B parameter models (Llama 3 70B): Need 2 to 4 GPUs. Cloud cost: $3 to $8 per hour. These models match mid-tier API quality for most tasks.
- 400B+ parameter models: Need 8+ high end GPUs. Cloud cost: $15 to $30 per hour. Only practical for organizations with existing GPU infrastructure.
The break-even point between open source self-hosting and API usage depends on your volume. At 10,000 requests per day, self hosting a 7B model on a single GPU costs roughly $300 to $600 per month, while the equivalent API calls at budget model rates cost $30 to $100 per month. APIs win at this volume. At 100,000 requests per day, self hosting costs the same $300 to $600 per month (the GPU runs regardless of utilization), while API costs scale to $300 to $1,000 per month. At this volume, the calculus starts to favor self hosting, especially when you factor in data privacy and latency benefits.
Cost Optimization Strategies
Model Routing
Use a cheap model for simple queries and route complex queries to a more capable model. A customer service chatbot can send 85% of conversations to Haiku or GPT-4o mini (at $0.25 per million tokens) and only escalate complex or sensitive queries to Sonnet or GPT-4o ($3 to $10 per million tokens). This cuts your average cost per conversation by 60% to 80% compared to sending everything to the mid-tier model.
Prompt Caching
Structure your prompts so the static parts (system prompt, knowledge base context) come first and the dynamic parts (user message, conversation history) come last. This maximizes cache hit rates and reduces input costs by up to 90% on repeated calls.
Batch Processing
Any workload that does not need real-time responses should use batch APIs. Content generation, email processing, data analysis, report generation, and document classification all work well in batch mode at half the per-token cost.
Context Window Management
Sending less context saves money. Instead of including your entire knowledge base in every prompt, use RAG to retrieve only the most relevant sections. Instead of sending the full conversation history, summarize older messages. Every token you do not send is a token you do not pay for.