provide accurate model metadata

This commit is contained in:
joshualipman123 2025-08-25 15:50:44 -07:00 committed by daniel-lxs
parent b8094b30a7
commit 5e873eee82
No known key found for this signature in database
GPG key ID: 21C74479048B3AA6
2 changed files with 68 additions and 3 deletions

View file

@ -26,10 +26,70 @@ export const VERCEL_AI_GATEWAY_PROMPT_CACHING_MODELS = new Set([
"openai/o4-mini",
])
export const VERCEL_AI_GATEWAY_VISION_ONLY_MODELS = new Set([
"alibaba/qwen-3-14b",
"alibaba/qwen-3-235b",
"alibaba/qwen-3-30b",
"alibaba/qwen-3-32b",
"alibaba/qwen3-coder",
"amazon/nova-pro",
"anthropic/claude-3.5-haiku",
"google/gemini-1.5-flash-8b",
"google/gemini-2.0-flash-thinking",
"google/gemma-3-27b",
"mistral/devstral-small",
"xai/grok-vision-beta",
])
export const VERCEL_AI_GATEWAY_VISION_AND_TOOLS_MODELS = new Set([
"amazon/nova-lite",
"anthropic/claude-3-haiku",
"anthropic/claude-3-opus",
"anthropic/claude-3-sonnet",
"anthropic/claude-3.5-sonnet",
"anthropic/claude-3.7-sonnet",
"anthropic/claude-opus-4",
"anthropic/claude-opus-4.1",
"anthropic/claude-sonnet-4",
"google/gemini-1.5-flash",
"google/gemini-1.5-pro",
"google/gemini-2.0-flash",
"google/gemini-2.0-flash-lite",
"google/gemini-2.0-pro",
"google/gemini-2.5-flash",
"google/gemini-2.5-flash-lite",
"google/gemini-2.5-pro",
"google/gemini-exp",
"meta/llama-3.2-11b",
"meta/llama-3.2-90b",
"meta/llama-3.3",
"meta/llama-4-maverick",
"meta/llama-4-scout",
"mistral/pixtral-12b",
"mistral/pixtral-large",
"moonshotai/kimi-k2",
"openai/gpt-4-turbo",
"openai/gpt-4.1",
"openai/gpt-4.1-mini",
"openai/gpt-4.1-nano",
"openai/gpt-4.5-preview",
"openai/gpt-4o",
"openai/gpt-4o-mini",
"openai/gpt-oss-120b",
"openai/gpt-oss-20b",
"openai/o3",
"openai/o3-pro",
"openai/o4-mini",
"vercel/v0-1.0-md",
"xai/grok-2-vision",
"zai/glm-4.5v",
])
export const vercelAiGatewayDefaultModelInfo: ModelInfo = {
maxTokens: 64000,
contextWindow: 128000,
supportsImages: true,
supportsComputerUse: true,
supportsPromptCache: true,
inputPrice: 3,
outputPrice: 15,

View file

@ -2,6 +2,7 @@ import axios from "axios"
import { z } from "zod"
import type { ModelInfo } from "@roo-code/types"
import { VERCEL_AI_GATEWAY_VISION_ONLY_MODELS, VERCEL_AI_GATEWAY_VISION_AND_TOOLS_MODELS } from "@roo-code/types"
import type { ApiHandlerOptions } from "../../../shared/api"
import { parseApiPrice } from "../../../shared/cost"
@ -67,8 +68,8 @@ export async function getVercelAiGatewayModels(options?: ApiHandlerOptions): Pro
for (const model of data) {
const { id } = model
// Filter out embedding models (models with "embedding" in name)
if (id.toLowerCase().includes("embed")) {
// Only include language models
if (model.type !== "language") {
continue
}
@ -98,11 +99,15 @@ export const parseVercelAiGatewayModel = ({ id, model }: { id: string; model: Ve
const cacheReadsPrice = model.pricing?.input_cache_read ? parseApiPrice(model.pricing?.input_cache_read) : undefined
const supportsPromptCache = typeof cacheWritesPrice !== "undefined" && typeof cacheReadsPrice !== "undefined"
const supportsImages =
VERCEL_AI_GATEWAY_VISION_ONLY_MODELS.has(id) || VERCEL_AI_GATEWAY_VISION_AND_TOOLS_MODELS.has(id)
const supportsComputerUse = VERCEL_AI_GATEWAY_VISION_AND_TOOLS_MODELS.has(id)
const modelInfo: ModelInfo = {
maxTokens: model.max_tokens,
contextWindow: model.context_window,
supportsImages: false,
supportsImages,
supportsComputerUse,
supportsPromptCache,
inputPrice: parseApiPrice(model.pricing?.input),
outputPrice: parseApiPrice(model.pricing?.output),