Hugging Face Inference Providers now route through OpenRouter: what changes for your code, keys and Claude Code
Hugging Face now sends language model requests from Inference Providers through OpenRouter's router, with automatic retries on another provider. Your code and token stay the same, but your own provider API keys no longer work for language models.
Hugging Face has switched Inference Providers, its pay-as-you-go API for models served by many inference providers, from its own router to OpenRouter's. Since November 16, 2026, requests to language models go through OpenRouter, which picks a provider for each call based on live price, speed and reliability, and retries on another provider inside the same call if the first one fails. Hugging Face says your code stays the same.
One thing does break: you can no longer use your own API key for a provider when calling language models. Those requests are now billed to your Hugging Face account or organization. Image, video and audio generation are not affected: they still run directly through Hugging Face Inference Providers, without OpenRouter.
What changed, in one list
- Routing: language model requests go through OpenRouter, which compares effective price (what a provider actually charges given its real cache hit rate and the model's usual mix of input and output tokens, not just the list price), throughput and time to first token, and how often each provider fails, returns malformed tool calls or runs out of capacity. The measurements update in real time, and traffic moves away from a slow or failing provider until it recovers.
- Failover: before, Inference Providers picked one provider and returned its error if it failed. Now a failed request is retried on another provider serving the model.
- Same token, same API: the router accepts OpenAI's Chat Completions and Responses APIs and Anthropic's Messages API for every chat model.
- Pricing: you pay the provider's price on your Hugging Face bill, with no Hugging Face markup. PRO users get $2 of credits a month; Team and Enterprise organizations get $2 per seat, shared among members. These are general-purpose compute credits that also cover Inference Endpoints, Spaces hardware and Jobs, and they are applied before pay-as-you-go billing. Free accounts get no monthly credits and must buy credits to use Inference Providers.
- Visibility: model pages gain a Providers tab (input and output price, speed and 24-hour uptime per provider) and a Metrics tab (best price, throughput, time to first token, context length and uptime among them), and your usage overview splits the past month's spend by model and by the provider each request went to.
- Not routed through OpenRouter: image, video and audio generation.
Who needs to change something
Most callers do not. If you send a model id and your Hugging Face token, failover is now included, with no stated extra charge; usage is still billed at the provider's price. Check your setup if any of these apply:
- You used your own provider API key for language models. That no longer works. Hugging Face's blog post does not say what error old requests return, so test before you rely on it. To keep a specific provider, pin it with a suffix on the model id instead, and remember the cost now lands on your Hugging Face bill. Custom keys for image and video providers keep working.
- You pinned a provider, such as model:novita. A pinned provider is never replaced, so you do not get the new failover. If the pin was only a workaround for flaky providers, try removing it.
- You need to keep traffic away from certain providers. Turn them off in your Inference Providers settings; the router never sends requests there, and pinning a disabled provider returns an error. Pinning a provider that does not serve the model also returns an error.
- You bill to an organization. Those requests follow the organization's provider settings, not yours. From code, pass bill_to to the Python InferenceClient, billTo to the JavaScript InferenceClient, or an X-HF-Bill-To header in OpenAI-client and raw HTTP requests; admins can also set a spending limit.
- You run long agent sessions. Routing is cache-aware, but to keep a conversation on the provider that holds its prompt cache explicitly, send a stable UUID per conversation in the X-HF-Session-Id header. Hugging Face says its Python and JavaScript clients handle caching automatically. Either way, keep the system prompt and tools first and what changes last, avoid timestamps or random ids at the top of the system prompt, and check cached_tokens in the response's usage field to see whether the cache was hit.
Suffixes: which one to use
The routing policy is set by a suffix on the model id, so it works even in tools that only let you type a model name:
zai-org/GLM-5.3 # default: best mix of price, speed and reliability
zai-org/GLM-5.3:fastest # highest throughput
zai-org/GLM-5.3:cheapest # lowest price
zai-org/GLM-5.3:novita # only Novita (no failover)The docs define the default as balancing price, speed and reliability, :fastest by throughput, :cheapest by price, and a provider suffix as that provider only. Our suggestion: pin a provider when you need to know which one ran every request, for example when comparing providers in an evaluation; pinning fixes the provider, not the output. Otherwise leave the default on, since it is the setting that retries on another provider when one fails.
Using it from Claude Code
Hugging Face's Claude Code guide points the CLI at the router. The quickest route is the hf-claude extension for the hf CLI, which opens a model and provider picker and launches Claude Code with the environment set. It needs an HF_TOKEN with the "Make calls to Inference Providers" permission:
hf extensions install hf-claude
hf claudeThe manual route sets the Anthropic environment variables. The guide maps every Claude Code model slot to an open model; you can give each slot a different model, and CLAUDE_CODE_SUBAGENT_MODEL controls sub-agents:
export ANTHROPIC_BASE_URL="https://router.huggingface.co"
export ANTHROPIC_AUTH_TOKEN="${HF_TOKEN}"
export ANTHROPIC_API_KEY="${HF_TOKEN}"
export ANTHROPIC_DEFAULT_FABLE_MODEL="zai-org/GLM-5.3"
export ANTHROPIC_DEFAULT_OPUS_MODEL="zai-org/GLM-5.3"
export ANTHROPIC_DEFAULT_SONNET_MODEL="zai-org/GLM-5.3"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="zai-org/GLM-5.3"
export CLAUDE_CODE_SUBAGENT_MODEL="zai-org/GLM-5.3"
claudeTo bill a Team or Enterprise organization you belong to, use hf claude --bill-to your-org-name, set HF_BILL_TO, or with manual variables set ANTHROPIC_CUSTOM_HEADERS to "X-HF-Bill-To: your-org-name". Hugging Face also publishes setup guides for Codex, OpenCode, Pi and Hermes Agent.
What the numbers in the announcement add up to
Hugging Face backs the move with OpenRouter data. Open-weight models went from 26.8% of tokens served on OpenRouter in October 2025 to 71.7% at the end of September 2026, after peaking at 77.5% in July, and weekly open-weight volume grew more than 60-fold against almost tenfold for closed models. OpenRouter serves more than 800 trillion tokens a month to over 10 million users, across 600+ models from 80+ providers. Their average price was $0.28 per million input tokens and $1.62 per million output tokens, against $1.27 and $6.36 for closed models.
Worked out from those averages, closed models cost about 4.5 times more per input token and 3.9 times more per output token. For an illustrative agent session of 2 million input and 200,000 output tokens, that is roughly $0.88 at the open-weight average against $3.81 at the closed average, so $2 would cover about two such sessions at the open-weight average if nothing else used the credit. In practice the PRO credit is shared with other compute spend. Real prices depend on the model and provider; check the Providers tab before you budget.
The quality gap is still there. On the Artificial Analysis Intelligence Index cited by Hugging Face, Kimi K3.1 Pro, the best open-weight model, scores 46 against 65 for Claude Fable 5.2, about 71% of the score, at $3.68 per task against $26.54, about one seventh of the cost. OpenRouter says its rebuilt routing cut capacity errors by 46% and improved time to first token by 16.9% and throughput by 16.3%; those are OpenRouter's own measurements.
What comes next
Hugging Face calls this the first step of the partnership. Next on its list: connecting your OpenRouter account to Hugging Face, and routing more tasks through OpenRouter. It has not given dates.
Try it with your AI. Copy this into Claude Code or another coding assistant to audit a project that calls Hugging Face Inference Providers:
Audit this repository for calls to Hugging Face Inference Providers after its November
16, 2026 switch to OpenRouter routing for language models. My target behaviour: [default
routing / cheapest / one fixed provider]. First, list every place that calls
router.huggingface.co, uses huggingface_hub InferenceClient or huggingface.js inference,
or sets ANTHROPIC_BASE_URL or OPENAI_BASE_URL to the Hugging Face router; also check
provider parameters, config files and environment variable names that set a model id or
key. Do not print or open any token or .env values; refer to variables by name only. For
each call, report in a table: file and line, task (chat/text vs image, video or audio),
model id, any suffix (:fastest, :cheapest or a provider name), and whether it passes a
provider's own API key instead of a Hugging Face token. Then flag only: (1) chat or text
calls that pass a provider's own API key, since those no longer work (image and video
provider keys still work, do not flag them); (2) pinned providers, which are never
replaced if they fail, if that conflicts with my target behaviour; (3) long multi-turn
chat loops that send raw HTTP requests, not through the Hugging Face clients, without an
X-HF-Session-Id header. For each flag, propose a change but show me the diff and wait
for my confirmation before editing anything. Do not install packages and do not change
billing or organization settings.FAQ
Do I need to change my code? Usually no. Hugging Face says the same token and API keep working. Change it only if you used your own provider API key for language models, or if you want a different routing policy.
Does Hugging Face charge more now? No. You pay the provider's price on your Hugging Face bill, with no markup. PRO, Team and Enterprise credits still apply, and they are general-purpose compute credits shared with other Hugging Face compute services.
Can I still choose the provider? Yes. Add the provider name as a suffix, such as :novita, or turn providers off in your settings. A pinned provider is not replaced if it fails.
Are image and video models affected? No. Image, video and audio generation keep working as before without OpenRouter, and custom keys for image and video providers still work.
Can I use my OpenRouter account with Hugging Face? Not yet. Connecting an OpenRouter account is listed as a next step, with no date.
I am on a free account. Can I use it? Free accounts get no monthly credits; Hugging Face's pricing page says free users can use Inference Providers by purchasing credits or upgrading to PRO.
How do I bill usage to my organization from code? Pass bill_to to the Python InferenceClient, billTo to the JavaScript InferenceClient, or send an X-HF-Bill-To header with the organization name. The organization must be a Team or Enterprise org.
Source: Hugging Face blog: Hugging Face and OpenRouter join forces to make open-weight models easy to run (November 16, 2026), Hugging Face docs: Inference Providers routing and providers, Hugging Face docs: Claude Code with Inference Providers, Hugging Face docs: Prompt caching, Hugging Face docs: Pricing and billing
This story first appeared in the claudefox daily briefing for November 17, 2026.