Configure Claude Code, Cursor & Cline with Custom LLM APIs
Why Most Custom API Setups Fail: Protocol Mismatch Explained
Over 90% of 400 and 404 errors when wiring coding tools into an LLM API gateway come from mixing up OpenAI Chat Completions (/v1/chat/completions) and Anthropic Messages (/v1/messages):
| Client | Native Protocol | Expected Base URL Shape | Recommended Gateways |
|---|---|---|---|
| Claude Code (CLI) | Anthropic /v1/messages | Root URL (often without /v1) | AIKuBot Coding API or native Anthropic-compatible gateways |
| Cursor (AI IDE) | OpenAI Compatible (/v1) | https://your-gateway/v1 | AIKuBot, AISuhui, OpenRouter |
| Cline / Roo Code | Both OpenAI & Anthropic | .../v1 (OpenAI) or root (Anthropic) | AIKuBot, OpenRouter |
| Cherry Studio | OpenAI / Anthropic / Gemini | https://your-gateway/v1 | AISuhui, SiliconFlow, OpenRouter |
Still comparing providers? Read our 2026 Best LLM API Gateways & OpenRouter Alternatives Guide or browse the AI API Relays Directory.
1. Configure Claude Code with a Custom Gateway
Set the Anthropic environment variables in your shell profile (~/.zshrc / ~/.bashrc):
export ANTHROPIC_BASE_URL="https://aikubot.com"
export ANTHROPIC_AUTH_TOKEN="sk-your-gateway-api-key"
On Windows PowerShell:
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://aikubot.com", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "sk-your-gateway-api-key", "User")
Restart your terminal and run claude inside any repository. If you see 404, check your gateway docs for whether /v1 should be appended or omitted.
2. Configure Cursor (Override OpenAI Base URL)
- Open Cursor → Settings → Models.
- Paste your gateway API key into OpenAI API Key.
- Enable Override OpenAI Base URL and enter
https://aikubot.com/v1(orhttps://aisuhui.com/v1/https://openrouter.ai/api/v1). - Click Verify, then enable the exact model IDs supported by your gateway.
3. Configure Cline / Roo Code for Maximum Prompt-Caching Savings
- Open Cline or Roo Code settings in VS Code.
- Select Anthropic (with Custom Base URL enabled) when your gateway supports native
/v1/messagesprompt caching, or OpenAI Compatible for universal models. - Enter your Base URL, API Key, and model ID.
- Keep prompt caching active—on multi-turn repo refactors, cache hits reduce repeated context costs by 50–80%.
4. Configure Cherry Studio for Multi-Model Chat & Local RAG
- Open Cherry Studio → Settings → Model Providers.
- Add an OpenAI-compatible provider (or pick built-in OpenRouter / SiliconFlow).
- Enter your gateway Base URL (
https://aisuhui.com/v1) and API Key, click Check, and click Manage to fetch available models.
Quick Error Troubleshooting
- HTTP 401: Invalid/revoked key, trailing whitespace, or conflicting
ANTHROPIC_API_KEYvs.ANTHROPIC_AUTH_TOKEN. - HTTP 404: Double
/v1/v1path or pasting/chat/completionsinside the Base URL field. - HTTP 429: Insufficient balance or upstream burst limit—switch to an official-tier coding route or add a failover provider in Cloudflare AI Gateway.
Explore more BYOK open-source developer tools in our AI Coding Category.