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.