feat(ai): expose routed model on openai-completions (#3968)

Adds `AssistantMessage.responseModel` on the openai-completions path:
surfaces the concrete `chunk.model` when it differs from the requested
id (e.g. OpenRouter `auto` -> `anthropic/...`).
This commit is contained in:
Alejandro
2026-04-30 00:16:12 +02:00
committed by GitHub
parent cf5ec23240
commit e354c521f4
4 changed files with 148 additions and 0 deletions

View File

@@ -207,6 +207,9 @@ export const streamOpenAICompletions: StreamFunction<"openai-completions", OpenA
// OpenAI documents ChatCompletionChunk.id as the unique chat completion identifier,
// and each chunk in a streamed completion carries the same id.
output.responseId ||= chunk.id;
if (typeof chunk.model === "string" && chunk.model.length > 0 && chunk.model !== model.id) {
output.responseModel ||= chunk.model;
}
if (chunk.usage) {
output.usage = parseChunkUsage(chunk.usage, model);
}

View File

@@ -216,6 +216,7 @@ export interface AssistantMessage {
api: Api;
provider: Provider;
model: string;
responseModel?: string; // Concrete `chunk.model` when different from the requested `model` (e.g. OpenRouter `auto` -> `anthropic/...`)
responseId?: string; // Provider-specific response/message identifier when the upstream API exposes one
usage: Usage;
stopReason: StopReason;