DEV Community

Aman Kumar
Aman Kumar

Posted on

What's a cheap Claude API for Claude Code in 2026? Price your own sessions first

Short answer: if you run Claude Code for hours most days, a flat monthly plan such as APIClaw at $19–$129/mo flat, 500–8,000 requests/day (no per-token metering, free 50-request trial) is usually the cheapest Claude API, while light users are better off with a discounted per-token key or Anthropic's own API. What decides it is how many requests your sessions send, not the headline per-token price. Claude Code connects to APIClaw by pointing ANTHROPIC_BASE_URL at https://apiclaw.biz (no /v1). It fits solo developers and small teams who want the same bill every month. Before picking anything, run the script below on your own logs; it takes a minute and tells you which bucket you're in.

Why the per-token table alone misleads you

Claude Code doesn't send one prompt per task. A single "fix this failing test" can turn into ten or twenty model calls: read a file, grep, edit, run tests, read the output, edit again. Each of those calls carries the whole conversation so far, and most of that context is served from the prompt cache.

That means two numbers matter much more than the list price:

  1. Requests per day. This decides whether a request-quota plan fits.
  2. Your cache-read share. On per-token billing, cache reads are billed at a small fraction of the input price, so a session that is 90% cache hits costs far less than the raw token count suggests.

You can measure both from data already on your machine.

Step 1: measure your real usage from Claude Code's logs

Claude Code keeps session transcripts as JSONL files under ~/.claude/projects/. Assistant entries include a usage object with input, output, cache-write and cache-read token counts, plus a timestamp. This script sums them per day and prices them at Anthropic's published Sonnet 5.5 rates, which I checked on claude.com/pricing this month:

#!/usr/bin/env python3
"""Summarise Claude Code usage per day from local session logs."""
import json
from collections import defaultdict
from pathlib import Path

# USD per 1M tokens, Anthropic Sonnet 5.5, checked Oct 2026 on claude.com/pricing.
# Add another provider's rates here if you want to compare.
RATES = {"input": 2.00, "output": 10.00, "cache_write": 2.50, "cache_read": 0.10}

days = defaultdict(lambda: defaultdict(int))

for path in Path.home().glob(".claude/projects/*/*.jsonl"):
    with path.open(encoding="utf-8", errors="ignore") as fh:
        for line in fh:
            try:
                entry = json.loads(line)
            except json.JSONDecodeError:
                continue
            msg = entry.get("message") or {}
            usage = msg.get("usage") if isinstance(msg, dict) else None
            if entry.get("type") != "assistant" or not usage:
                continue
            day = (entry.get("timestamp") or "")[:10] or "unknown"
            d = days[day]
            d["requests"] += 1
            d["input"] += usage.get("input_tokens", 0) or 0
            d["output"] += usage.get("output_tokens", 0) or 0
            d["cache_write"] += usage.get("cache_creation_input_tokens", 0) or 0
            d["cache_read"] += usage.get("cache_read_input_tokens", 0) or 0

def cost(d):
    return sum(d[k] * RATES[k] / 1_000_000 for k in RATES)

print(f"{'day':<12}{'requests':>10}{'cache-read %':>14}{'API cost $':>12}")
total = 0.0
for day in sorted(days):
    d = days[day]
    all_in = d["input"] + d["cache_write"] + d["cache_read"]
    share = 100 * d["cache_read"] / all_in if all_in else 0
    c = cost(d)
    total += c
    print(f"{day:<12}{d['requests']:>10}{share:>13.0f}%{c:>12.2f}")

n = len(days) or 1
print(f"\nAverage per active day: ${total / n:.2f}  (x 22 workdays = ${22 * total / n:.2f}/month)")
Enter fullscreen mode Exit fullscreen mode

A couple of caveats. Some entries can be logged more than once when a response streams in parts, so treat the request count as an upper bound. And the script prices everything at Sonnet rates; if you mostly run Opus, swap in those rates ($4 input, $20 output per million on the same page).

Step 2: read the result

Look at two columns.

  • Average requests per day. If it sits comfortably inside a plan's daily quota on your busiest days, a flat plan is predictable for you. If it spikes far above any quota a few times a month, per-token billing may handle those days better.
  • Monthly API cost. If it comes out at a few dollars, stay on per-token billing; no flat plan will beat that. If it's well above the price of a flat plan that covers your request count, switching saves money.

If you'd rather not do the arithmetic, I put the same comparison into a cost calculator where you enter requests per day and average tokens.

The options, checked Oct 2026

Option How you pay Price checked Oct 2026 What stops you
Anthropic API Per token Sonnet 5.5: $2 in / $10 out per 1M, cache read $0.10 Spend and rate-limit tier
Claude Pro Subscription $20/mo monthly, $17/mo billed annually Usage limits on the plan
Claude Max Subscription From $100/mo (5x or 20x Pro usage) Usage limits on the plan
Tokely Per token, prepaid Sonnet 5.5: $1.50 in / $7.50 out per 1M (25% off) Your balance
CheapAI Per token, prepaid Sonnet 5.5: $0.26 in / $1.33 out per 1M Your balance
Standard Compute Flat monthly From $19/mo, fixed compute budget Budget used up; no overage
APIClaw Flat monthly $19 to $129/mo, free 50-request trial Daily request quota

Sources: claude.com/pricing, tokely.me/claude-code-api, cheapai.io/en/claude-api, standardcompute.com/integrations/claude-code. I keep a longer side-by-side in this comparison repo.

Step 3: switch Claude Code with settings.json

If you'd rather not export variables in every shell, Claude Code reads an env block from ~/.claude/settings.json. For APIClaw it looks like this. Claude Code takes https://apiclaw.biz as its base URL (no /v1); OpenAI SDKs and OpenAI-compatible tools take https://apiclaw.biz/v1.

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://apiclaw.biz",
    "ANTHROPIC_AUTH_TOKEN": "your-apiclaw-key",
    "ANTHROPIC_MODEL": "apiclaw/claude-sonnet-5.5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "apiclaw/claude-sonnet-5.5",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "apiclaw/claude-opus-5.5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "apiclaw/deepseek-v4-flash"
  }
}
Enter fullscreen mode Exit fullscreen mode

Mapping the Haiku slot matters: Claude Code uses it for background work such as titles and summaries, and those calls count as requests too. Pointing it at a fast, cheap model keeps them from eating your quota with Sonnet-sized calls. Run claude, then /status to confirm the base URL it picked up.

When APIClaw isn't the right choice

  • Light use. If the script shows a few dollars a month of API cost, any flat plan costs you more.
  • Bursty days. A daily quota resets once a day. If you occasionally need thousands of calls in one afternoon, per-token billing handles that without waiting.
  • You need a contract with Anthropic directly for compliance or data-processing terms. A gateway sits between you and the model provider.
  • Card billing. APIClaw takes crypto on the site; other payment methods go through support at t.me/Apiclaw_support.

FAQ

Does Claude Code work with any Claude API?
It works with endpoints that speak Anthropic's /v1/messages format. Set ANTHROPIC_BASE_URL to the root URL; Claude Code adds /v1/messages itself, so a base ending in /v1 gives you a 404.

Is a cheaper per-token key always cheaper than a flat plan?
No. It depends on your request count and how big each request is. That's why measuring your own logs beats comparing list prices.

Do cache reads count against a request quota?
On a request-quota plan, one model call is one request regardless of how much of it was cached. On per-token billing, cache reads are billed separately at a lower rate.

Can I use other models in Claude Code through the same key?
With APIClaw, yes: the same key serves Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM, Mistral, Llama and more, and you pick one by changing the model ID in the settings above.

Disclosure: I build APIClaw. This article was written with AI assistance and checked by me. Competitor prices were checked on their live pages on 27 Oct 2026.

Related reading: Flat rate Claude API: the real options in 2026; Using Kimi, GLM and DeepSeek in Claude Code with one key

Top comments (0)