BroadRouter
Get started

Claude Code with open models: proxies, native endpoints and limits

By the BroadNet Inference team · 6 min read · Published

Claude Code sends Anthropic Messages API requests to ANTHROPIC_BASE_URL. To use an OpenAI-compatible provider, run a translating proxy such as LiteLLM and point Claude Code at it, or pick a provider with its own Anthropic-format endpoint, such as DeepSeek or Z.ai. Anthropic does not support non-Claude models in Claude Code, so test tools, caching and context limits yourself.

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 system and message blocks with cache_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; check cached_tokens in your logs.
  • Token counting. Without /v1/messages/count_tokens, Claude Code falls back to a character-based estimate, so /context is 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 400 naming Extra inputs are not permitted or an anthropic-beta value means something upstream rejected a pre-release field. The docs suggest CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1.
  • Thinking. MAX_THINKING_TOKENS and 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 toward max_tokens. If answers come back empty, raise the output limit or send reasoning_effort low. 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.

Questions

Can Claude Code use DeepSeek?

Yes, in two ways. DeepSeek publishes an Anthropic-format base URL, https://api.deepseek.com/anthropic, that maps claude-sonnet and claude-haiku names to deepseek-flash and claude-opus names to deepseek-v4-pro. Or you put a translating proxy such as LiteLLM in front of any OpenAI-compatible host of DeepSeek models.

Does Claude Code work with an OpenAI-compatible API?

Not directly. Claude Code sends Anthropic Messages API requests to /v1/messages. A proxy such as LiteLLM accepts those requests and forwards them to an OpenAI-style /chat/completions endpoint, then translates the reply back.

Is using Claude Code with other models supported by Anthropic?

No. Claude Code's gateway docs say Anthropic does not support routing Claude Code to non-Claude models through any gateway. It works in practice for many people, but bugs on that path are yours to debug.

Which BroadNet model should I use behind Claude Code?

GLM 5.3 or Qwen3.8 27B. BroadNet documents tool calling for those two only, and Claude Code edits files and runs commands through tools. GLM 5.3 has a 1,048,576-token context; Qwen3.8 27B has 262,144 and accepts images.

Can I run Claude Code on BroadNet's unlimited plan?

Not as a documented fit. The flat plans cover DeepSeek V4.1 Flash only, and BroadNet does not document tool calling for that model. A plan session also runs one request at a time, while Claude Code can run subagents in parallel.

Why does Claude Code say Invalid model name through LiteLLM?

Claude Code asked for a model name your config.yaml does not define, often a built-in Claude alias or the background Haiku model. Set ANTHROPIC_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL to names from your model_list.

Read as MarkdownAsk ChatGPTAsk ClaudeAsk Perplexity