Connecting Cursor / Claude Code / Cherry Studio to a Custom AI Gateway
Mainstream AI tools all support custom APIs — which means you can point them at your own gateway (e.g. 4-4 AI) and use one key and one billing account everywhere. This guide covers the three most-used tools plus a universal troubleshooting approach.
https://www.4-4.vip/v1) as the example — any OpenAI-compatible gateway works the same way.Cursor
Cursor's chat models can run over a custom OpenAI-compatible endpoint:
- Open
Settings → Models; - Expand the
OpenAI API Keysection and enter your gateway key (sk-...); - Fill in
Override OpenAI Base URL:https://www.4-4.vip/v1; - Add the model names available on your gateway (exactly matching the gateway-side names, case-sensitive);
- Click Verify; once it passes, pick your custom model in the chat panel.
Note: Cursor's built-in Tab completion and parts of Composer run on Cursor's own service and are unaffected; custom models mainly apply to Chat.
Claude Code
Claude Code speaks the Anthropic protocol. The prerequisite is that your gateway supports the Anthropic endpoint (/v1/messages) — gateways in the new-api ecosystem (including 4-4 AI) support protocol conversion, routing Anthropic-format requests to whatever model channel you configured.
Configure via environment variables (in the terminal where you launch claude):
export ANTHROPIC_BASE_URL="https://www.4-4.vip"
export ANTHROPIC_AUTH_TOKEN="sk-your-gateway-key"
# launch
claude
Windows PowerShell equivalent:
$env:ANTHROPIC_BASE_URL = "https://www.4-4.vip"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-gateway-key"
Cherry Studio
Cherry Studio supports custom OpenAI-compatible providers directly:
Settings → Model Providers: add or select an OpenAI-compatible provider;- API address:
https://www.4-4.vip/v1(some versions auto-append /v1 — don't duplicate it); - API key: your gateway key;
- Add available model names in model management, save, and select them in chat.
The universal pattern: any OpenAI-compatible tool
Plenty of tools (LobeChat, Open WebUI, immersive-translate, various IDE plugins) follow the same three-part pattern:
| Setting | Value | Common pitfall |
|---|---|---|
| Base URL | https://www.4-4.vip/v1 | some tools want /v1, some don't — on a 404, toggle /v1 first |
| API Key | gateway key (sk-...) | copied whitespace, expired key, exhausted quota |
| Model name | the gateway channel's name | must match the gateway exactly — presets with non-existent names fail |
Troubleshooting cheat sheet
401 Unauthorized
- whitespace/newline copied with the key → re-copy;
- key disabled or out of quota → check the Tokens page in the console;
- malformed Authorization header → must be
Bearer sk-....
404 Not Found
- wrong Base URL path → toggle "with /v1" vs "without /v1";
- gateway doesn't support the protocol endpoint the tool requests → confirm OpenAI /v1/chat/completions or Anthropic /v1/messages support.
400 Model Not Found / no available channel
- model name mismatch → verify exact names on the console Models/Channels page;
- channel disabled or your group lacks permission → check the token's model scope and group settings.
Streaming cuts off / no response
- corporate proxy buffering SSE → test on a direct connection;
- tool timeout too short → raise it; for long outputs also confirm no gateway-side forced timeout.
FAQ
Is my data safe through a gateway?
Your requests transit the gateway to the upstream channel. Check the platform's logging and privacy policy; for sensitive data, disable conversation log storage on the gateway or pick channels with no-data-retention.
Can one tool connect to multiple gateways?
Most tools support multiple providers with instant switching (Cherry Studio, Cursor, etc.). Give each tool its own token — that also separates usage stats and quota caps.
Why route tools through one gateway instead of direct vendor connections?
Three reasons: centralized key management (smaller leak surface), unified billing and usage visibility (no multi-platform reconciliation), and vendor decoupling (switching models is a gateway config change, not a rewrite).
Related articles
One key for GLM, DeepSeek, Qwen and more — unified billing and usage analytics.
View models & pricing Get started