freeaiapi.aiSign Up

Use Claude Code with a pay-per-token API key

Claude Code supports LLM gateways out of the box. Point it at freeaiapi.ai, keep using Claude models, and pay per token from a prepaid balance — no subscription, up to 30% below official API prices.

Get your Claude Code API keyLast updated

Set up in two minutes

  1. Step 1

    Get an API key

    Create a free account. Connect Telegram and join our channel to unlock $1 trial credit, then create your key.

  2. Step 2

    Point Claude Code at the gateway

    Set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN in your Claude Code settings.

  3. Step 3

    Run claude

    Start Claude Code as usual. Requests go through the gateway and are billed per token.

Claude Code settings

Add this to ~/.claude/settings.json (or export the same variables in your shell). The base URL has no /v1 — Claude Code adds the path itself.

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.freeaiapi.ai",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_FREEAIAPI_KEY",
    "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1"
  }
}

Claude model prices

What Claude Code usage costs per 1M tokens, next to Anthropic's official API price.

Claude model prices
ModelOfficial input /MOfficial output /MOur input /MOur output /MYou save
claude-haiku-4-5-20251001$1.00$5.00$0.70$3.50−30%
claude-haiku-5-5$0.10$0.50$0.07$0.35−30%
claude-opus-4-5-20251101$5.00$25.00$3.50$17.50−30%
claude-opus-4-6$5.00$25.00$3.50$17.50−30%
claude-opus-4-7$5.00$25.00$3.50$17.50−30%
claude-opus-4-8$5.00$25.00$3.50$17.50−30%
claude-opus-5$5.00$25.00$3.50$17.50−30%
claude-opus-5-5$4.00$20.00$2.80$14.00−30%
claude-sonnet-4-5-20250929$3.00$15.00$2.10$10.50−30%
claude-sonnet-4-6$3.00$15.00$2.10$10.50−30%
claude-sonnet-5$2.00$10.00$1.40$7.00−30%
claude-sonnet-5-5$2.00$10.00$1.40$7.00−30%

Subscription or pay per token?

Claude Code is included in Anthropic's paid plans, which have usage limits that reset over time. If you code with it all day, every day, a plan can work out cheaper.

If your usage is irregular — a few sessions a week, a team sharing budget, CI jobs, or bursts that hit plan limits — paying per token means you pay only for what you use and never wait for a limit to reset.

Frequently asked questions

Does Claude Code officially support custom API endpoints?

Yes. Claude Code supports LLM gateways through the ANTHROPIC_BASE_URL setting, with credentials passed via ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY.

Can I use non-Claude models in Claude Code?

Anthropic does not support routing Claude Code to non-Claude models through a gateway, so we recommend using Claude models. For other models, use a tool built for them, such as OpenCode, Cline or Kilo Code.

Should the base URL include /v1?

No. Use https://api.freeaiapi.ai. Claude Code appends /v1/messages itself.

Is there a free option?

Connect Telegram and join our channel to unlock $1 trial credit, with no card required, so you can try Claude Code on the gateway before paying.

Related

Get your free API key

No card required. One key for every model, up to 30% below official pricing.

Get free API key