Claude Code gateway setup
Claude Code documents an LLM gateway pattern where ANTHROPIC_BASE_URL points at the gateway endpoint. Use a Model Proxy virtual key as the API key value and keep the upstream provider key in the gateway deployment.
export ANTHROPIC_BASE_URL="https://modelproxy.space/anthropic"
export ANTHROPIC_AUTH_TOKEN="sk-mp_project_virtual_key"
OpenAI-compatible client setup
For OpenAI-compatible clients, keep the messages shape and change the base URL plus API key. The gateway resolves the requested model alias to the upstream model configured in the routing profile.
import OpenAI from "openai"
const client = new OpenAI({
apiKey: process.env.MODEL_PROXY_KEY,
baseURL: "https://modelproxy.space/proxy/v1"
})
const result = await client.chat.completions.create({
model: "research-fast",
messages: [{ role: "user", content: "Summarize this incident." }]
})
Route profile shape
{
"alias": "claude-sonnet",
"provider": "deepseek-primary",
"upstreamModel": "deepseek-chat",
"fallbackProvider": "kimi-backup",
"policy": "cost_first_then_fallback",
"budgetAction": "block_when_price_unknown"
}
Virtual key scope
A production virtual key should carry a project, endpoint allowlist, model allowlist, RPM, TPM, monthly budget, and retention level. A leaked virtual key should be revocable without rotating every upstream provider credential.
Search bridge provenance
When a client asks for web search and the upstream model does not provide native search, Model Proxy can call a search provider and return results as a tool response or context block. The monitor should show search provider, source URLs, result count, cache status, and separate cost.