---
title: "Claude Code API: Run It on FreeTheAI Models"
description: "Run Claude Code with AI models like GLM 5.3 and Kimi K3 through FreeTheAI. Tested settings.json and environment variables."
url: https://freetheai.org/setup/claude-code
language: en
updated: 2026-09-29
---

# Claude Code API: Run It on FreeTheAI Models

Claude Code can run on FreeTheAI's Anthropic-compatible Messages endpoint. Point ANTHROPIC_BASE_URL at FreeTheAI and choose which model fills each Claude slot.

## Settings

- ANTHROPIC_BASE_URL: `https://api.freetheai.org`
- ANTHROPIC_AUTH_TOKEN: `your FreeTheAI key (ftai_..., 53 characters)`
- ANTHROPIC_MODEL: `glm-5.3`

## Steps

1. **Add the settings.** Put this in ~/.claude/settings.json (on Windows, %USERPROFILE%\.claude\settings.json). Never put your key in a project's shared .claude/settings.json.

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.freetheai.org",
    "ANTHROPIC_AUTH_TOKEN": "ftai_your_key_here",
    "ANTHROPIC_MODEL": "glm-5.3",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.3",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.3",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.3-flash",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```
2. **Start Claude Code.** Run claude, then /status. The Anthropic base URL line should show https://api.freetheai.org.
3. **Add funds.** Paid models bill your wallet. Add funds at freetheai.org/dashboard/wallet and follow a provider of the model on its page, or requests are refused.

## Tips

- Claude Code warns that FreeTheAI models are not in its model catalog. That is expected; it still works and assumes a 200K context.
- The HAIKU model runs background tasks such as titles, so a fast model fits there.
- If a model answers 400 about unknown fields, add "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1".

## Troubleshooting

**Is using Claude Code with FreeTheAI official?**

No. Claude Code supports custom gateways through ANTHROPIC_BASE_URL, but Anthropic does not support non-Claude models behind one, so some Claude-only features may not work.

**Does Claude Code tool use work on FreeTheAI?**

Yes. File reading and other tools were tested on 2026-09-29 with glm-5.3 and kimi-k3.1-pro.

**Does it use my Claude subscription?**

No. While ANTHROPIC_AUTH_TOKEN is set, requests go to FreeTheAI with your FreeTheAI key and do not count against a claude.ai plan.

Checked: Tested end to end with Claude Code 2.1.284 on 2026-09-29 (reads a file with its Read tool on three FreeTheAI models).
