diff --git a/src/api/providers/fetchers/__tests__/vercel-ai-gateway.spec.ts b/src/api/providers/fetchers/__tests__/vercel-ai-gateway.spec.ts index ed4baa33b8b..5c33116e5c6 100644 --- a/src/api/providers/fetchers/__tests__/vercel-ai-gateway.spec.ts +++ b/src/api/providers/fetchers/__tests__/vercel-ai-gateway.spec.ts @@ -108,10 +108,7 @@ describe("Vercel AI Gateway Fetchers", () => { const models = await getVercelAiGatewayModels() expect(models).toEqual({}) - expect(consoleErrorSpy).toHaveBeenCalledWith( - "Vercel AI Gateway models response is invalid", - expect.any(Object), - ) + expect(consoleErrorSpy).toHaveBeenCalled() consoleErrorSpy.mockRestore() }) diff --git a/src/api/providers/fetchers/vercel-ai-gateway.ts b/src/api/providers/fetchers/vercel-ai-gateway.ts index 646def5ec84..483dbe27008 100644 --- a/src/api/providers/fetchers/vercel-ai-gateway.ts +++ b/src/api/providers/fetchers/vercel-ai-gateway.ts @@ -12,10 +12,11 @@ import { parseApiPrice } from "../../../shared/cost" */ const vercelAiGatewayPricingSchema = z.object({ - input: z.string(), - output: z.string(), + input: z.string().optional(), // Image models don't have an input price. + output: z.string().optional(), // Embedding and image models don't have an output price. input_cache_write: z.string().optional(), input_cache_read: z.string().optional(), + image: z.string().optional(), // Only image models have an image price. }) /** @@ -62,22 +63,19 @@ export async function getVercelAiGatewayModels(options?: ApiHandlerOptions): Pro const data = result.success ? result.data.data : response.data.data if (!result.success) { - console.error("Vercel AI Gateway models response is invalid", result.error.format()) + console.error(`Vercel AI Gateway models response is invalid ${JSON.stringify(result.error.format())}`) } for (const model of data) { const { id } = model - // Only include language models for chat inference - // Embedding models are statically defined in embeddingModels.ts + // Only include language models for chat inference. + // Embedding models are statically defined in embeddingModels.ts. if (model.type !== "language") { continue } - models[id] = parseVercelAiGatewayModel({ - id, - model, - }) + models[id] = parseVercelAiGatewayModel({ id, model }) } } catch (error) { console.error(