Skip to Content

Models and routing

Connect a provider, pick a model, and see how zerd routes each request, fails over, and keeps cheaper models on track.

zerd connects to Claude, GPT, Codex, DeepSeek and local models through a key or a login, routes each request to a model that fits it, and fails over to another provider when one runs out of quota.

Connecting a model

There are three ways to connect a provider:

  • zerd setup asks for a key, tests it with a live call, and saves it.
  • /connect <provider> inside a session asks for the key, saves it, and lists the provider's models. /connect alone shows which providers are ready.
  • Set the provider's environment variable (see the table below).

Keys you paste are saved to zerd's own .env in the data folder, readable only by you. zerd never opens the .env of the repo you are working in.

Model ids

FormWhere it goes
groq:llama-3.3-70bStraight to that provider. Only the first colon splits, so ollama:qwen3:8b keeps its tag
codex/gpt-5.6-lunaYour ChatGPT/Codex login, over the Responses API
MiniMaxAI/MiniMax-M3 (anything else)The gateway, using API_KEY and BASE_URL

The default model is MiniMaxAI/MiniMax-M3. Change it with -m, /model, or [model] name in config.

For example, zerd -m groq:llama-3.3-70b sends everything to Groq for that run.

Built-in providers

NameKey variableFormat
openaiOPENAI_API_KEYOpenAI
anthropicANTHROPIC_API_KEYAnthropic
geminiGEMINI_API_KEYOpenAI-compatible
openrouterOPENROUTER_API_KEYOpenAI
groqGROQ_API_KEYOpenAI
deepseekDEEPSEEK_API_KEYOpenAI
mistralMISTRAL_API_KEYOpenAI
xaiXAI_API_KEYOpenAI
togetherTOGETHER_API_KEYOpenAI
fireworksFIREWORKS_API_KEYOpenAI
cerebrasCEREBRAS_API_KEYOpenAI
moonshotMOONSHOT_API_KEYOpenAI
zaiZAI_API_KEYOpenAI
ollamanone, localhost:11434OpenAI
lmstudionone, localhost:1234OpenAI

Your own provider

Any server that speaks the OpenAI or Anthropic format needs only a few lines in config.toml:

[providers.work]
base_url    = "https://llm.internal.example.com/v1"
api_key_env = "WORK_LLM_KEY"
protocol    = "anthropic"            # default is "openai"
headers     = { "x-team" = "infra" } # optional extra headers

Then use -m work:some-model. A provider that is not a built-in needs a base_url.

Servers that are only mostly OpenAI-compatible

vLLM, llama.cpp, SGLang and company proxies often differ from OpenAI in small ways. The compat switches in config cover those. Each line below is a separate switch, so set only the ones your server needs:

[providers.box.compat]
max_tokens_field     = "max_completion_tokens"   # or "none" to send no cap
stream_usage         = false                      # the server rejects stream_options
tool_result_name     = true                       # tool messages must carry the tool's name
assistant_after_tool = true                       # the chat template refuses a user message right after a tool one
cache_control        = true                       # a proxy in front of Claude that wants Anthropic cache marks
extra_body           = { thinking_token_budget = 4096 }   # merged into every request, last, so it wins

Roles and routing

A role is a job, and each role is a fallback chain. zerd tries the models left to right and moves on when one fails.

RoleUsed for
defaultOrdinary requests
fastSmall, easy requests
strongHard requests, and after a repair fails or a loop is detected
exploreThe scout that searches the repo first
summarizeShrinking old conversation when the context fills up. Falls back to fast
reviewIndependent review of changes. A model other than the main one is preferred
advisorA second opinion before big edits. Defaults to deepseek/deepseek-v4-pro
challengeArguing against risky plans
[routing]
default = ["anthropic:claude-sonnet-5-5", "deepseek:deepseek-chat"]
fast    = ["groq:llama-3.3-70b"]
strong  = ["anthropic:claude-opus-5-5"]
review  = ["openai:gpt-5.6-sol"]

Each request is classified by rules, without a model call, and zerd prints the reason:

  • Small work goes to fast.
  • Words like debugging, race condition, refactor, migration, security, payments and webhooks send it to strong.
  • A failed repair or a detected loop escalates to strong.

Pinning a model with -m or /model turns routing off for the main model.

If a provider's quota runs out, zerd fails over to another provider and tells you.

What zerd fixes for the model

Open and cheaper models often get the hard parts right but slip on small mechanical things. zerd corrects those in code, so you rarely see them.

What the model doesWhat zerd does
Calls Read, bash, str_replaceMaps it to read_file, shell, edit
Sends old_str, file_path, newStringRenames to the real parameters
Sends a list of edits as a JSON string, or one edit instead of a list of oneParses it
Writes a tool call into its answer (<tool_call>, [TOOL_CALLS])Says "text is not run" and re-asks, twice at most
Thinks, then replies with nothingTells it the user saw a blank answer
Is cut off by the output limitContinues exactly where it stopped. A tool call cut mid-argument is never run
Pastes code instead of writing the fileNotices no file changed and asks it to apply it
Only updates a doc when the bug is in codeSends it back for the code
Hits a "prompt too long" in any of 20+ providers' wordingsCompacts and retries once

Tuning from what happened

Four commands show what your models are doing:

  • zerd probe-models shows which models your gateway key can call, with latency.
  • zerd insights reads zerd's trace files and shows, per model, failed calls, cache hit rate, malformed tool calls and how often the loop had to step in.
  • /cost shows the current session. Add a [pricing] section to see a dollar estimate (see Configuration).
  • /effort low|medium|high|auto sets reasoning effort for Codex models. Others ignore it.

On this page