Claude Code sends every request in the Anthropic Messages API format, to /v1/messages on whatever ANTHROPIC_BASE_URL points at. Most open-model providers, BroadNet Inference included, speak the OpenAI format instead. So you need either a proxy that translates between the two, or a provider that publishes its own Anthropic-format endpoint. This post covers both, plus the limits that decide whether it is worth doing.
Why can’t Claude Code call an OpenAI-compatible API directly?
Claude Code’s gateway compatibility guide lists the formats a gateway must expose. For a plain base URL, that is Anthropic Messages: /v1/messages, with /v1/messages/count_tokens optional, and the anthropic-beta and anthropic-version headers forwarded. An OpenAI-compatible API serves /v1/chat/completions with a different request and response shape. Point Claude Code straight at one and the requests fail.
One more thing to know before you start. Claude Code’s own docs say Anthropic “doesn’t support routing Claude Code to non-Claude models through any gateway.” Many people do it anyway, but nobody at Anthropic will debug it for you.
What are your three options?
| Route | How it works | Best for | Trade-off |
|---|---|---|---|
| Translating proxy (LiteLLM) | Claude Code talks Anthropic format to a local proxy; the proxy calls the OpenAI-compatible provider | Using a specific OpenAI-compatible provider, such as BroadNet | One more process to run and update; translation gaps |
| Native Anthropic-format endpoint | The provider accepts /v1/messages itself |
DeepSeek or GLM models from their makers | Each maps or ignores some fields |
| A different agent | Use an agent that takes an OpenAI-compatible base URL | Anyone who doesn’t need Claude Code specifically | You give up Claude Code’s interface and features |
How do you run Claude Code through LiteLLM?
LiteLLM’s tutorial for non-Anthropic models works like this: install the proxy, define models in config.yaml, start it, then set two variables in Claude Code. LiteLLM translates between formats, so Claude Code keeps sending Anthropic requests.
Define the BroadNet models the same way as in the LiteLLM guide, with the openai/ prefix and api_base:
model_list:
- model_name: glm
litellm_params:
model: openai/broadnet/glm-5.3
api_base: https://inference.broadnet.ai/v1
api_key: os.environ/BROADNET_API_KEY
rpm: 30
- model_name: qwen
litellm_params:
model: openai/broadnet/qwen3.8-27b
api_base: https://inference.broadnet.ai/v1
api_key: os.environ/BROADNET_API_KEY
rpm: 30
general_settings:
master_key: os.environ/LITELLM_MASTER_KEY
Start the proxy:
uv tool install 'litellm[proxy]'
export BROADNET_API_KEY='your-broadnet-key'
export LITELLM_MASTER_KEY='sk-any-local-secret'
litellm --config config.yaml # listens on http://0.0.0.0:4000
Then point Claude Code at it. ANTHROPIC_AUTH_TOKEN goes out as an Authorization: Bearer header, which is what LiteLLM reads:
export ANTHROPIC_BASE_URL=http://0.0.0.0:4000
export ANTHROPIC_AUTH_TOKEN="$LITELLM_MASTER_KEY"
export ANTHROPIC_MODEL=glm # main model
export ANTHROPIC_DEFAULT_HAIKU_MODEL=qwen # background tasks
export ANTHROPIC_DEFAULT_SONNET_MODEL=glm # the sonnet alias
export ANTHROPIC_DEFAULT_OPUS_MODEL=glm # the opus alias
export CLAUDE_CODE_SUBAGENT_MODEL=glm # subagents
claude
Run /status in Claude Code. The Anthropic base URL line should show the proxy address.
The model variables matter. LiteLLM’s Claude Code page warns that picking a built-in Claude name that your config doesn’t define fails with “Invalid model name passed in”. Claude Code’s env-vars reference says ANTHROPIC_DEFAULT_HAIKU_MODEL is also used for background functionality, so map it too, or background requests ask for a Haiku name the proxy doesn’t know. CLAUDE_CODE_SUBAGENT_MODEL sets the default model for subagents, but a model Claude passes when it spawns one, often an alias such as sonnet or haiku, takes precedence. Mapping the sonnet and opus aliases as well means those requests still resolve to a model the proxy knows. Keep your BroadNet key in the proxy’s environment, never in a project’s committed .claude/settings.json.
Which DeepSeek and GLM endpoints work without a proxy?
Two model makers publish Anthropic-format base URLs:
| Provider | Base URL | Model handling (from their docs, checked 2026-11-15) |
|---|---|---|
| DeepSeek | https://api.deepseek.com/anthropic |
claude-sonnet* and claude-haiku* names map to deepseek-flash; claude-opus* maps to deepseek-v4-pro; names not starting with claude return 400 |
| Z.ai (GLM Coding Plan) | https://api.z.ai/api/anthropic |
Key in ANTHROPIC_AUTH_TOKEN; the manual example maps Opus and Sonnet to glm-5.3[1m] and Haiku to glm-5.3-flash[1m] |
DeepSeek’s release note of 10 September 2026 says deepseek-flash serves DeepSeek-V4.1-Flash. Its Anthropic API page also lists what it ignores: cache_control, budget_tokens, disable_parallel_tool_use and the anthropic-version header, among others. On deepseek-flash, images in assistant messages return 400, and deepseek-v4-pro replaces images with “[Unsupported Image]”.
If you only want DeepSeek or GLM in Claude Code, these native endpoints are the shortest path. Prices and plan limits for both are compared in the Claude API alternatives page.
What breaks or changes on a non-Claude model?
Translation keeps requests flowing, but several Claude Code features depend on things a proxy or another model may not pass through. Claude Code’s docs name these:
- Prompt caching. Claude Code marks
systemand message blocks withcache_control. If the gateway or upstream drops it, there is no error, but every turn bills as uncached input. On an OpenAI-compatible upstream, caching follows that provider’s own rules instead. BroadNet bills cached input at a lower price when its usage block reports a cache hit; checkcached_tokensin your logs. - Token counting. Without
/v1/messages/count_tokens, Claude Code falls back to a character-based estimate, so/contextis approximate. - Context window. Claude Code applies its own default window to model names it doesn’t recognise. Set
CLAUDE_CODE_AUTO_COMPACT_WINDOW(100,000 to 1,000,000 tokens) to fit the model. For Qwen3.8 27B, with a 262,144-token context, set it well below that. - Unknown fields. A
400namingExtra inputs are not permittedor ananthropic-betavalue means something upstream rejected a pre-release field. The docs suggestCLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1. - Thinking.
MAX_THINKING_TOKENSand adaptive thinking are Claude features. On BroadNet, DeepSeek V4.1 Flash, GLM 5.3 and Qwen3.8 27B reason before they answer, and those reasoning tokens count towardmax_tokens. If answers come back empty, raise the output limit or sendreasoning_effortlow. See why reasoning models return empty answers. - Images. GLM 5.3 is text-only on BroadNet. Use Qwen3.8 27B if you paste screenshots.
Test a real task end to end, with file edits, shell commands and a long session, before you rely on it.
Which BroadNet model should sit behind Claude Code?
Claude Code reads files, edits them and runs commands through tool calls. BroadNet’s API reference documents tools, structured output and reasoning for two models:
| Model | Input / output per 1M tokens | Context | Images | Tools documented |
|---|---|---|---|---|
| GLM 5.3 | $0.78 / $3.46 | 1,048,576 | No | Yes |
| Qwen3.8 27B | $0.175 / $2.17 | 262,144 | Yes | Yes |
| DeepSeek V4.1 Flash | $0.175 / $0.52 | 1,048,576 | Yes | Not documented |
GLM 5.3 is the natural main model for large repositories. Qwen3.8 27B costs less per input token and works for images and lighter background calls. Both need a top-up; they are not covered by the $5 starting credit. The GLM 5.3 vs Qwen3.8 27B comparison has the side-by-side.
Can you use BroadNet’s flat-rate plan with Claude Code?
Not as a documented fit, and it’s better to know that before buying. The Full Moon, Orbit and Meteor plans cover DeepSeek V4.1 Flash only, and BroadNet does not document tool calling for it. Each plan session also runs one request at a time. Claude Code can run subagents and background tasks alongside the main loop, and those requests would queue on one session.
If a flat price is what you want, use an agent that BroadNet documents with the plan, such as Aider. For Claude Code, use pay-as-you-go GLM 5.3 or Qwen3.8 27B, which allow 30 requests a minute and 4 in flight per key. Back off on 429 as in errors and retries.
When is a different agent the better choice?
If you don’t need Claude Code itself, skip the proxy. opencode, Cline, Roo Code, Continue and Aider all take an OpenAI-compatible base URL, a key and a model ID directly. The field names for each are in use open models in coding agents, with setup guides for opencode and Cline. Fewer moving parts means fewer translation bugs. To compare models for this work, see best open model for coding agents.
Stay on Claude models if your work depends on Claude-specific features such as extended thinking, Anthropic prompt caching or the newest Claude Code betas. In that case, cut costs inside Claude Code rather than swapping the model.
Where BroadNet Inference fits
BroadNet Inference is an OpenAI-compatible API, so it reaches Claude Code only through a proxy such as LiteLLM. Behind one, GLM 5.3 and Qwen3.8 27B are the two models with documented tool calling, billed per token with no content retained after the request. If you want a native Anthropic-format endpoint, DeepSeek and Z.ai are simpler. If you want BroadNet’s flat plan, pair it with an agent that speaks the OpenAI format.
