Models for large codebases: when context size is the deciding factor
Fourteen ids here take 1,000,000 tokens and GPT 6 Astra Stable takes 1,050,000. Filling a 1M window costs $0.050 on Gemini 3 Flash and $2.00 on Astra — per request, every request.
The context ladder has five rungs
At 200,000 tokens: Claude Sonnet 4.6, Claude Sonnet 4.6 Stable, Claude Haiku 4.5 Stable and Grok Composer 2.5 Fast. At 272,000: GPT 5.5, GPT 5.4 and GPT 5.4 Mini. At 372,000: GPT 5.6 Sol, Terra and Luna. At 500,000: Grok 4.6 and Grok 4.5.
The top rung is 1,000,000 tokens and it is crowded: Claude Fable 5 Stable and Fable 5.1 Stable, Claude Opus 5 and its stable lane, Opus 4.8 and its stable lane, Opus 4.6, Claude Sonnet 5 and its stable lane, and all five Gemini ids — Gemini 3.8 Flash, 3.7 Flash, 3.6 Flash, 3 Flash and 3.1 Pro. One id sits above it: GPT 6 Astra Stable at 1,050,000.
Output ceilings do not follow the same ordering. The 1M-context Claude ids and the GPT 5.6 family emit up to 128,000 tokens; Grok 4.6 and 4.5 and every Gemini id stop at 65,536 (65,535 on Gemini 3.1 Pro); the 200k Claude ids and the older GPT ids at 64,000; Grok Composer 2.5 Fast at 32,768. A job that reads a large repository and writes a large migration is constrained at both ends.
A big window is room, not recall — and you pay for what you fill it with
Per-token price does not change with how full the window is. One million input tokens, sent once, costs $0.050 on Gemini 3 Flash (0.1× of the $0.50/M official rate), $0.075 on Gemini 3.7 Flash, $0.20 on Grok 4.6, $0.30 on Claude Sonnet 5, $0.50 on Claude Opus 5 and $2.00 on GPT 6 Astra Stable (0.2× of $10/M).
Those are per-request figures, and that is the part people miss. A conversation that re-pastes the same million tokens on each of twenty turns pays for twenty million input tokens: $10 on Claude Opus 5, $40 on GPT 6 Astra Stable, for what a human would describe as "the same repo, twenty questions".
Two levers change that curve. Prompt caching bills a genuinely repeating prefix — a system prompt, a set of files the conversation keeps returning to — as a cache read rather than fresh input on later turns. Retrieval is the blunter one: sending the 30,000 tokens that matter beats sending the 900,000 that might, and it is 30× cheaper on every id above.
export TOKEN_SHARE_KEY="<your-pool-api-key>"
# Rough sizing: bytes / 4 is a usable first approximation for source code.
TOKENS=$(git ls-files '*.ts' '*.tsx' '*.go' '*.py' \
| xargs wc -c | awk 'END { print int($1 / 4) }')
echo "approx input tokens: $TOKENS"
# Consumer rates are quoted per MILLION tokens.
# claude-sonnet-5: 0.1x of $3/M official = $0.30/M consumer.
awk -v t="$TOKENS" 'BEGIN { printf "one request: $%.4f\n", t / 1000000 * 0.30 }'
# The authoritative count is the one the gateway reports back.
curl -sS https://token-share.app/v1/messages \
-H "x-api-key: $TOKEN_SHARE_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Summarise the module layout."}]
}' | jq '.usage'Cost and headroom move independently
The largest window in the catalog is not the cheapest per token, and the cheapest per token is not the smallest window. Gemini 3 Flash pairs a 1,000,000-token window with the lowest consumer input rate here, $0.050/M. GPT 6 Astra Stable pairs the largest window, 1,050,000, with $2.00/M — 40× the Gemini figure, from a $10/M official rate at a 0.2× multiplier.
Grok 4.6 sits between them on both axes: 500,000 tokens at $0.20/M. Claude Sonnet 5 gives 1,000,000 at $0.30/M and Claude Opus 5 the same window at $0.50/M. So "I need a big window" narrows the field to fifteen ids and settles nothing about price.
What a table cannot tell you is whether a model uses the far end of its window well on your material. That is measurable: put a fact you need at 80% depth in a real 500,000-token payload, ask for it, and see what comes back. Do it on your own files — a synthetic needle test says little about how a model handles your code.
Route shape when the payload is large
The 1M-context Claude ids and GPT 6 Astra Stable answer on /v1/messages with x-api-key and anthropic-version: 2023-06-01. Gemini and Grok ids answer on /v1/chat/completions with Authorization: Bearer. The GPT 5.6 family and the 5.x ids answer on /v1/responses with the same bearer header.
Large requests are exactly where you want streaming on: a 500,000-token prompt takes time to process before the first token appears, and a non-streaming client can look hung when it is merely working.
Every response reports usage. Log it. The gateway's count is the one you are billed on, and comparing it against your own estimate is how a repo-sized prompt stops being a surprise at the end of the month.