Skip to content

Feature request: Explicit provider selection for LLM inference in SDK #430

Closed

Description

@bitsnaps

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.

References:

Expected outcome:

  • Users are able to explicitly select an available provider when making inference requests with the SDK, improving control over inference and provider-specific behavior.

Activity

  1. mattapperson commented on Jun 17, 2026

    @mattapperson
    Contributor

    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):

    const result = await client.chat.completions.create({
      model: "z-ai/glm-5.1",
      messages: [{ role: "user", content: "Hello!" }],
      provider: {
        order: ["zhipu", "nvidia"], // try Zhipu first, then NVIDIA
        allowFallbacks: 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

    — the OpenRouter SDK team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions