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
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down
16 changes: 7 additions & 9 deletions src/api/providers/fetchers/vercel-ai-gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
})

/**
Expand Down Expand Up @@ -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(
Expand Down
Loading