Claude Code Config Generator: Custom API Endpoint Setup for Codex CLI, Cline, Cursor and More
Pick your tool, operating system and model ID, and copy the generated config below. Two rules cover almost every setup: Anthropic-protocol tools such as Claude Code useANTHROPIC_BASE_URL=https://www.ccsub.net(no /v1 at the end) with your key in ANTHROPIC_AUTH_TOKEN; OpenAI-compatible tools such as Codex CLI, Cline and Cursor usehttps://www.ccsub.net/api/v1.
Replace sk-your-key below with a key from the API Keys page in your CCSub dashboard.
No key yet? Sign upYour config · Claude Code · macOS / Linux (zsh)
Option 1: add environment variables to ~/.zshrc
echo 'export ANTHROPIC_BASE_URL="https://www.ccsub.net"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="sk-your-key"' >> ~/.zshrc
echo 'export ANTHROPIC_MODEL="claude-sonnet-5"' >> ~/.zshrc
source ~/.zshrc- Run these once — running them again appends duplicate lines. Every new terminal picks the variables up automatically.
Option 2: put it in ~/.claude/settings.json (applies to every project)
{
"env": {
"ANTHROPIC_BASE_URL": "https://www.ccsub.net",
"ANTHROPIC_AUTH_TOKEN": "sk-your-key"
},
"model": "claude-sonnet-5"
}- If the file already exists, merge the two env entries and model into it instead of replacing the whole file. settings.json is strict JSON: no comments and no trailing commas.
- Values in the env block override variables of the same name exported in your shell — check this file first if a shell change seems to be ignored.
Start and verify
- Send any message — getting a reply means you're connected.
- Open Usage in the CCSub dashboard to see the request's model, token counts and cost.
cd ~/your-project
claudeTwo base URLs: match the tool's protocol first
CCSub exposes an Anthropic-compatible API and an OpenAI-compatible API, and the same key works for both. A wrong base URL is the most common reason a setup fails, and the rule behind it is simple: the client appends the API path itself, so you only enter the part it expects.
| Protocol | Base URL to enter | Typical tools | Path the client appends |
|---|---|---|---|
| Anthropic Messages | https://www.ccsub.net | Claude Code, cc-switch (Claude Code), Cline's Anthropic provider | /v1/messages |
| OpenAI-compatible | https://www.ccsub.net/api/v1 | Codex CLI, Cline, Cursor, cc-switch (Codex) | /responses, /chat/completions, /models |
| OpenAI-compatible (Cherry Studio) | https://www.ccsub.net | Cherry Studio's OpenAI endpoint | /v1/chat/completions |
https://www.ccsub.net/v1 and https://www.ccsub.net/api/v1 reach the same OpenAI-compatible API; the docs use /api/v1. With the bare domain, chat requests still work, but /models lands on the website's models page, so any tool that fetches a model list gets an HTML page back.
What each setting means
| Setting | Where | Meaning and gotchas |
|---|---|---|
ANTHROPIC_BASE_URL | Claude Code | Where requests are sent — just the domain. Per Claude Code's docs, when this points to a non-Anthropic host all MCP tools are loaded up front, so sessions with many MCP servers send noticeably more input tokens per request. |
ANTHROPIC_AUTH_TOKEN | Claude Code | Your CCSub key, sent as Authorization: Bearer. |
ANTHROPIC_API_KEY | Claude Code | Alternative sent as X-Api-Key; CCSub accepts both. When it is set, interactive Claude Code asks you to approve the key once, which is why the docs use AUTH_TOKEN. |
ANTHROPIC_MODEL / model | Claude Code | Default model ID. --model and /model win, then ANTHROPIC_MODEL, then the model key in settings.json. |
env | ~/.claude/settings.json | Environment variables injected into every session; they override variables of the same name exported in your shell. |
model / model_provider | Codex config.toml | Default model ID and which provider to use (the [model_providers.ccsub] table below it). |
base_url | Codex config.toml | Provider endpoint: https://www.ccsub.net/api/v1. Codex appends /responses. |
env_key | Codex config.toml | Name of the environment variable that holds the key — not the key itself. |
wire_api | Codex config.toml | Protocol. Codex's config reference lists responses as the only supported value, and it is the default. |
| Base URL / Model ID | Cline | Fields shown after choosing the OpenAI Compatible provider; Model ID accepts any model ID you type. |
| Override OpenAI Base URL | Cursor | Toggle under Cursor Settings → Models → API Keys; once on, it applies to every model that isn't Claude or Gemini. |
| API address | Cherry Studio | Enter the root URL; Cherry Studio appends /v1/chat/completions. A URL ending in # is used exactly as written. |
Common mistakes
ANTHROPIC_BASE_URL ends with /v1
Claude Code adds /v1/messages on its own, so a base URL ending in /v1 becomes /v1/v1/messages and fails with 404 or never connects. Use https://www.ccsub.net with no trailing slash.
The OpenAI-compatible URL is just the domain, or is missing /api
Codex printing unexpected status 404 Not Found: <!DOCTYPE html>, or another tool saying the model list is empty or the response can't be parsed, usually means the request hit a website page. Change the URL to https://www.ccsub.net/api/v1.
Changed an environment variable but the tool still uses the old endpoint
Open terminals don't reload variables. On macOS / Linux run source ~/.zshrc or open a new terminal; on Windows, close every terminal window after SetEnvironmentVariable, and restart VS Code entirely if you use its terminal. Still stuck? Check ~/.claude/settings.json — its env block overrides your shell.
Edits to config.toml are ignored
Either the settings went into a project's .codex/config.toml (Codex does not read model_provider or model_providers there), or model = ... was appended under an existing [table] header and became part of that table. Top-level keys must come before every table header.
401 Unauthorized / invalid_api_key
The key picked up a stray space, quote or line break, or the placeholder was never replaced. It can also mean the tool is still pointed at the official API, which naturally rejects a CCSub key.
Custom models starting with claude- fail in Cursor
Cursor decides which key to send from the start of the model name; claude- names use the Anthropic key slot and skip the OpenAI base URL override. Use a GPT model ID in Cursor instead.
“Connection error”, ECONNREFUSED or ETIMEDOUT in the terminal
These have nothing to do with how the config is written — they point to the network or a terminal proxy. Run the connectivity check to see whether your browser can reach the API, then repeat the test from your terminal with the curl commands on that page.
FAQ
Do I need an account to use the config generator? Does it collect my key?
No account is needed. The page only assembles text in your browser and always uses the placeholder sk-your-key, which you replace locally after copying. There is no field for entering a key and nothing is uploaded.
Why must ANTHROPIC_BASE_URL not end with /v1?
Claude Code appends /v1/messages to the base URL itself. With https://www.ccsub.net it calls https://www.ccsub.net/v1/messages; with https://www.ccsub.net/v1 it would call /v1/v1/messages and get a 404.
Should the OpenAI-compatible base URL be /api/v1 or /v1?
The CCSub docs use https://www.ccsub.net/api/v1. https://www.ccsub.net/v1 points to the same API (cc-switch's built-in CCSub preset uses it), so either works. Don't use the bare domain: some tools fetch https://www.ccsub.net/models for the model list, which is a website page and returns HTML instead of JSON.
Environment variables or ~/.claude/settings.json — which should I use?
Either one. Environment variables apply to anything launched from your shell; settings.json is read by Claude Code no matter how it starts, including from an editor extension. If both define the same variable, the settings.json env value wins.
Why does the model dropdown only show some model IDs?
It is filtered by protocol: Claude Code lists Claude model IDs, Codex CLI lists GPT model IDs, and Cursor lists GPT model IDs only, because Cursor sends any model name starting with claude- to its Anthropic key slot rather than the OpenAI override. The full list with prices is on the models page.
Can I commit the generated config to a shared repository?
Never commit a file that contains a real key. A project's .claude/settings.json is shared with everyone who clones the repo, so keep the key in your personal ~/.claude/settings.json or in environment variables. Codex provider settings only work in the user-level ~/.codex/config.toml anyway.
How do I confirm requests are really going through CCSub?
Send one message, then open Usage in the CCSub dashboard. If you see the request with its model, token counts (input, output, cache) and cost, the setup works. If nothing shows up, the tool is still using another endpoint or stale environment variables.
Related pages
Need a key? Create a CCSub account
After signing up, create a key on the API Keys page and swap it in for sk-your-key in the config above. Balance is credited at ¥1 = $1 and charged by actual usage.