Skip to content

Commit 09907ad

Browse files
author
1bcMax
committed
fix: align listModels field mapping with actual API response format
The API returns camelCase fields (inputPrice, outputPrice, provider) but the client was mapping from wrong fields (pricing.input, owned_by). Now accepts both camelCase and snake_case for compatibility.
1 parent 137a4ab commit 09907ad

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/client.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -877,16 +877,16 @@ export class LLMClient {
877877

878878
// eslint-disable-next-line @typescript-eslint/no-explicit-any
879879
const data = (await response.json()) as { data?: any[] };
880-
// Map API snake_case response to SDK camelCase Model interface
880+
// Map API response to SDK Model interface
881881
return (data.data || []).map((m) => ({
882882
id: m.id,
883883
name: m.name || m.id,
884-
provider: m.owned_by || "",
884+
provider: m.provider || m.owned_by || "",
885885
description: m.description || "",
886-
inputPrice: m.pricing?.input ?? m.pricing?.flat ?? 0,
887-
outputPrice: m.pricing?.output ?? 0,
888-
contextWindow: m.context_window || 0,
889-
maxOutput: m.max_output || 0,
886+
inputPrice: m.inputPrice ?? m.input_price ?? m.pricing?.input ?? 0,
887+
outputPrice: m.outputPrice ?? m.output_price ?? m.pricing?.output ?? 0,
888+
contextWindow: m.contextWindow ?? m.context_window ?? 0,
889+
maxOutput: m.maxOutput ?? m.max_output ?? 0,
890890
categories: m.categories || [],
891891
available: true,
892892
}));

0 commit comments

Comments
 (0)