n4nAI

GPT-4o vs Claude vs Gemini: cost per million tokens

Practical head-to-head comparison of GPT-4o vs Claude vs Gemini pricing, capabilities, latency, and ergonomics for engineers optimizing LLM app cost.

n4n Team3 min read739 words

Audio narration

Coming soon — every post will get a voice note here.

The first line item in any LLM budget is the model itself, and GPT-4o vs Claude vs Gemini pricing drives most early architecture decisions. But token rates alone don’t determine spend—capabilities, latency, and ecosystem fit change the equation fast once you ship.

Capabilities

GPT-4o is OpenAI’s omni-model: strong general reasoning, native vision, and audio I/O through a single weight set. It handles structured extraction and tool calling with high reliability, which is why it remains the default for mixed-modality product surfaces.

Claude (specifically Claude 3.5 Sonnet as the current flagship) wins on long-form comprehension, code generation, and agentic workflows. Its strength is following nuanced instructions inside large prompts without drifting, making it the pick for document-heavy pipelines.

Gemini 1.5 Pro ships with a 1M-token context (2M in private preview) and native multimodal ingestion of text, image, audio, and video. It lags slightly on complex instruction adherence but excels when you need to ground a query in massive corpora without external chunking.

Price and cost model

Published list prices (Q4 2024) for the flagships:

  • GPT-4o: $2.50 / 1M input tokens, $10 / 1M output tokens.
  • Claude 3.5 Sonnet: $3 / 1M input, $15 / 1M output.
  • Gemini 1.5 Pro: $3.50 / 1M input, $10.50 / 1M output for prompts over 128k; $1.25 / $5 below that tier.

The GPT-4o vs Claude vs Gemini pricing gap narrows when you factor prompt caching. Anthropic and Google both offer cache write/read discounts; OpenAI added prompt caching at $1.25 / 1M cached input for GPT-4o. If your traffic repeats system prompts, effective cost can drop 50–90%.

# Cost estimate for a 10k-token repeated system prompt + 2k new tokens, 100k calls/mo
models = {
    "gpt-4o": {"in": 2.50, "out": 10.0, "cache": 1.25},
    "claude-3-5-sonnet": {"in": 3.0, "out": 15.0, "cache": 0.30},
    "gemini-1.5-pro": {"in": 3.50, "out": 10.50, "cache": 0.875},
}
for name, p in models.items():
    cached_in = 10_000 * p["cache"] / 1e6
    new_in = 2_000 * p["in"] / 1e6
    out = 1_000 * p["out"] / 1e6  # assume 1k output
    print(name, (cached_in + new_in + out) * 100_000)

Latency and throughput

Raw benchmark numbers shift weekly, so treat these as operational ranges from production traffic:

  • GPT-4o: lowest time-to-first-token (TTFT) among the three at ~300–500ms for small prompts; sustained throughput ~100–150 tok/s per stream.
  • Claude 3.5 Sonnet: TTFT ~600–900ms; throughput similar but more sensitive to prompt length past 32k tokens.
  • Gemini 1.5 Pro: TTFT highly variable by region; can be 400ms on Vertex but degrades when context exceeds 500k tokens.

If you need interactive UX, GPT-4o leads. For batch extraction over night, all three are acceptable.

Ergonomics

OpenAI’s API is the de facto standard. The Anthropic SDK differs (separate messages shape, system as top-level), but a gateway such as n4n.ai collapses these three into one OpenAI-compatible endpoint covering 240+ models, so the same client code swaps models by string.

from openai import OpenAI
client = OpenAI(base_url="https://api.n4n.ai/v1", api_key="sk-...")

for model in ["gpt-4o", "claude-3-5-sonnet", "gemini-1.5-pro"]:
    r = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": "Summarize: ..."}],
        max_tokens=512,
    )
    print(model, r.usage.total_tokens)

Gemini exposes cache-control via systemInstruction and cachedContent objects in Google’s SDK; through an OpenAI-compatible proxy, those map to extra_body routing hints. The gateway honors client routing directives and forwards provider cache-control hints, which matters when you want Claude’s prompt caching without leaving the OpenAI SDK.

Ecosystem

  • GPT-4o: largest third-party tooling, fine-tuning available, Azure OpenAI mirroring.
  • Claude: Anthropic-first, but available on AWS Bedrock and GCP Vertex; no self-serve fine-tune on 3.5 yet.
  • Gemini: native to Google Cloud, tight with BigQuery and Vertex AI; open-weight variants (Gemma) for local.

If you’re already on GCP, Gemini’s egress zero-cost is a real line item. On AWS, Bedrock’s Claude integration avoids cross-cloud fees.

Limits

Dimension GPT-4o Claude 3.5 Sonnet Gemini 1.5 Pro
Context window 128k tokens 200k (1M beta) 1M (2M preview)
Max output 4k (configurable to 16k) 8k (configurable) 8k
Modalities Text, image, audio Text, image (input) Text, image, audio, video
Rate limit (tier 1) 10k req/min 4k req/min 1.5k req/min (Vertex)
Fine-tune Yes No (3.5) Yes (custom)

Routing and fallback

In production you rarely lock to one model. Automatic fallback when a provider is rate-limited or degraded keeps p99 latency bounded. With per-token usage metering you can attribute cost to features without building your own accounting layer.

{
  "route": {
    "primary": "gpt-4o",
    "fallback": ["claude-3-5-sonnet", "gemini-1.5-pro"],
    "on_error": [429, 503]
  },
  "cache_control": {"type": "ephemeral", "ttl": 3600}
}

Which to choose

High-volume chat with low latency: GPT-4o. Best TTFT and cheapest cached input among the three at scale.

Long-document analysis or agentic coding: Claude 3.5 Sonnet. The 200k window and instruction fidelity offset the higher output price.

Massive context or Google-cloud-native: Gemini 1.5 Pro. The 1M window removes your chunking layer; sub-128k pricing undercuts both rivals.

Cost-sensitive MVP: Start on Gemini 1.5 Pro (sub-128k tier) or GPT-4o mini if quality permits, then promote to flagship only for low-frequency complex calls.

Resilient production: Use all three behind a routing layer with fallback. Keep GPT-4o primary, Claude for long prompts, Gemini for overflow. Meter per token and revisit the GPT-4o vs Claude vs Gemini pricing quarterly—the list prices move every few months.

Tagsgpt-4oclaudegeminipricing

Written by

n4n Team

The team building n4n — a single OpenAI-compatible API in front of 240+ models, with automatic fallback, load balancing and pay-per-token metering.

More from n4n Team →

All cost optimization & model routing posts →