Connect your coding agent
Claude Code, Codex, Cursor, Gemini CLI and OpenCode reach this gateway by changing one address. This page gives the exact configuration per tool, the published conformance specification we implement, and each tool's known boundaries.
Claude Code
Point Claude Code at the gateway with ANTHROPIC_BASE_URL and authenticate with ANTHROPIC_AUTH_TOKEN, which is this gateway's sk- key. Leave ANTHROPIC_API_KEY unset, or the client may fall back to Anthropic's own authentication.
This gateway implements Anthropic's published gateway compatibility guide: anthropic-version and anthropic-beta are forwarded verbatim and treated as an open list, so a capability introduced by a newer client release is not stripped; upstream errors retain protocol structure with sensitive credentials filtered, and a cross-protocol route carries the capability_rejected: token that keeps the client's automatic recovery working; the system array and the cache_control markers inside it are forwarded unchanged, prompt caching still depends on model support; streams are relayed as they arrive and a keep-alive is emitted during upstream silence, reducing the risk of the client's 300-second watchdog timing out.
export ANTHROPIC_BASE_URL="https://www.link42.ai/anthropic"
export ANTHROPIC_AUTH_TOKEN="sk-..."
unset ANTHROPIC_API_KEY
# Copy an available text model id from GET /v1/models
export ANTHROPIC_MODEL="YOUR_TEXT_MODEL_ID"set ANTHROPIC_BASE_URL=https://www.link42.ai/anthropic
set ANTHROPIC_AUTH_TOKEN=sk-...
set ANTHROPIC_API_KEY=
set ANTHROPIC_MODEL=YOUR_TEXT_MODEL_ID
claude$env:ANTHROPIC_BASE_URL = "https://www.link42.ai/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = "sk-..."
Remove-Item Env:ANTHROPIC_API_KEY -ErrorAction SilentlyContinue
$env:ANTHROPIC_MODEL = "YOUR_TEXT_MODEL_ID"
claudeModel discovery in Claude Code
With CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1, Claude Code requests GET /v1/models and adds the result to its /model picker. It keeps only entries whose id contains claude or anthropic; that filter belongs to the client.
So Claude models your operator serves appear in the picker on their own, while the rest of this catalogue — DeepSeek, GLM, Seedance and the others — is callable over the Anthropic protocol but will not appear there, and is selected with ANTHROPIC_MODEL or /model instead. We do not rename a model to get it past that filter.
Codex
Codex speaks only the OpenAI protocol, and current configurations use the Responses API. Define a model_providers block in config.toml pointing at this gateway and select it with model_provider.
model_provider = "link42"
model = "YOUR_TEXT_MODEL_ID"
[model_providers.link42]
name = "LINK42"
base_url = "https://www.link42.ai/v1"
env_key = "LINK42_API_KEY"
wire_api = "responses"Cursor and other OpenAI-compatible tools
Any OpenAI-compatible client that lets you set a base URL reaches the gateway at https://www.link42.ai/v1 with an sk- key. Both /v1/chat/completions and /v1/responses are served, so either wire protocol works.
Gemini CLI
Gemini CLI speaks the Gemini protocol: point GOOGLE_GEMINI_BASE_URL at the gateway's Gemini address, put this gateway's sk- key in GEMINI_API_KEY, and choose "Use Gemini API key" on first launch (signing in with a Google account bypasses the custom address). Pick the model with -m or GEMINI_MODEL, using an exact id from GET /v1/models.
Gemini CLI requires HTTPS for any address other than localhost; this gateway's address qualifies.
export GOOGLE_GEMINI_BASE_URL="https://www.link42.ai/gemini"
export GEMINI_API_KEY="sk-..."
export GEMINI_MODEL="YOUR_TEXT_MODEL_ID"
geminiset GOOGLE_GEMINI_BASE_URL=https://www.link42.ai/gemini
set GEMINI_API_KEY=sk-...
set GEMINI_MODEL=YOUR_TEXT_MODEL_ID
gemini$env:GOOGLE_GEMINI_BASE_URL = "https://www.link42.ai/gemini"
$env:GEMINI_API_KEY = "sk-..."
$env:GEMINI_MODEL = "YOUR_TEXT_MODEL_ID"
geminiOpenCode
OpenCode connects through a custom provider: declare one that uses @ai-sdk/openai-compatible in opencode.json at the project root (or globally in ~/.config/opencode/opencode.json), set baseURL to https://www.link42.ai/v1, and read the key from the environment with {env:LINK42_API_KEY} instead of writing it into the file. List the model ids you use under models and pick one with /models.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"link42": {
"npm": "@ai-sdk/openai-compatible",
"name": "LINK42",
"options": {
"baseURL": "https://www.link42.ai/v1",
"apiKey": "{env:LINK42_API_KEY}"
},
"models": {
"YOUR_TEXT_MODEL_ID": { "name": "YOUR_TEXT_MODEL_ID" }
}
}
}
}export LINK42_API_KEY="sk-..."
opencode$env:LINK42_API_KEY = "sk-..."
opencodeCost per session and per subagent
Claude Code sends x-claude-code-session-id on every request, and requests from a subagent carry x-claude-code-agent-id and x-claude-code-parent-agent-id as well. The gateway records all three, so the console can total a session's spend and open it to show what each agent inside it cost — after a fan-out of subagents you can see which one spent the budget.
These identifiers come from the client and are used for attribution only, never as a credential or an identity. A request that arrives without them, such as an ordinary SDK call, is reported as unattributed rather than folded into a session.