Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/gateway/src/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1832,7 +1832,11 @@ chat.openapi(completions, async (c) => {
);
}

const baseModelName = finalModelInfo?.id || usedModel;
// Use the canonical model ID from modelInfo (set before any routing/fallback)
// This ensures correct stats tracking when low-uptime fallback changes the provider
// Fall back to finalModelInfo.id or usedModel for edge cases like custom providers
const baseModelName =
(modelInfo as ModelDefinition)?.id || finalModelInfo?.id || usedModel;

// Check if this is an image generation model
const imageGenProviderMapping = finalModelInfo?.providers.find(
Expand Down
2 changes: 1 addition & 1 deletion apps/worker/src/services/stats-calculator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ describe("stats-calculator", () => {
duration: 2000,
requestedModel: "gpt-4",
requestedProvider: "anthropic",
usedModel: "openai/gpt-4",
usedModel: "anthropic/gpt-4", // Must match usedProvider for correct stats tracking
usedProvider: "anthropic",
responseSize: 150,
hasError: true,
Expand Down
Loading