Skip to content
AI.info

The Pulse

Hugging Face switches language-model routing to OpenRouter

Hugging Face has replaced its custom router for language-model requests with OpenRouter, adding retries across providers. Existing code and tokens continue to work, but custom provider API keys can no longer be used for those models.

Hugging Face switches language-model routing to OpenRouter

Hugging Face has replaced its custom router for language-model requests with OpenRouter, adding automatic retries with another provider when a call fails. The change lets developers call open-weight models on the Hugging Face Hub that a provider serves using their existing token and API, the company said in a blog post.

The switch was published on November 16 as part of a partnership between the companies. Existing code stays the same, but users can no longer supply their own provider API keys for language-model requests.

How requests are routed

Previously, Inference Providers selected a single provider for a request and returned an error if that provider failed. OpenRouter chooses a provider using live price, speed and reliability measurements; if the first attempt fails, the request is retried with another provider within the same call.

The router supports OpenAI's Chat Completions and Responses APIs and Anthropic's Messages API for every chat model, regardless of the provider serving it. The post also provides setup guides for Claude Code, Codex, OpenCode, Pi and Hermes Agent.

Developers can override the default selection by adding a suffix to a model ID. The :fastest suffix selects the highest throughput, :cheapest selects the lowest price, and a provider name such as :novita restricts the request to that provider.

The routing is also cache-aware: a conversation stays with the provider holding its prompt cache. Developers can make the association explicit by sending a stable UUID for each conversation in the X-HF-Session-Id header.

OpenRouter's measurements of its recently rebuilt routing system found a 46% reduction in capacity errors, a 16.9% improvement in time to first token and a 16.3% improvement in throughput.

Billing and provider keys

Requests are billed to the user's Hugging Face account or organization, rather than through a custom provider key. Users can still select a provider by suffix or disable providers in their settings. Custom keys for image and video providers continue to work.

Pricing remains at the provider's price on the Hugging Face bill, without a Hugging Face markup. PRO users receive $2 in credits each month, while Team and Enterprise organizations receive $2 per seat.

Image, video and audio generation continue through Hugging Face Inference Providers directly, without going through OpenRouter. They continue to use the same token and API.

Provider details on model pages

Model pages have new Providers and Metrics tabs alongside the chat widget. The Providers tab lists the providers OpenRouter can route a model to, their input and output prices, speed and uptime over the last 24 hours. Metrics shows the best price, throughput, time to first token, context length and uptime among them.

Users can also see spending broken down by the provider that handled each request. Organization settings can disable providers for every request billed to that organization.

The companies plan to let users connect an OpenRouter account to Hugging Face and route more tasks through OpenRouter.

Source

  1. Hugging Face

Companies in this story

Related stories

Explore

More articles