freeaiapi.ai
Integrations

Claude Code

Run Claude Code on a pay-per-token freeaiapi.ai key.

Claude Code supports LLM gateways. Point it at freeaiapi.ai with two settings.

Configure

Add this to ~/.claude/settings.json (or export the same variables in your shell):

~/.claude/settings.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.freeaiapi.ai",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_FREEAIAPI_KEY",
    "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1"
  }
}
  • ANTHROPIC_BASE_URL has no /v1 — Claude Code appends /v1/messages itself.
  • ANTHROPIC_AUTH_TOKEN is sent as Authorization: Bearer. ANTHROPIC_API_KEY (sent as x-api-key) also works.
  • CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY fills the model picker from GET /v1/models.

Choose models

Set ANTHROPIC_MODEL to pin a model, and ANTHROPIC_DEFAULT_HAIKU_MODEL for the model Claude Code uses for background tasks. Use Claude model IDs from the model list.

Anthropic does not support routing Claude Code to non-Claude models through a gateway. Use Claude models with Claude Code; for other models, use OpenCode, Cline or Kilo Code.

On this page