> ## Documentation Index
> Fetch the complete documentation index at: https://docs.refillapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Code

> Run Claude Code on DeepSeek, Kimi, GLM or Qwen through RefillAPI.

[Claude Code](https://docs.claude.com/en/docs/claude-code/overview) talks to models through the Anthropic Messages API. RefillAPI serves that API for its text models, so you can point Claude Code at DeepSeek, Kimi, GLM or Qwen with one settings file.

> [!TIP]
>
> On the [API Keys](https://refillapi.com/keys) page, click **Integration config** next to the key and choose Claude Code. It generates this file with your key already filled in, and **Copy for your agent** turns it into instructions for an AI assistant to apply.

## 1. Install Claude Code

> [tab] macOS / Linux
>
> ```bash theme={null}
> curl -fsSL https://claude.ai/install.sh | bash
> ```

> [tab] Windows
>
> ```powershell theme={null}
> irm https://claude.ai/install.ps1 | iex
> ```

> [tab] npm
>
> ```bash theme={null}
> npm install -g @anthropic-ai/claude-code
> ```

## 2. Configure

Open `~/.claude/settings.json` (Windows: `%USERPROFILE%\.claude\settings.json`), create it if it does not exist, and add the `env` block. Replace `YOUR_API_KEY`, and `deepseek-v4-pro` with the model you want.

```json theme={null}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://refillapi.com",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_MODEL": "deepseek-v4-pro",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-pro",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-flash"
  }
}
```

If the file already has other settings, merge these keys into its `env` instead of replacing the file.

| Setting | Meaning |
| - | - |
| `ANTHROPIC_BASE_URL` | `https://refillapi.com` — **without** `/v1`; Claude Code adds `/v1/messages` |
| `ANTHROPIC_AUTH_TOKEN` | Your RefillAPI key |
| `ANTHROPIC_MODEL` | Main model |
| `ANTHROPIC_DEFAULT_OPUS_MODEL` / `SONNET` / `HAIKU` | Models for Claude Code's tiers and background tasks. Set all three — otherwise Claude Code asks for Claude model names, which RefillAPI does not serve, and those calls fail |

> [!TIP]
>
> Background tasks (titles, summaries) run often, so a cheaper model such as `deepseek-flash` works well for `ANTHROPIC_DEFAULT_HAIKU_MODEL`.

## 3. Verify

Open a new terminal and run:

```bash theme={null}
claude -p "Reply with OK"
```

An `OK` means it works. Each call appears in [Usage Logs](https://refillapi.com/usage-logs/common).

## Troubleshooting

> [accordion] model\_not\_found
>
> One of `ANTHROPIC_MODEL` or the three `DEFAULT_*_MODEL` settings is missing or not an exact RefillAPI model ID. A trailing space also causes this.

> [accordion] 404 or invalid URL
>
> `ANTHROPIC_BASE_URL` must be `https://refillapi.com` — no `/v1`, no `/v1/messages`.

> [accordion] Claude Code still asks me to log in
>
> The settings were not loaded. Check that the keys are inside `env`, that the file is valid JSON (`python3 -m json.tool ~/.claude/settings.json`), and restart the terminal.

> [accordion] 401 or 403
>
> The key is wrong, disabled, expired or out of quota, or your wallet is empty. See [API keys](https://docs.refillapi.com/account/api-keys.md) and [Errors](https://docs.refillapi.com/errors.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.