Model Proxy

Claude Code gateway setup

Claude Code documents an LLM gateway pattern where ANTHROPIC_BASE_URL points at the gateway endpoint. Use a generated Model Proxy access scope key as the API key value and keep upstream provider keys encrypted server-side or supplied per request.

export ANTHROPIC_BASE_URL="https://modelproxy.space/anthropic"
export ANTHROPIC_AUTH_TOKEN="$MODEL_PROXY_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"
}

Access scope key

A production access scope key should carry a project, endpoint allowlist, model allowlist, RPM, TPM, monthly budget, and retention level. A leaked scope 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.

Current references