Skip to content
← All articles

Published November 14, 2026 · 6 min read

Run DeepSeek V4.1 Flash or GLM 5.3 Flash in Claude Code

Point Claude Code at zrouter and run deepseek-v4.1-flash or glm-5.3-flash. Which variable to use, ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY, how to set the background model, and what it costs.


Claude Code does not care which model sits behind the endpoint, as long as the endpoint speaks the Anthropic messages protocol. zrouter does, so you can run deepseek-v4.1-flash or glm-5.3-flash inside Claude Code with a handful of environment variables.

This guide shows the setup, explains the two authentication variables people mix up, and covers the background-model setting that trips up most first attempts.

What these two models cost

Prices below come from the live zrouter catalog on 14 November 2026 and are per 1M tokens. Check the model pages for the current numbers.

| Model | Input | Output | Context | Below official price | | --- | --- | --- | --- | --- | | deepseek-v4.1-flash | $0.015 | $0.06 | 1,000,000 tokens | 90% | | glm-5.3-flash | $0.015 | $0.05 | 1,000,000 tokens | 90% |

You can pay as you go, or buy a Token Plan for the model ($1, $2, $5 or $10). A Token Plan is spent first; when it runs out, requests fall back to your pay-as-you-go balance. The balance does not expire and there is no 5-hour window. See pricing for the tiers.

The environment

Create an API key in the zrouter dashboard (it starts with zr_), then set these variables before starting claude:

export ANTHROPIC_BASE_URL="https://api.zrouter.dev"
export ANTHROPIC_AUTH_TOKEN="zr_your_key_here"
export ANTHROPIC_MODEL="deepseek-v4.1-flash"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4.1-flash"
claude

Three details matter:

  1. The base URL has no /v1. For the Anthropic protocol the base URL is https://api.zrouter.dev; Claude Code adds the /v1/messages path itself. The /v1 suffix belongs to OpenAI-compatible tools only (https://api.zrouter.dev/v1).
  2. The model name is the zrouter name, exactly as shown on the model page.
  3. Set the background model too. See below.

ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY?

Claude Code's environment variable reference describes them like this: ANTHROPIC_AUTH_TOKEN is a custom value for the Authorization header, sent with a Bearer prefix, while ANTHROPIC_API_KEY is sent as the X-Api-Key header. The same page notes that when ANTHROPIC_API_KEY is set, Claude Code uses it instead of your Claude subscription, even if you are logged in.

The zrouter gateway accepts both header styles, and either one carries the same zr_ key. In practice:

  • Use ANTHROPIC_AUTH_TOKEN when you want a clean, explicit gateway setup. It does not interact with the subscription login logic.
  • Use ANTHROPIC_API_KEY if your tooling already expects it. Set only one of them, not both.

If you see a 401 invalid_api_key, the key is wrong, expired or revoked. The gateway deliberately answers the same way for all of those cases.

The background model: SMALL_FAST_MODEL is deprecated

Claude Code runs some work in the background, such as short summaries and titles, on a small, fast model. Older guides tell you to set ANTHROPIC_SMALL_FAST_MODEL. The model configuration page now says that variable is deprecated in favour of ANTHROPIC_DEFAULT_HAIKU_MODEL, and the environment reference lists the Haiku variable as the model "also used for background functionality".

So set ANTHROPIC_DEFAULT_HAIKU_MODEL to a model your zrouter key can reach. Pointing it at the same Flash model keeps background calls cheap and avoids requests for a model name the gateway does not serve. If you still have ANTHROPIC_SMALL_FAST_MODEL in an old shell profile, remove it.

Put it in settings.json instead

If you do not want to export variables in every shell, Claude Code also reads an env block from its settings file, and the LLM gateway guide shows that pattern:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.zrouter.dev",
    "ANTHROPIC_AUTH_TOKEN": "zr_your_key_here",
    "ANTHROPIC_MODEL": "glm-5.3-flash",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.3-flash"
  }
}

Keep a key like this out of any repository. A project-level settings file that is committed would leak it.

Reasoning models and small token limits

Both models can think before they answer. If you test with a tiny max_tokens (for example 16 or 32), the budget can be used up by reasoning and the visible answer comes back empty. That is not a gateway error. Claude Code sets generous limits itself, but if you call the endpoint by hand, use a larger max_tokens.

Quick check from the terminal

Before starting Claude Code, confirm the key and model with one request:

curl https://api.zrouter.dev/v1/messages \
  -H "x-api-key: $ZROUTER_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model":"deepseek-v4.1-flash","max_tokens":512,"messages":[{"role":"user","content":"Say hi"}]}'

A 200 with a usage object means the setup is right. A 402 means the key has no remaining Token Plan and the pay-as-you-go balance is empty; top up and retry.

Paying for it

You can top up with QRIS, USDT or USDC. No credit card is needed. QRIS checkouts can include a small service fee, and the checkout screen shows the exact total before you pay. For USDT and USDC, the network fee of the chain you send on is paid by you as the sender and is not part of the zrouter price.

Summary

  • Base URL https://api.zrouter.dev (no /v1) for Claude Code.
  • ANTHROPIC_AUTH_TOKEN is the clean choice; set only one of the two key variables.
  • Use ANTHROPIC_DEFAULT_HAIKU_MODEL, not the deprecated ANTHROPIC_SMALL_FAST_MODEL.
  • deepseek-v4.1-flash and glm-5.3-flash are both 90% below the official price at the time of writing.

Ready to try it? Create a key or browse the model catalog.