Gemini vs Claude for coding
Both families run through the same Code By AI key. This page answers two questions separately: how to connect the tool you already use, and how to compare the two on your own task before you choose one. It also lists each channel's live token prices, including the cached-input price.
Short answer
Compare the selected catalog rows at current Code By AI rates (USD per 1M input / output tokens): Gemini 3.8 Flash $0.075 / $0.375; Claude Sonnet 5 $0.50 / $2.50; these token prices are not a quality ranking or the cost of one identical task.
Token and monthly figures are arithmetic from the current catalog, not a forecast or a measured benchmark. The monthly example excludes cache writes, tools and actual usage differences.
Token prices on the same basis
All values are USD per 1M tokens. Code By AI prices already include the published multiplier. Vendor list prices are shown only when verified. The 5-minute and 1-hour cache writes apply only to Claude and use each platform’s own input rate.
| Model | Metric | Code By AI | Official list | OpenRouter |
|---|---|---|---|---|
| Gemini 3.8 Flashgemini-3.8-flash | Input | $0.075 | $0.75 | Not verified |
| Cache read | $0.0075 | $0.075 | Not verified | |
| Cache write (5 min) | Not applicable | Not applicable | Not applicable | |
| Cache write (1 hour) | Not applicable | Not applicable | Not applicable | |
| Output | $0.375 | $3.75 | Not verified | |
| Claude Sonnet 5claude-sonnet-5 | Input | $0.50 | $2.00 | $2.00 |
| Cache read | $0.05 | $0.20 | $0.20 | |
| Cache write (5 min) | $0.625 | $2.50 | $2.50 | |
| Cache write (1 hour) | $1.00 | $4.00 | $4.00 | |
| Output | $2.50 | $10.00 | $10.00 |
OpenRouter standard endpoint (verified): anthropic/claude-sonnet-5 · anthropic · anthropic/claude-sonnet-5-20260630 ·
OpenRouter cells show a number only when the exact provider model ID and rate basis were checked against this catalog row. Cells marked Not verified have no such evidence. Credit-purchase fees and other OpenRouter plans are separate and are never added to the per-token prices here. OpenRouter pricing and FAQ · FAQ
The token table uses one catalog model per family. Monthly list costs and savings are shown only for verified vendor prices. /pricing
The two channels at a glance
Range of verified list prices per 1M tokens in each channel.
| Channel | Models | Input | Cache read | Output |
|---|---|---|---|---|
| Gemini | 5 | $0.75–$2.00 | $0.075–$0.10 | $3.75–$10.00 |
| Claude Code | 12 | $1.00–$10.00 | $0.10–$1.00 | $5.00–$50.00 |
Cache reads that hit are billed at the cached-input price shown here. Re-sending context does not guarantee a hit, and Claude cache writes are billed at 1.25× or 2× the normal input price, so the real cost depends on the hit rate, cache writes and actual usage.
Cost example at a fixed token volume
Each channel shows its cheapest, default and most expensive model at Code By AI rates, for the same workload: 20M input and 2M output tokens.
| Channel | Position | Model | At list price | On Code By AI | Saving vs. list price |
|---|---|---|---|---|---|
| Gemini | Cheapest · Default | gemini-3.8-flash | $22.50 | $2.25 | 90% |
| Most expensive | gemini-3.1-pro-preview | Not verified | $6.40 | — | |
| Claude Code | Cheapest | claude-haiku-4-5-20251001 | $30.00 | $7.50 | 75% |
| Default | claude-sonnet-5 | $60.00 | $15.00 | 75% | |
| Most expensive | claude-fable-5-1 | $300.00 | $75.00 | 75% |
This is arithmetic, not a forecast. Every input token is priced at the normal input rate and caching is left out entirely; cache reads that hit are billed at the cached-input price, so the real cost depends on the hit rate, cache writes and actual usage. It is not a subscription price, and it is not what the same task would cost on each channel: two models of similar price can differ in capability and use different numbers of tokens for the same job. Compare rows of similar cost across channels, not just the two defaults.
Already using one of the tools: connect it
Gemini CLI
Set these two variables. The base URL ends at /api/agent: Gemini CLI adds the request path itself, so do not paste a full request URL from the table further down. Then use a Gemini model ID from the tables above.
export GOOGLE_GEMINI_BASE_URL="https://www.codebyai.net/api/agent"
export GEMINI_API_KEY="sk-proj-xxxx"Current Gemini CLI versions also need API-key sign-in selected in ~/.gemini/settings.json; the setup guide shows the exact file.
Gemini setup guideClaude Code
Set these two variables. The base URL ends at /api/agent: Claude Code adds /v1/messages itself, so do not paste a full request URL from the table further down. Then use a Claude model ID from the tables above.
export ANTHROPIC_BASE_URL="https://www.codebyai.net/api/agent"
export ANTHROPIC_AUTH_TOKEN="sk-proj-xxxx"Claude Code setup guideNot decided yet: run the same task on both
Which tool works better depends on your codebase and your tasks, so the useful comparison is one you run yourself. One key covers both, so a trial needs no extra account.
- Pick a real task with a clear finish line, such as fixing a bug that has a failing test or adding tests for one module.
- Create two branches from the same commit, one for each tool, so both start from identical code.
- Give both tools the same prompt, and pick models of similar cost from the tables above so the comparison is fair. While a run is going, send no other requests to that model, from any tool or key.
- Right before each run, refresh Usage History and note the day's totals for that model. Right after it, refresh and note them again. The run's cost is the difference.
- Record the results in the template below. Repeat with two or three tasks before drawing a conclusion.
Copy this template into your notes and fill it in after each run:
| Measure | Claude Code | Gemini CLI |
| --- | --- | --- |
| Tests pass without your help? | | |
| Lines you changed by hand afterwards | | |
| Wall-clock time to a mergeable result | | |
| Tokens and quota used (after minus before) | | |Usage History adds up all requests per model per day; it does not list single requests. That is why each run's cost has to be taken as a before-and-after difference. A run that crosses midnight lands on two days' rows, so add both. Open Usage History
Full request URLs for direct API calls
All three endpoints share the base URL https://www.codebyai.net/api/agent. Each keeps its own wire format, so send a model ID the endpoint accepts.
Setting up Claude Code or Gemini CLI? Use only the base URL https://www.codebyai.net/api/agent from the setup cards above. These clients add the request path themselves, so a full URL from this table would end up with the path twice.
| Protocol | Endpoint | Model families | Typical use |
|---|---|---|---|
| Anthropic Messages | https://www.codebyai.net/api/agent/v1/messages | Claude only | curl or the Anthropic SDK |
| OpenAI Chat Completions | https://www.codebyai.net/api/agent/v1/chat/completions | Claude (also GPT) | OpenAI-compatible SDKs and apps |
| Gemini generateContent | https://www.codebyai.net/api/agent/v1beta/models/{model}:generateContent | Gemini only | curl or the Google Gen AI SDK |
Gemini does not use the Chat Completions endpoint on this page. Use the generateContent endpoint for Gemini model IDs.
Gemini models: full price comparison
| Model | List price | You pay |
|---|---|---|
| gemini-3.8-flashDefault | $0.75 / $0.075 / $3.75 | $0.075 / $0.0075 / $0.375 |
| gemini-3.7-flash | Not verified | $0.10 / $0.01 / $0.30 |
| gemini-3.1-pro-preview | Not verified | $0.20 / $0.02 / $1.20 |
| gemini-4-argon | $2.00 / $0.10 / $10.00 | $0.20 / $0.01 / $1.00 |
| gemini-4-carbon | $2.00 / $0.10 / $10.00 | $0.20 / $0.01 / $1.00 |
per 1M tokens (input / cache read / output)
Gemini model service may be unstable due to recent upstream risk controls. Please choose carefully.
Claude Code models: full price comparison
| Model | List price | You pay |
|---|---|---|
| claude-haiku-4-5-20251001 | $1.00 / $0.10 / $5.00 | $0.25 / $0.025 / $1.25 |
| claude-sonnet-5Default | $2.00 / $0.20 / $10.00 | $0.50 / $0.05 / $2.50 |
| claude-sonnet-5-5 | $2.00 / $0.10 / $10.00 | $0.50 / $0.025 / $2.50 |
| claude-sonnet-4-6 | $3.00 / $0.30 / $15.00 | $0.75 / $0.075 / $3.75 |
| claude-opus-5-5 | $4.00 / $0.20 / $20.00 | $1.00 / $0.05 / $5.00 |
| claude-opus-4-6 | $5.00 / $0.50 / $25.00 | $1.25 / $0.125 / $6.25 |
| claude-opus-4-7 | $5.00 / $0.50 / $25.00 | $1.25 / $0.125 / $6.25 |
| claude-opus-4-8 | $5.00 / $0.50 / $25.00 | $1.25 / $0.125 / $6.25 |
| claude-opus-5 | $5.00 / $0.50 / $25.00 | $1.25 / $0.125 / $6.25 |
| claude-fable-5-2 | $8.00 / $0.20 / $40.00 | $2.00 / $0.05 / $10.00 |
| claude-fable-5 | $10.00 / $1.00 / $50.00 | $2.50 / $0.25 / $12.50 |
| claude-fable-5-1 | $10.00 / $0.25 / $50.00 | $2.50 / $0.0625 / $12.50 |
Claude cache writes cost 1.25× the input rate for 5-minute entries or 2× for 1-hour entries. These rates replace the normal input rate for those tokens; the cache-read price applies only to reads.
per 1M tokens (input / cache read / output)
FAQ
- Do Gemini and Claude need different API keys?
- No. One Code By AI key covers both channels. Each tool still needs its own endpoint and a model ID from that channel.
- I have not picked a tool yet. How do I decide?
- Run the trial above: give both tools the same real task from the same commit, then compare whether the tests pass, how much you had to edit by hand, how long it took and what it cost. Two or three tasks typical of your project say more than any general ranking, and this page does not rank them because the result depends on your code.
- Are the prices on this page fixed?
- No. The tables read the live catalog, so they always show current prices. The cost example uses one fixed token volume for both channels; it is not a subscription price or the cost of any particular task.