You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request: Explicit provider selection for LLM inference in SDK #430
Feature request: Allow explicit provider selection for LLM inference
Currently, when using the OpenRouter TypeScript SDK, specifying a model (e.g., openrouter/glm-5.1) does not allow the user to directly choose the underlying provider that serves the model. However, some models (such as GLM-5.1) are available from multiple providers (e.g., Zhipu, NVIDIA), and there may be valid reasons to route requests via a particular provider (performance, regional compliance, availability, pricing, etc.).
Proposed Enhancement:
Add a feature to the SDK and/or the OpenRouter routing logic to enable end-users to select a preferred provider for a given model, if that model is available from multiple providers.
If NVIDIA, Zhipu, or other providers support a given model, provide a mechanism (e.g., via a provider parameter or model identifier) for the user to explicitly target their choice.
Fallback to automatic routing if an explicit provider is not selected or that provider is unavailable.
Motivation:
In some model listing pages, it is evident from vendor sites that a provider may host the same model, but OpenRouter currently doesn't expose a way to select which provider is used for inference.
There may be additional providers or future LLMs with multi-provider support where this feature would benefit users.
Users are able to explicitly select an available provider when making inference requests with the SDK, improving control over inference and provider-specific behavior.
Thanks for the thoughtful write-up! Good news: this is already supported. OpenRouter's Provider Routing lets you explicitly select which underlying provider serves a model, and the TypeScript SDK exposes it via the provider field on your request.
For example, to prefer specific providers (with automatic fallback):
constresult=awaitclient.chat.completions.create({model: "z-ai/glm-5.1",messages: [{role: "user",content: "Hello!"}],provider: {order: ["zhipu","nvidia"],// try Zhipu first, then NVIDIAallowFallbacks: true,// fall back to automatic routing if neither is available},});
Other useful keys on provider: only (restrict to specific provider slugs), ignore, and sort. Full reference: https://openrouter.ai/docs/guides/routing/provider-selection — and the SDK type is ProviderPreferences. If you're on an older SDK version, upgrading to the latest will make sure the field is available.
The referenced #85 predates the current SDK, which now includes this field across chat, responses, messages, embeddings, and rerank requests.
Since this is more of a usage/product question and is already covered, I'm going to close this out — but please don't hesitate to reach out in our community Discord for any follow-up product or routing questions: https://discord.gg/fVyRaUDgxW
Activity
mattapperson commentedon Jun 17, 2026
Thanks for the thoughtful write-up! Good news: this is already supported. OpenRouter's Provider Routing lets you explicitly select which underlying provider serves a model, and the TypeScript SDK exposes it via the
providerfield on your request.For example, to prefer specific providers (with automatic fallback):
Other useful keys on
provider:only(restrict to specific provider slugs),ignore, andsort. Full reference: https://openrouter.ai/docs/guides/routing/provider-selection — and the SDK type isProviderPreferences. If you're on an older SDK version, upgrading to the latest will make sure the field is available.The referenced #85 predates the current SDK, which now includes this field across chat, responses, messages, embeddings, and rerank requests.
Since this is more of a usage/product question and is already covered, I'm going to close this out — but please don't hesitate to reach out in our community Discord for any follow-up product or routing questions: https://discord.gg/fVyRaUDgxW
— the OpenRouter SDK team