Get your API key

Terminal coding agent · setup guide

Connect Claude Code to AllModelAPI

A coding agent that runs in your terminal. It reads your project, writes code and runs commands. You can point it at AllModelAPI models such as DeepSeek V4 Pro or Kimi K3.1.

About 10 minutesWindows · macOS · LinuxUses the Messages APIChecked 19 November 2026
1 · Your computer
Stays in this browser tab. It is never saved or sent anywhere. No key yet? Create one.

Pick the easy way

Easiest

Let an AI agent do it

Already use an AI coding agent (any one: Codex, OpenCode, Cursor, another assistant)? Copy this prompt, paste it into that agent and press Enter. It installs Claude Code, writes the settings, saves your key and tests everything. It will ask you for your API key.

See what the prompt says
# Task: connect Claude Code to AllModelAPI

You are a coding agent on my computer. Set up **Claude Code** so it uses **AllModelAPI** as its model provider. Work step by step, tell me briefly what you are doing, and ask me before doing anything not listed here.

## Facts
- Service: AllModelAPI, an API gateway for DeepSeek, Qwen, GLM, Kimi and MiniMax models.
- Claude Code talks to it with the Messages API.
- Base URL: `https://api.allmodelapi.com` (no /v1: the tool adds /v1/messages itself)
- Main model: `deepseek-v4-pro` (DeepSeek V4 Pro, 1000K context). Fast background model: `deepseek-flash`.
- Model IDs are case-sensitive. Full list: https://api.allmodelapi.com/v1/models
- API key: not included. **Ask me to paste my AllModelAPI API key** (I can create one at https://allmodelapi.com/customer/api-keys).
- Human guide: https://allmodelapi.com/documentation/claude-code

## Steps
1. Detect my operating system (macOS, Linux or Windows) and shell.
2. Check whether Claude Code is installed: `claude --version`. If it is not, install it with the official command:
   - macOS: `curl -fsSL https://claude.ai/install.sh | bash`
   - Linux: `curl -fsSL https://claude.ai/install.sh | bash`
   - Windows (PowerShell): `irm https://claude.ai/install.ps1 | iex`
3. Settings file location:
   - macOS / Linux: `~/.claude/settings.json`
   - Windows: `%USERPROFILE%\.claude\settings.json`
4. If the file exists, copy it to `<file>.bak` first. If it contains other settings, **merge**: keep everything unrelated and only add or replace the keys shown below. If it does not exist, create it with exactly this content (replace PASTE_YOUR_ALLMODELAPI_KEY_HERE with my key):

```json
{
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.allmodelapi.com",
    "ANTHROPIC_AUTH_TOKEN": "PASTE_YOUR_ALLMODELAPI_KEY_HERE",
    "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",
    "CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-v4-pro",
    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "750000",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```
5. API key: Put the key in the settings file as the value of ANTHROPIC_AUTH_TOKEN.
6. Verify. Run:
```
claude --version
claude doctor
claude -p "Reply with just: OK"
```
   A short reply such as "OK" means it works. On 401 re-check the key; on 400 "unknown model" re-check the model ID; on 402 I need more credit.
7. Report: what you changed, where the backup is, and how I start Claude Code.

## Rules
- Only touch the files named above. Do not remove other providers, models or settings.
- Never print my full API key in your replies or logs, and never put it in a git repository or project file.
- Use JSON that parses: no comments in JSON, no trailing commas.
One paste

Do it in your terminal

Install Claude Code (step 3 below), then paste this one command into PowerShell. It backs up your old settings and writes the complete new file.

Or edit the file yourself: open %USERPROFILE%\.claude\settings.json, delete everything inside, paste the full file, and save.

No key pasted above, so copied text contains PASTE_YOUR_ALLMODELAPI_KEY_HERE. Paste your key at the top first, or replace that text later.

Step by step, for Windows

Never used a terminal before? That's fine. Follow each step in order. Every grey “Why?” box explains what you just did.

  1. Get your AllModelAPI API key

    Sign in, open API Keys and create a key. Copy it and keep it private: anyone with the key can spend your credit. You will see it only once.

    Why? An API key is like a password for apps. It lets a tool use AI models on your account, and your usage is billed to it.

    Create your key here: https://allmodelapi.com/customer/api-keys

  2. Open a terminal

    Press the Windows key, type PowerShell and press Enter. A blue or black window opens. That is your terminal. Use PowerShell, not Command Prompt.

    Why? A terminal is a window where you type commands instead of clicking buttons. Every command on this page is pasted there.

    To paste in a terminal: Ctrl + V in PowerShell, Cmd + V on Mac, Ctrl + Shift + V on Linux. Then press Enter.

  3. Install Claude Code

    Paste this command and press Enter. Wait until it finishes. Then close the terminal and open a new one so it can find Claude Code.

    Why? This downloads the tool from its official website and adds it to your computer.

    Install (PowerShell)
    irm https://claude.ai/install.ps1 | iex
    Check it installed: this should print a version number
    claude --version

    Already installed? Skip to the next step.

  4. Your key goes inside the settings file

    Paste your key in the box at the top of this page before copying, or replace PASTE_YOUR_ALLMODELAPI_KEY_HERE in the file after saving it.

    Why? This tool reads ANTHROPIC_AUTH_TOKEN from its own settings file, which lives in your user folder, not in your projects.

  5. Save the Claude Code settings file

    Paste this one command and press Enter. It creates the folder if needed, keeps a backup of any old file (.bak), and writes the complete settings file. Prefer doing it by hand? Use "Copy full config file" at the top, open the file in a text editor, select everything, paste, and save.

    Why? Claude Code reads its settings from %USERPROFILE%\.claude\settings.json. This file tells it to send requests to AllModelAPI and which model to use.

    Write the settings file
    $file = Join-Path $HOME ".claude\settings.json"
    New-Item -ItemType Directory -Force -Path (Join-Path $HOME ".claude") | Out-Null
    if (Test-Path $file) { Copy-Item $file "$file.bak" -Force; Write-Host "Backup saved: $file.bak" }
    [System.IO.File]::WriteAllText($file, @'
    {
      "$schema": "https://json.schemastore.org/claude-code-settings.json",
      "env": {
        "ANTHROPIC_BASE_URL": "https://api.allmodelapi.com",
        "ANTHROPIC_AUTH_TOKEN": "PASTE_YOUR_ALLMODELAPI_KEY_HERE",
        "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",
        "CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-v4-pro",
        "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "750000",
        "API_TIMEOUT_MS": "3000000",
        "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1",
        "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
      }
    }
    '@)
    Write-Host "Saved: $file"

    Your old file had other settings you care about? Use the agent prompt instead. It merges instead of replacing.

  6. The model picker will look empty. That is normal.

    Your model is set by the settings file, so you don't need the picker. To switch models, change ANTHROPIC_MODEL in the file (or choose another model at the top of this page and copy again), then restart the tool.

    Why? The built-in /model menu only lists the maker's own model names.

  7. Check that it works

    You should see a short reply such as OK. If you see an error instead, look it up in "Something went wrong?" below.

    Why? This sends one tiny request, so you know the key, the address and the model are all correct before you start a real project.

    Check the install
    claude --version
    claude doctor
    Ask one question without opening the app
    claude -p "Reply with just: OK"
    Test your key directly (PowerShell)
    Invoke-RestMethod -Method Post -Uri "https://api.allmodelapi.com/v1/chat/completions" `
      -Headers @{ Authorization = "Bearer $env:ALLMODELAPI_API_KEY" } `
      -ContentType "application/json" `
      -Body '{"model":"deepseek-v4-pro","max_tokens":20,"messages":[{"role":"user","content":"Reply with just: OK"}]}'
  8. Start building

    Open a terminal in your project folder and type claude. Inside, type /status: the base URL line should show api.allmodelapi.com.

The complete settings file

This is the whole file. Every line matters, so copy it with the button instead of selecting it by hand.

%USERPROFILE%\.claude\settings.json
{
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.allmodelapi.com",
    "ANTHROPIC_AUTH_TOKEN": "PASTE_YOUR_ALLMODELAPI_KEY_HERE",
    "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",
    "CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-v4-pro",
    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "750000",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}

Something went wrong?

It asks me to log in

Choose to use an API key or press Esc. If it still asks, run /logout inside the tool, close it and start again. Make sure the settings file was saved in your user folder (see the path above).

"Do you want to use this API key?"

Choose Yes.

400 Extra inputs are not permitted

Keep CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS set to "1" in the file, as shown.

Settings Error when it starts

The JSON file is broken, usually a missing comma or quote. Copy the full file from this page again and replace everything.

Empty or malformed response (HTTP 200)

ANTHROPIC_BASE_URL must be exactly https://api.allmodelapi.com, without /v1 at the end.

401 / invalid API key

The key is missing, mistyped or revoked. Copy it again from https://allmodelapi.com/customer/api-keys and save it again. Keys start with the same prefix you see in your dashboard.

402 / insufficient credit

Your plan credit and pay-as-you-go credit are used up for this request. Add credit or pick a coding plan in Billing, or choose a cheaper model.

400 / unknown model

Model IDs are case-sensitive and must match the AllModelAPI list exactly, for example MiniMax-M3.1-Flash, not minimax-m3.1-flash.

command not found / is not recognized

The tool is not installed, or your terminal was opened before the install finished. Close the terminal, open a new one and try again.

Still stuck? Copy the agent prompt above into any AI assistant and paste the exact error message after it, or write to support@allmodelapi.com. See all models and IDs in the model list.