Environment
- openrouter/sdk@1.2.27
- TypeScript 5.9.3
- NodeNext module resolution
Problem
chat.send() has separate overloads for stream?: false and stream: true, but both return:
ChatResult | EventStream<ChatStreamChunk>
This makes both documented usage patterns fail TypeScript.
Non-streaming
const completion = await client.chat.send({
chatRequest: {
model: "openai/gpt-5-mini",
messages: [{ role: "user", content: "Hello" }],
stream: false,
},
});
console.log(completion.choices[0]);
TS2339: Property 'choices' does not exist on type
'SendChatCompletionRequestResponse'.
Streaming
const stream = await client.chat.send({
chatRequest: {
model: "openai/gpt-5-mini",
messages: [{ role: "user", content: "Hello" }],
stream: true,
},
});
for await (const chunk of stream) {
console.log(chunk);
}
TS2504: SendChatCompletionRequestResponse must have a
[Symbol.asyncIterator]() method.
Expected
The overloads should return:
stream?: false → Promise<ChatResult>
stream: true → Promise<EventStream<ChatStreamChunk>>
The union is only necessary when the streaming mode is not statically known.
Environment
Problem
chat.send()has separate overloads forstream?: falseandstream: true, but both return:This makes both documented usage patterns fail TypeScript.
Non-streaming
Streaming
Expected
The overloads should return:
The union is only necessary when the streaming mode is not statically known.