Skip to content

Provider routing #85

Closed
Closed

Description

@ProjectInfinity

I noticed that after migrating over from the openai library to openrouter sdk I cannot seem to give it a provider routing anymore.

The README lists a provider key (which I assume is where my provider information would go such as limiting a myself to only one provider). This is the example code:

https://github.com/OpenRouterTeam/typescript-sdk?tab=readme-ov-file#sdk-usage

import { OpenRouter } from "@openrouter/sdk";

const openRouter = new OpenRouter();

const result = await openRouter.chat.send({
  messages: [
    {
      role: "user",
      content: "Hello, how are you?",
    },
  ],
  model: "openai/gpt-5",
  provider: {
    zdr: true,
    sort: "price",
  },
  stream: true
});

for await (const chunk of result) {
  console.log(chunk.choices[0].delta.content)
}

However upon trying this I was met with typescript errors that the provider field does not exist. Upon looking at ChatGenerationParams this does indeed seem to be the case.
https://github.com/OpenRouterTeam/typescript-sdk/blob/main/src/models/chatgenerationparams.ts#L73

Is this a documentation issue, implementation issue or am I doing something wrong?

Appreciate any pointers.
Thanks.

Activity

  1. mattapperson commented on Nov 18, 2025

    @mattapperson
    Contributor

    So sorry, this is a bug that I will be resolving hopefully today

  2. self-assigned this
    on Nov 18, 2025
  3. mattapperson commented on Nov 18, 2025

    @mattapperson
    Contributor

    This is now fixed in v0.1.13

  4. ProjectInfinity commented on Nov 18, 2025

    @ProjectInfinity
    Author

    This is now fixed in v0.1.13

    Thanks @mattapperson . However how would I use it? As far as I can tell ChatGenerationParams still does not contain this field and as such the README section is still showcasing what seems to be a missing field.

  5. dehli commented on Dec 3, 2025

    @dehli

    Just ran into this as well - looks like provider is missing from the ChatGenerationParams type

    export type ChatGenerationParams = {
    messages: Array<Message>;
    model?: string | undefined;
    models?: Array<string> | undefined;
    frequencyPenalty?: number | null | undefined;
    logitBias?: { [k: string]: number } | null | undefined;
    logprobs?: boolean | null | undefined;
    topLogprobs?: number | null | undefined;
    maxCompletionTokens?: number | null | undefined;
    maxTokens?: number | null | undefined;
    metadata?: { [k: string]: string } | undefined;
    presencePenalty?: number | null | undefined;
    reasoning?: Reasoning | undefined;
    responseFormat?:
    | ChatGenerationParamsResponseFormatText
    | ChatGenerationParamsResponseFormatJSONObject
    | ResponseFormatJSONSchema
    | ResponseFormatTextGrammar
    | ChatGenerationParamsResponseFormatPython
    | undefined;
    seed?: number | null | undefined;
    stop?: string | Array<string> | null | undefined;
    stream?: boolean | undefined;
    streamOptions?: ChatStreamOptions | null | undefined;
    temperature?: number | null | undefined;
    toolChoice?: any | undefined;
    tools?: Array<ToolDefinitionJson> | undefined;
    topP?: number | null | undefined;
    user?: string | undefined;
    debug?: Debug | undefined;
    };

  6. dpchamps commented on Dec 3, 2025

    @dpchamps

    This doesn't appear to be fixed as of 0.2.9

  7. remitoffoli commented on Dec 11, 2025

    @remitoffoli

    Yep, quite confusing as the code doesn't match the documentation at all:
    https://openrouter.ai/docs/guides/routing/provider-selection

    Maybe this should be re-opened?

  8. mattapperson commented on Dec 11, 2025

    @mattapperson
    Contributor

    Sorry, it does seem we quickly regressed here, my apologies. We will prioritize fixing this ASAP

  9. BlackGlory commented on Dec 12, 2025

    @BlackGlory

    15 years of experience, 300 vibe-coded commits, and it's still worse than the client I casually hacked together.
    The industry is cooked lmao.

  10. mattapperson commented on Dec 16, 2025

    @mattapperson
    Contributor

    Sorry for the delay in getting back to this thread, but this issue should be fixed now. Leaving this open though for now to keep an eye on it.

  11. yogasanas commented on Jan 22, 2026

    @yogasanas
    Contributor

    Hey all! This should be fixed now! Thanks for the patience.

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

Metadata

Metadata

Assignees

Labels

BugsbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions