From 515b4e5d6a5543b2bd8f20b53aeac4374100bbc4 Mon Sep 17 00:00:00 2001
From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com>
Date: Wed, 5 Nov 2025 12:43:44 -0800
Subject: [PATCH] Fix vercel gateway thinking and model list (#7196)
---
cli/pkg/cli/task/settings_parser.go | 6 -
proto/cline/models.proto | 2 -
src/core/api/index.ts | 8 +-
src/core/api/providers/vercel-ai-gateway.ts | 36 ++++-
.../api/transform/vercel-ai-gateway-stream.ts | 38 ++++-
src/core/controller/index.ts | 11 --
src/core/controller/ui/initializeWebview.ts | 46 ------
src/core/storage/StateManager.ts | 18 ---
src/core/storage/utils/state-helpers.ts | 14 --
src/shared/api.ts | 21 ---
.../models/api-configuration-conversion.ts | 8 -
src/shared/storage/state-keys.ts | 4 -
.../settings/OpenRouterModelPicker.tsx | 4 +-
.../providers/VercelAIGatewayProvider.tsx | 140 ++----------------
.../settings/utils/providerUtils.ts | 36 ++---
.../src/context/ExtensionStateContext.tsx | 9 --
16 files changed, 97 insertions(+), 304 deletions(-)
diff --git a/cli/pkg/cli/task/settings_parser.go b/cli/pkg/cli/task/settings_parser.go
index caff15a3..c77b9128 100644
--- a/cli/pkg/cli/task/settings_parser.go
+++ b/cli/pkg/cli/task/settings_parser.go
@@ -180,8 +180,6 @@ func setSimpleField(settings *cline.Settings, key, value string) error {
settings.PlanModeHuaweiCloudMaasModelId = strPtr(value)
case "plan_mode_oca_model_id":
settings.PlanModeOcaModelId = strPtr(value)
- case "plan_mode_vercel_ai_gateway_model_id":
- settings.PlanModeVercelAiGatewayModelId = strPtr(value)
case "act_mode_api_model_id":
settings.ActModeApiModelId = strPtr(value)
case "act_mode_reasoning_effort":
@@ -218,8 +216,6 @@ func setSimpleField(settings *cline.Settings, key, value string) error {
settings.ActModeHuaweiCloudMaasModelId = strPtr(value)
case "act_mode_oca_model_id":
settings.ActModeOcaModelId = strPtr(value)
- case "act_mode_vercel_ai_gateway_model_id":
- settings.ActModeVercelAiGatewayModelId = strPtr(value)
// Boolean fields
case "aws_use_cross_region_inference":
@@ -736,8 +732,6 @@ func setSecretField(secrets *cline.Secrets, key, value string) error {
secrets.HuaweiCloudMaasApiKey = strPtr(value)
case "baseten_api_key":
secrets.BasetenApiKey = strPtr(value)
- case "vercel_ai_gateway_api_key":
- secrets.VercelAiGatewayApiKey = strPtr(value)
case "dify_api_key":
secrets.DifyApiKey = strPtr(value)
case "oca_api_key":
diff --git a/proto/cline/models.proto b/proto/cline/models.proto
index 78aa2026..8834427f 100644
--- a/proto/cline/models.proto
+++ b/proto/cline/models.proto
@@ -23,8 +23,6 @@ service ModelsService {
rpc refreshHuggingFaceModels(EmptyRequest) returns (OpenRouterCompatibleModelInfo);
// Refreshes and returns OpenAI models
rpc refreshOpenAiModels(OpenAiModelsRequest) returns (StringArray);
- // Refreshes and returns Vercel AI Gateway models
- rpc refreshVercelAiGatewayModelsRpc(EmptyRequest) returns (OpenRouterCompatibleModelInfo);
// Refreshes and returns Requesty models
rpc refreshRequestyModels(EmptyRequest) returns (OpenRouterCompatibleModelInfo);
// Refreshes and returns Hicap models
diff --git a/src/core/api/index.ts b/src/core/api/index.ts
index 82edc858..62d7a3aa 100644
--- a/src/core/api/index.ts
+++ b/src/core/api/index.ts
@@ -367,10 +367,10 @@ function createHandlerForProvider(
return new VercelAIGatewayHandler({
onRetryAttempt: options.onRetryAttempt,
vercelAiGatewayApiKey: options.vercelAiGatewayApiKey,
- vercelAiGatewayModelId:
- mode === "plan" ? options.planModeVercelAiGatewayModelId : options.actModeVercelAiGatewayModelId,
- vercelAiGatewayModelInfo:
- mode === "plan" ? options.planModeVercelAiGatewayModelInfo : options.actModeVercelAiGatewayModelInfo,
+ openRouterModelId: mode === "plan" ? options.planModeOpenRouterModelId : options.actModeOpenRouterModelId,
+ openRouterModelInfo: mode === "plan" ? options.planModeOpenRouterModelInfo : options.actModeOpenRouterModelInfo,
+ thinkingBudgetTokens:
+ mode === "plan" ? options.planModeThinkingBudgetTokens : options.actModeThinkingBudgetTokens,
})
case "zai":
return new ZAiHandler({
diff --git a/src/core/api/providers/vercel-ai-gateway.ts b/src/core/api/providers/vercel-ai-gateway.ts
index 42644cd0..f190554e 100644
--- a/src/core/api/providers/vercel-ai-gateway.ts
+++ b/src/core/api/providers/vercel-ai-gateway.ts
@@ -1,5 +1,5 @@
import { Anthropic } from "@anthropic-ai/sdk"
-import { ModelInfo, vercelAiGatewayDefaultModelId, vercelAiGatewayDefaultModelInfo } from "@shared/api"
+import { ModelInfo, openRouterDefaultModelId, openRouterDefaultModelInfo } from "@shared/api"
import OpenAI from "openai"
import type { ChatCompletionTool as OpenAITool } from "openai/resources/chat/completions"
import { fetch } from "@/shared/net"
@@ -11,8 +11,9 @@ import { createVercelAIGatewayStream } from "../transform/vercel-ai-gateway-stre
interface VercelAIGatewayHandlerOptions extends CommonApiHandlerOptions {
vercelAiGatewayApiKey?: string
- vercelAiGatewayModelId?: string
- vercelAiGatewayModelInfo?: ModelInfo
+ openRouterModelId?: string
+ openRouterModelInfo?: ModelInfo
+ thinkingBudgetTokens?: number
}
export class VercelAIGatewayHandler implements ApiHandler {
@@ -57,6 +58,7 @@ export class VercelAIGatewayHandler implements ApiHandler {
systemPrompt,
messages,
{ id: modelId, info: modelInfo },
+ this.options.thinkingBudgetTokens,
tools,
)
let didOutputUsage: boolean = false
@@ -76,6 +78,28 @@ export class VercelAIGatewayHandler implements ApiHandler {
yield* toolCallProcessor.processToolCallDeltas(delta.tool_calls)
}
+ // Reasoning tokens are returned separately from the content
+ if ("reasoning" in delta && delta.reasoning) {
+ yield {
+ type: "reasoning",
+ // @ts-ignore-next-line
+ reasoning: delta.reasoning,
+ }
+ }
+
+ // Reasoning details that can be passed back in API requests to preserve reasoning traces
+ if (
+ "reasoning_details" in delta &&
+ delta.reasoning_details &&
+ // @ts-ignore-next-line
+ delta.reasoning_details.length // exists and non-0
+ ) {
+ yield {
+ type: "reasoning_details",
+ reasoning_details: delta.reasoning_details,
+ }
+ }
+
if (!didOutputUsage && chunk.usage) {
const inputTokens = chunk.usage.prompt_tokens || 0
const outputTokens =
@@ -109,11 +133,11 @@ export class VercelAIGatewayHandler implements ApiHandler {
}
getModel(): { id: string; info: ModelInfo } {
- const modelId = this.options.vercelAiGatewayModelId
- const modelInfo = this.options.vercelAiGatewayModelInfo
+ const modelId = this.options.openRouterModelId
+ const modelInfo = this.options.openRouterModelInfo
if (modelId && modelInfo) {
return { id: modelId, info: modelInfo }
}
- return { id: vercelAiGatewayDefaultModelId, info: vercelAiGatewayDefaultModelInfo }
+ return { id: openRouterDefaultModelId, info: openRouterDefaultModelInfo }
}
}
diff --git a/src/core/api/transform/vercel-ai-gateway-stream.ts b/src/core/api/transform/vercel-ai-gateway-stream.ts
index 1a0c108e..be573ef1 100644
--- a/src/core/api/transform/vercel-ai-gateway-stream.ts
+++ b/src/core/api/transform/vercel-ai-gateway-stream.ts
@@ -1,5 +1,10 @@
import { Anthropic } from "@anthropic-ai/sdk"
-import { ModelInfo } from "@shared/api"
+import {
+ CLAUDE_SONNET_1M_SUFFIX,
+ ModelInfo,
+ openRouterClaudeSonnet41mModelId,
+ openRouterClaudeSonnet451mModelId,
+} from "@shared/api"
import OpenAI from "openai"
import type { ChatCompletionTool as OpenAITool } from "openai/resources/chat/completions"
import { convertToOpenAiMessages } from "../transform/openai-format"
@@ -10,6 +15,7 @@ export async function createVercelAIGatewayStream(
systemPrompt: string,
messages: Anthropic.Messages.MessageParam[],
model: { id: string; info: ModelInfo },
+ thinkingBudgetTokens?: number,
tools?: OpenAITool[],
) {
// Convert Anthropic messages to OpenAI format
@@ -18,9 +24,15 @@ export async function createVercelAIGatewayStream(
...convertToOpenAiMessages(messages),
]
+ const isClaudeSonnet1m = model.id === openRouterClaudeSonnet41mModelId || model.id === openRouterClaudeSonnet451mModelId
+ if (isClaudeSonnet1m) {
+ // remove the custom :1m suffix, to create the model id openrouter API expects
+ model.id = model.id.slice(0, -CLAUDE_SONNET_1M_SUFFIX.length)
+ }
+
const isAnthropicModel = model.id.startsWith("anthropic/")
- if (isAnthropicModel && model.info.supportsPromptCache) {
+ if (isAnthropicModel) {
openAiMessages[0] = {
role: "system",
content: systemPrompt,
@@ -46,12 +58,32 @@ export async function createVercelAIGatewayStream(
})
}
+ // Configure reasoning parameters similar to OpenRouter
+ let temperature: number | undefined = 0
+ let reasoning: { max_tokens: number } | undefined
+
+ if (isAnthropicModel) {
+ const budget_tokens = thinkingBudgetTokens || 0
+ const reasoningOn = budget_tokens !== 0
+ if (reasoningOn) {
+ temperature = undefined // extended thinking does not support non-1 temperature
+ reasoning = { max_tokens: budget_tokens }
+ }
+ } else if (thinkingBudgetTokens && model.info?.thinkingConfig && thinkingBudgetTokens > 0) {
+ temperature = undefined // extended thinking does not support non-1 temperature
+ reasoning = { max_tokens: thinkingBudgetTokens }
+ }
+
+ // @ts-ignore-next-line
const stream = await client.chat.completions.create({
model: model.id,
max_tokens: model.info.maxTokens,
- temperature: 0.7,
+ temperature: temperature,
messages: openAiMessages,
stream: true,
+ stream_options: { include_usage: true },
+ include_reasoning: true,
+ ...(reasoning ? { reasoning } : {}),
...getOpenAIToolParams(tools),
})
diff --git a/src/core/controller/index.ts b/src/core/controller/index.ts
index 5ef2af17..b8463ed1 100644
--- a/src/core/controller/index.ts
+++ b/src/core/controller/index.ts
@@ -764,17 +764,6 @@ export class Controller {
return undefined
}
- // Read Vercel AI Gateway models from disk cache
- async readVercelAiGatewayModels(): Promise | undefined> {
- const vercelAiGatewayModelsFilePath = path.join(await ensureCacheDirectoryExists(), GlobalFileNames.vercelAiGatewayModels)
- const fileExists = await fileExistsAtPath(vercelAiGatewayModelsFilePath)
- if (fileExists) {
- const fileContents = await fs.readFile(vercelAiGatewayModelsFilePath, "utf8")
- return JSON.parse(fileContents)
- }
- return undefined
- }
-
// Task history
async getTaskWithId(id: string): Promise<{
diff --git a/src/core/controller/ui/initializeWebview.ts b/src/core/controller/ui/initializeWebview.ts
index 333ee560..8dee9ba8 100644
--- a/src/core/controller/ui/initializeWebview.ts
+++ b/src/core/controller/ui/initializeWebview.ts
@@ -9,7 +9,6 @@ import { refreshBasetenModels } from "../models/refreshBasetenModels"
import { refreshGroqModels } from "../models/refreshGroqModels"
import { refreshHicapModels } from "../models/refreshHicapModels"
import { refreshOpenRouterModels } from "../models/refreshOpenRouterModels"
-import { refreshVercelAiGatewayModels } from "../models/refreshVercelAiGatewayModels"
import { sendOpenRouterModelsEvent } from "../models/subscribeToOpenRouterModels"
/**
@@ -152,51 +151,6 @@ export async function initializeWebview(controller: Controller, _request: EmptyR
}
})
- // Refresh Vercel AI Gateway models from API
- refreshVercelAiGatewayModels(controller).then(async (models) => {
- if (models && Object.keys(models).length > 0) {
- // Update model info in state for Vercel AI Gateway (this needs to be done here since we don't want to update state while settings is open, and we may refresh models there)
- const apiConfiguration = controller.stateManager.getApiConfiguration()
- const planActSeparateModelsSetting = controller.stateManager.getGlobalSettingsKey("planActSeparateModelsSetting")
- const currentMode = controller.stateManager.getGlobalSettingsKey("mode")
-
- if (planActSeparateModelsSetting) {
- // Separate models: update only current mode
- const modelIdField =
- currentMode === "plan" ? "planModeVercelAiGatewayModelId" : "actModeVercelAiGatewayModelId"
- const modelInfoField =
- currentMode === "plan" ? "planModeVercelAiGatewayModelInfo" : "actModeVercelAiGatewayModelInfo"
- const modelId = apiConfiguration[modelIdField]
-
- if (modelId && models[modelId]) {
- controller.stateManager.setGlobalState(modelInfoField, models[modelId])
- await controller.postStateToWebview()
- }
- } else {
- // Shared models: update both plan and act modes
- const planModelId = apiConfiguration.planModeVercelAiGatewayModelId
- const actModelId = apiConfiguration.actModeVercelAiGatewayModelId
- const updates: Partial = {}
-
- // Update plan mode model info if we have a model ID
- if (planModelId && models[planModelId]) {
- updates.planModeVercelAiGatewayModelInfo = models[planModelId]
- }
-
- // Update act mode model info if we have a model ID
- if (actModelId && models[actModelId]) {
- updates.actModeVercelAiGatewayModelInfo = models[actModelId]
- }
-
- // Post state update if we updated any model info
- if (Object.keys(updates).length > 0) {
- controller.stateManager.setGlobalStateBatch(updates)
- await controller.postStateToWebview()
- }
- }
- }
- })
-
// Refresh Hicap models from API
refreshHicapModels(controller, EmptyRequest.create()).then(async (response) => {
if (response && response.models) {
diff --git a/src/core/storage/StateManager.ts b/src/core/storage/StateManager.ts
index c775db0b..01afe815 100644
--- a/src/core/storage/StateManager.ts
+++ b/src/core/storage/StateManager.ts
@@ -530,8 +530,6 @@ export class StateManager {
planModeHuggingFaceModelInfo,
planModeHuaweiCloudMaasModelId,
planModeHuaweiCloudMaasModelInfo,
- planModeVercelAiGatewayModelId,
- planModeVercelAiGatewayModelInfo,
planModeOcaModelId,
planModeOcaModelInfo,
planModeHicapModelId,
@@ -568,8 +566,6 @@ export class StateManager {
actModeHuggingFaceModelInfo,
actModeHuaweiCloudMaasModelId,
actModeHuaweiCloudMaasModelInfo,
- actModeVercelAiGatewayModelId,
- actModeVercelAiGatewayModelInfo,
actModeOcaModelId,
actModeOcaModelInfo,
actModeHicapModelId,
@@ -610,8 +606,6 @@ export class StateManager {
planModeHuggingFaceModelInfo,
planModeHuaweiCloudMaasModelId,
planModeHuaweiCloudMaasModelInfo,
- planModeVercelAiGatewayModelId,
- planModeVercelAiGatewayModelInfo,
planModeOcaModelId,
planModeOcaModelInfo,
planModeHicapModelId,
@@ -647,8 +641,6 @@ export class StateManager {
actModeHuggingFaceModelInfo,
actModeHuaweiCloudMaasModelId,
actModeHuaweiCloudMaasModelInfo,
- actModeVercelAiGatewayModelId,
- actModeVercelAiGatewayModelInfo,
actModeOcaModelId,
actModeOcaModelInfo,
actModeHicapModelId,
@@ -1150,11 +1142,6 @@ export class StateManager {
planModeHuaweiCloudMaasModelInfo:
this.taskStateCache["planModeHuaweiCloudMaasModelInfo"] ||
this.globalStateCache["planModeHuaweiCloudMaasModelInfo"],
- planModeVercelAiGatewayModelId:
- this.taskStateCache["planModeVercelAiGatewayModelId"] || this.globalStateCache["planModeVercelAiGatewayModelId"],
- planModeVercelAiGatewayModelInfo:
- this.taskStateCache["planModeVercelAiGatewayModelInfo"] ||
- this.globalStateCache["planModeVercelAiGatewayModelInfo"],
planModeOcaModelId: this.globalStateCache["planModeOcaModelId"],
planModeOcaModelInfo: this.globalStateCache["planModeOcaModelInfo"],
planModeHicapModelId: this.taskStateCache["planModeHicapModelId"] || this.globalStateCache["planModeHicapModelId"],
@@ -1222,11 +1209,6 @@ export class StateManager {
actModeHuaweiCloudMaasModelInfo:
this.taskStateCache["actModeHuaweiCloudMaasModelInfo"] ||
this.globalStateCache["actModeHuaweiCloudMaasModelInfo"],
- actModeVercelAiGatewayModelId:
- this.taskStateCache["actModeVercelAiGatewayModelId"] || this.globalStateCache["actModeVercelAiGatewayModelId"],
- actModeVercelAiGatewayModelInfo:
- this.taskStateCache["actModeVercelAiGatewayModelInfo"] ||
- this.globalStateCache["actModeVercelAiGatewayModelInfo"],
actModeOcaModelId: this.globalStateCache["actModeOcaModelId"],
actModeOcaModelInfo: this.globalStateCache["actModeOcaModelInfo"],
actModeHicapModelId: this.globalStateCache["actModeHicapModelId"],
diff --git a/src/core/storage/utils/state-helpers.ts b/src/core/storage/utils/state-helpers.ts
index 06b06c4f..f7f99777 100644
--- a/src/core/storage/utils/state-helpers.ts
+++ b/src/core/storage/utils/state-helpers.ts
@@ -369,11 +369,6 @@ export async function readGlobalStateFromDisk(context: ExtensionContext): Promis
context.globalState.get("planModeBasetenModelId")
const planModeBasetenModelInfo =
context.globalState.get("planModeBasetenModelInfo")
- const planModeVercelAiGatewayModelId =
- context.globalState.get("planModeVercelAiGatewayModelId")
- const planModeVercelAiGatewayModelInfo = context.globalState.get<
- GlobalStateAndSettings["planModeVercelAiGatewayModelInfo"]
- >("planModeVercelAiGatewayModelInfo")
const planModeOcaModelId = context.globalState.get("planModeOcaModelId") as string | undefined
const planModeOcaModelInfo = context.globalState.get("planModeOcaModelInfo") as OcaModelInfo | undefined
const planModeHicapModelId =
@@ -443,11 +438,6 @@ export async function readGlobalStateFromDisk(context: ExtensionContext): Promis
context.globalState.get("actModeBasetenModelId")
const actModeBasetenModelInfo =
context.globalState.get("actModeBasetenModelInfo")
- const actModeVercelAiGatewayModelId =
- context.globalState.get("actModeVercelAiGatewayModelId")
- const actModeVercelAiGatewayModelInfo = context.globalState.get<
- GlobalStateAndSettings["actModeVercelAiGatewayModelInfo"]
- >("actModeVercelAiGatewayModelInfo")
const actModeOcaModelId = context.globalState.get("actModeOcaModelId") as string | undefined
const actModeOcaModelInfo = context.globalState.get("actModeOcaModelInfo") as OcaModelInfo | undefined
const sapAiCoreUseOrchestrationMode =
@@ -573,8 +563,6 @@ export async function readGlobalStateFromDisk(context: ExtensionContext): Promis
planModeHuaweiCloudMaasModelInfo,
planModeBasetenModelId,
planModeBasetenModelInfo,
- planModeVercelAiGatewayModelId,
- planModeVercelAiGatewayModelInfo,
planModeOcaModelId,
planModeOcaModelInfo,
planModeHicapModelId,
@@ -611,8 +599,6 @@ export async function readGlobalStateFromDisk(context: ExtensionContext): Promis
actModeHuaweiCloudMaasModelInfo,
actModeBasetenModelId,
actModeBasetenModelInfo,
- actModeVercelAiGatewayModelId,
- actModeVercelAiGatewayModelInfo,
actModeOcaModelId,
actModeOcaModelInfo,
actModeHicapModelId,
diff --git a/src/shared/api.ts b/src/shared/api.ts
index b00b61f9..f7c51c88 100644
--- a/src/shared/api.ts
+++ b/src/shared/api.ts
@@ -164,8 +164,6 @@ export interface ApiHandlerOptions {
planModeHuggingFaceModelInfo?: ModelInfo
planModeHuaweiCloudMaasModelId?: string
planModeHuaweiCloudMaasModelInfo?: ModelInfo
- planModeVercelAiGatewayModelId?: string
- planModeVercelAiGatewayModelInfo?: ModelInfo
planModeOcaModelId?: string
planModeOcaModelInfo?: OcaModelInfo
planModeAihubmixModelId?: string
@@ -203,8 +201,6 @@ export interface ApiHandlerOptions {
actModeHuggingFaceModelInfo?: ModelInfo
actModeHuaweiCloudMaasModelId?: string
actModeHuaweiCloudMaasModelInfo?: ModelInfo
- actModeVercelAiGatewayModelId?: string
- actModeVercelAiGatewayModelInfo?: ModelInfo
actModeOcaModelId?: string
actModeOcaModelInfo?: OcaModelInfo
actModeAihubmixModelId?: string
@@ -3101,23 +3097,6 @@ export const cerebrasModels = {
},
} as const satisfies Record
-// VERCEL AI GATEWAY MODELS
-export type VercelAIGatewayModelId = string
-
-export const vercelAiGatewayDefaultModelId = "anthropic/claude-sonnet-4"
-export const vercelAiGatewayDefaultModelInfo: ModelInfo = {
- maxTokens: 64_000,
- contextWindow: 200_000,
- supportsImages: true,
- supportsPromptCache: true,
- inputPrice: 3.0,
- outputPrice: 15.0,
- cacheWritesPrice: 3.75,
- cacheReadsPrice: 0.3,
- description:
- "Claude Sonnet 4 delivers superior intelligence across coding, agentic search, and AI agent capabilities. It's a powerful choice for agentic coding, and can complete tasks across the entire software development lifecycle—from initial planning to bug fixes, maintenance to large refactors. It offers strong performance in both planning and solving for complex coding tasks, making it an ideal choice to power end-to-end software development processes.\n\nRead more in the [blog post here](https://www.anthropic.com/claude/sonnet)",
-}
-
// Groq
// https://console.groq.com/docs/models
// https://groq.com/pricing/
diff --git a/src/shared/proto-conversions/models/api-configuration-conversion.ts b/src/shared/proto-conversions/models/api-configuration-conversion.ts
index 1dc2c236..4a3f9e64 100644
--- a/src/shared/proto-conversions/models/api-configuration-conversion.ts
+++ b/src/shared/proto-conversions/models/api-configuration-conversion.ts
@@ -520,8 +520,6 @@ export function convertApiConfigurationToProto(config: ApiConfiguration): ProtoA
planModeHuaweiCloudMaasModelId: config.planModeHuaweiCloudMaasModelId,
planModeHuaweiCloudMaasModelInfo: convertModelInfoToProtoOpenRouter(config.planModeHuaweiCloudMaasModelInfo),
planModeSapAiCoreDeploymentId: config.planModeSapAiCoreDeploymentId,
- planModeVercelAiGatewayModelId: config.planModeVercelAiGatewayModelId,
- planModeVercelAiGatewayModelInfo: convertModelInfoToProtoOpenRouter(config.planModeVercelAiGatewayModelInfo),
planModeOcaModelId: config.planModeOcaModelId,
planModeOcaModelInfo: convertOcaModelInfoToProtoOcaModelInfo(config.planModeOcaModelInfo),
planModeAihubmixModelId: config.planModeAihubmixModelId,
@@ -559,8 +557,6 @@ export function convertApiConfigurationToProto(config: ApiConfiguration): ProtoA
actModeHuaweiCloudMaasModelId: config.actModeHuaweiCloudMaasModelId,
actModeHuaweiCloudMaasModelInfo: convertModelInfoToProtoOpenRouter(config.actModeHuaweiCloudMaasModelInfo),
actModeSapAiCoreDeploymentId: config.actModeSapAiCoreDeploymentId,
- actModeVercelAiGatewayModelId: config.actModeVercelAiGatewayModelId,
- actModeVercelAiGatewayModelInfo: convertModelInfoToProtoOpenRouter(config.actModeVercelAiGatewayModelInfo),
actModeOcaModelId: config.actModeOcaModelId,
actModeOcaModelInfo: convertOcaModelInfoToProtoOcaModelInfo(config.actModeOcaModelInfo),
actModeAihubmixModelId: config.actModeAihubmixModelId,
@@ -689,8 +685,6 @@ export function convertProtoToApiConfiguration(protoConfig: ProtoApiConfiguratio
planModeHuaweiCloudMaasModelId: protoConfig.planModeHuaweiCloudMaasModelId,
planModeHuaweiCloudMaasModelInfo: convertProtoToModelInfo(protoConfig.planModeHuaweiCloudMaasModelInfo),
planModeSapAiCoreDeploymentId: protoConfig.planModeSapAiCoreDeploymentId,
- planModeVercelAiGatewayModelId: protoConfig.planModeVercelAiGatewayModelId,
- planModeVercelAiGatewayModelInfo: convertProtoToModelInfo(protoConfig.planModeVercelAiGatewayModelInfo),
planModeOcaModelId: protoConfig.planModeOcaModelId,
planModeOcaModelInfo: convertProtoOcaModelInfoToOcaModelInfo(protoConfig.planModeOcaModelInfo),
planModeAihubmixModelId: protoConfig.planModeAihubmixModelId,
@@ -729,8 +723,6 @@ export function convertProtoToApiConfiguration(protoConfig: ProtoApiConfiguratio
actModeHuaweiCloudMaasModelId: protoConfig.actModeHuaweiCloudMaasModelId,
actModeHuaweiCloudMaasModelInfo: convertProtoToModelInfo(protoConfig.actModeHuaweiCloudMaasModelInfo),
actModeSapAiCoreDeploymentId: protoConfig.actModeSapAiCoreDeploymentId,
- actModeVercelAiGatewayModelId: protoConfig.actModeVercelAiGatewayModelId,
- actModeVercelAiGatewayModelInfo: convertProtoToModelInfo(protoConfig.actModeVercelAiGatewayModelInfo),
actModeOcaModelId: protoConfig.actModeOcaModelId,
actModeOcaModelInfo: convertProtoOcaModelInfoToOcaModelInfo(protoConfig.actModeOcaModelInfo),
actModeAihubmixModelId: protoConfig.actModeAihubmixModelId,
diff --git a/src/shared/storage/state-keys.ts b/src/shared/storage/state-keys.ts
index ced9dc9d..2d96a850 100644
--- a/src/shared/storage/state-keys.ts
+++ b/src/shared/storage/state-keys.ts
@@ -188,10 +188,6 @@ export interface Settings {
actModeHuggingFaceModelInfo: ModelInfo | undefined
actModeHuaweiCloudMaasModelId: string | undefined
actModeHuaweiCloudMaasModelInfo: ModelInfo | undefined
- planModeVercelAiGatewayModelId: string | undefined
- planModeVercelAiGatewayModelInfo: ModelInfo | undefined
- actModeVercelAiGatewayModelId: string | undefined
- actModeVercelAiGatewayModelInfo: ModelInfo | undefined
actModeOcaModelId: string | undefined
actModeOcaModelInfo: OcaModelInfo | undefined
actModeHicapModelId: string | undefined
diff --git a/webview-ui/src/components/settings/OpenRouterModelPicker.tsx b/webview-ui/src/components/settings/OpenRouterModelPicker.tsx
index c71a0520..aff9fbca 100644
--- a/webview-ui/src/components/settings/OpenRouterModelPicker.tsx
+++ b/webview-ui/src/components/settings/OpenRouterModelPicker.tsx
@@ -147,7 +147,7 @@ const OpenRouterModelPicker: React.FC = ({ isPopup,
return !id.includes(":free")
})
}
- // For OpenRouter provider: exclude Cline-specific models
+ // For OpenRouter and Vercel AI Gateway providers: exclude Cline-specific models
return unfilteredModelIds.filter((id) => !id.startsWith("cline/"))
}, [openRouterModels, modeFields.apiProvider])
@@ -423,7 +423,7 @@ const OpenRouterModelPicker: React.FC = ({ isPopup,
anthropic/claude-sonnet-4.5.
You can also try searching "free" for no-cost options currently available. OpenRouter presets can be used by
- entering @preset/your-preset-name.
+ entering @preset/your-preset-name
)}
diff --git a/webview-ui/src/components/settings/providers/VercelAIGatewayProvider.tsx b/webview-ui/src/components/settings/providers/VercelAIGatewayProvider.tsx
index 00c6bb25..a5559fa1 100644
--- a/webview-ui/src/components/settings/providers/VercelAIGatewayProvider.tsx
+++ b/webview-ui/src/components/settings/providers/VercelAIGatewayProvider.tsx
@@ -1,14 +1,8 @@
-import { EmptyRequest } from "@shared/proto/cline/common"
-import { fromProtobufModels } from "@shared/proto-conversions/models/typeConversion"
import { Mode } from "@shared/storage/types"
-import { useCallback, useMemo, useState } from "react"
-import { useMount } from "react-use"
+import { VSCodeLink } from "@vscode/webview-ui-toolkit/react"
import { useExtensionState } from "@/context/ExtensionStateContext"
-import { ModelsServiceClient } from "@/services/grpc-client"
import { DebouncedTextField } from "../common/DebouncedTextField"
-import { ModelInfoView } from "../common/ModelInfoView"
-import { ModelSelector } from "../common/ModelSelector"
-import { normalizeApiConfiguration } from "../utils/providerUtils"
+import OpenRouterModelPicker from "../OpenRouterModelPicker"
import { useApiConfigurationHandlers } from "../utils/useApiConfigurationHandlers"
/**
@@ -24,62 +18,8 @@ interface VercelAIGatewayProviderProps {
* The Vercel AI Gateway provider configuration component
*/
export const VercelAIGatewayProvider = ({ showModelOptions, isPopup, currentMode }: VercelAIGatewayProviderProps) => {
- const { apiConfiguration, vercelAiGatewayModels, setVercelAiGatewayModels } = useExtensionState()
- const { handleFieldChange, handleModeFieldsChange } = useApiConfigurationHandlers()
- const [isLoadingModels, setIsLoadingModels] = useState(false)
-
- // Get the normalized configuration (includes defaults)
- const { selectedModelId, selectedModelInfo } = normalizeApiConfiguration(apiConfiguration, currentMode)
-
- // Fetch models only once when component mounts
- useMount(() => {
- if (showModelOptions) {
- setIsLoadingModels(true)
- ModelsServiceClient.refreshVercelAiGatewayModelsRpc(EmptyRequest.create({}))
- .then((response) => {
- if (response && response.models) {
- setVercelAiGatewayModels(fromProtobufModels(response.models))
- }
- setIsLoadingModels(false)
- })
- .catch((error) => {
- console.error("Failed to fetch Vercel AI Gateway models:", error)
- setVercelAiGatewayModels({})
- setIsLoadingModels(false)
- })
- }
- })
-
- const handleModelChange = useCallback(
- (modelId: string) => {
- handleModeFieldsChange(
- {
- vercelAiGatewayModelId: { plan: "planModeVercelAiGatewayModelId", act: "actModeVercelAiGatewayModelId" },
- vercelAiGatewayModelInfo: {
- plan: "planModeVercelAiGatewayModelInfo",
- act: "actModeVercelAiGatewayModelInfo",
- },
- },
- {
- vercelAiGatewayModelId: modelId,
- vercelAiGatewayModelInfo: vercelAiGatewayModels[modelId],
- },
- currentMode,
- )
- },
- [vercelAiGatewayModels, handleModeFieldsChange, currentMode],
- )
-
- const hasModels = useMemo(() => {
- return Object.keys(vercelAiGatewayModels).length > 0
- }, [vercelAiGatewayModels])
-
- const displayModelInfo = useMemo(() => {
- if (hasModels && selectedModelId && vercelAiGatewayModels[selectedModelId]) {
- return vercelAiGatewayModels[selectedModelId]
- }
- return selectedModelInfo
- }, [hasModels, selectedModelId, vercelAiGatewayModels, selectedModelInfo])
+ const { apiConfiguration } = useExtensionState()
+ const { handleFieldChange } = useApiConfigurationHandlers()
return (
@@ -95,81 +35,27 @@ export const VercelAIGatewayProvider = ({ showModelOptions, isPopup, currentMode
This key is stored locally and only used to make API requests from this extension.
{!apiConfiguration?.vercelAiGatewayApiKey && (
-
+ <>
{" "}
-
- You can get a Vercel AI Gateway API key by signing up here.
-
-
+ style={{ display: "inline", fontSize: "inherit" }}>
+ signing up here.
+
+ >
)}
{showModelOptions && (
<>
- {hasModels ? (
- handleModelChange(e.target.value)}
- selectedModelId={selectedModelId || ""}
- />
- ) : (
- <>
-
- handleModeFieldsChange(
- {
- vercelAiGatewayModelId: {
- plan: "planModeVercelAiGatewayModelId",
- act: "actModeVercelAiGatewayModelId",
- },
- vercelAiGatewayModelInfo: {
- plan: "planModeVercelAiGatewayModelInfo",
- act: "actModeVercelAiGatewayModelInfo",
- },
- },
- {
- vercelAiGatewayModelId: value,
- vercelAiGatewayModelInfo: undefined,
- },
- currentMode,
- )
- }
- placeholder={"Enter Model ID (e.g., openai/gpt-4o)..."}
- style={{ width: "100%", marginBottom: 10 }}>
- Model ID
-
-
- {!isLoadingModels && (
-
- Unable to fetch models from Vercel AI Gateway.
-
- )}
- >
- )}
-
- {displayModelInfo && (
-
- )}
+
>
)}
diff --git a/webview-ui/src/components/settings/utils/providerUtils.ts b/webview-ui/src/components/settings/utils/providerUtils.ts
index d49a35b4..c454883a 100644
--- a/webview-ui/src/components/settings/utils/providerUtils.ts
+++ b/webview-ui/src/components/settings/utils/providerUtils.ts
@@ -59,8 +59,6 @@ import {
sambanovaModels,
sapAiCoreDefaultModelId,
sapAiCoreModels,
- vercelAiGatewayDefaultModelId,
- vercelAiGatewayDefaultModelInfo,
vertexDefaultModelId,
vertexModels,
xaiDefaultModelId,
@@ -331,18 +329,17 @@ export function normalizeApiConfiguration(
},
}
case "vercel-ai-gateway":
- const vercelAiGatewayModelId =
+ // Vercel AI Gateway uses OpenRouter model fields
+ const vercelModelId =
+ currentMode === "plan" ? apiConfiguration?.planModeOpenRouterModelId : apiConfiguration?.actModeOpenRouterModelId
+ const vercelModelInfo =
currentMode === "plan"
- ? apiConfiguration?.planModeVercelAiGatewayModelId
- : apiConfiguration?.actModeVercelAiGatewayModelId
- const vercelAiGatewayModelInfo =
- currentMode === "plan"
- ? apiConfiguration?.planModeVercelAiGatewayModelInfo
- : apiConfiguration?.actModeVercelAiGatewayModelInfo
+ ? apiConfiguration?.planModeOpenRouterModelInfo
+ : apiConfiguration?.actModeOpenRouterModelInfo
return {
selectedProvider: provider,
- selectedModelId: vercelAiGatewayModelId || vercelAiGatewayDefaultModelId,
- selectedModelInfo: vercelAiGatewayModelInfo || vercelAiGatewayDefaultModelInfo,
+ selectedModelId: vercelModelId || openRouterDefaultModelId,
+ selectedModelInfo: vercelModelInfo || openRouterDefaultModelInfo,
}
case "zai":
const zaiModels = apiConfiguration?.zaiApiLine === "china" ? mainlandZAiModels : internationalZAiModels
@@ -412,7 +409,6 @@ export function getModeSpecificFields(apiConfiguration: ApiConfiguration | undef
basetenModelId: undefined,
huggingFaceModelId: undefined,
huaweiCloudMaasModelId: undefined,
- vercelAiGatewayModelId: undefined,
hicapModelId: undefined,
aihubmixModelId: undefined,
@@ -424,7 +420,6 @@ export function getModeSpecificFields(apiConfiguration: ApiConfiguration | undef
groqModelInfo: undefined,
basetenModelInfo: undefined,
huggingFaceModelInfo: undefined,
- vercelAiGatewayModelInfo: undefined,
vsCodeLmModelSelector: undefined,
aihubmixModelInfo: undefined,
@@ -462,8 +457,6 @@ export function getModeSpecificFields(apiConfiguration: ApiConfiguration | undef
mode === "plan" ? apiConfiguration.planModeHuggingFaceModelId : apiConfiguration.actModeHuggingFaceModelId,
huaweiCloudMaasModelId:
mode === "plan" ? apiConfiguration.planModeHuaweiCloudMaasModelId : apiConfiguration.actModeHuaweiCloudMaasModelId,
- vercelAiGatewayModelId:
- mode === "plan" ? apiConfiguration.planModeVercelAiGatewayModelId : apiConfiguration.actModeVercelAiGatewayModelId,
ocaModelId: mode === "plan" ? apiConfiguration.planModeOcaModelId : apiConfiguration.actModeOcaModelId,
hicapModelId: mode === "plan" ? apiConfiguration.planModeHicapModelId : apiConfiguration.actModeHicapModelId,
aihubmixModelId: mode === "plan" ? apiConfiguration.planModeAihubmixModelId : apiConfiguration.actModeAihubmixModelId,
@@ -479,10 +472,6 @@ export function getModeSpecificFields(apiConfiguration: ApiConfiguration | undef
basetenModelInfo: mode === "plan" ? apiConfiguration.planModeBasetenModelInfo : apiConfiguration.actModeBasetenModelInfo,
huggingFaceModelInfo:
mode === "plan" ? apiConfiguration.planModeHuggingFaceModelInfo : apiConfiguration.actModeHuggingFaceModelInfo,
- vercelAiGatewayModelInfo:
- mode === "plan"
- ? apiConfiguration.planModeVercelAiGatewayModelInfo
- : apiConfiguration.actModeVercelAiGatewayModelInfo,
vsCodeLmModelSelector:
mode === "plan" ? apiConfiguration.planModeVsCodeLmModelSelector : apiConfiguration.actModeVsCodeLmModelSelector,
hicapModelInfo: mode === "plan" ? apiConfiguration.planModeHicapModelInfo : apiConfiguration.actModeHicapModelInfo,
@@ -650,10 +639,11 @@ export async function syncModeConfigurations(
break
case "vercel-ai-gateway":
- updates.planModeVercelAiGatewayModelId = sourceFields.vercelAiGatewayModelId
- updates.actModeVercelAiGatewayModelId = sourceFields.vercelAiGatewayModelId
- updates.planModeVercelAiGatewayModelInfo = sourceFields.vercelAiGatewayModelInfo
- updates.actModeVercelAiGatewayModelInfo = sourceFields.vercelAiGatewayModelInfo
+ // Vercel AI Gateway uses OpenRouter model fields
+ updates.planModeOpenRouterModelId = sourceFields.openRouterModelId
+ updates.actModeOpenRouterModelId = sourceFields.openRouterModelId
+ updates.planModeOpenRouterModelInfo = sourceFields.openRouterModelInfo
+ updates.actModeOpenRouterModelInfo = sourceFields.openRouterModelInfo
break
case "oca":
updates.planModeOcaModelId = sourceFields.ocaModelId
diff --git a/webview-ui/src/context/ExtensionStateContext.tsx b/webview-ui/src/context/ExtensionStateContext.tsx
index d9254a62..dcf543d5 100644
--- a/webview-ui/src/context/ExtensionStateContext.tsx
+++ b/webview-ui/src/context/ExtensionStateContext.tsx
@@ -26,8 +26,6 @@ import {
openRouterDefaultModelInfo,
requestyDefaultModelId,
requestyDefaultModelInfo,
- vercelAiGatewayDefaultModelId,
- vercelAiGatewayDefaultModelInfo,
} from "../../../src/shared/api"
import type { McpMarketplaceCatalog, McpServer, McpViewTab } from "../../../src/shared/mcp"
import { McpServiceClient, ModelsServiceClient, StateServiceClient, UiServiceClient } from "../services/grpc-client"
@@ -42,7 +40,6 @@ export interface ExtensionStateContextType extends ExtensionState {
groqModels: Record
basetenModels: Record
huggingFaceModels: Record
- vercelAiGatewayModels: Record
mcpServers: McpServer[]
mcpMarketplaceCatalog: McpMarketplaceCatalog
totalTasksSize: number | null
@@ -71,7 +68,6 @@ export interface ExtensionStateContextType extends ExtensionState {
setGroqModels: (value: Record) => void
setBasetenModels: (value: Record) => void
setHuggingFaceModels: (value: Record) => void
- setVercelAiGatewayModels: (value: Record) => void
setGlobalClineRulesToggles: (toggles: Record) => void
setLocalClineRulesToggles: (toggles: Record) => void
setLocalCursorRulesToggles: (toggles: Record) => void
@@ -257,9 +253,6 @@ export const ExtensionStateContextProvider: React.FC<{
[basetenDefaultModelId]: basetenModels[basetenDefaultModelId],
})
const [huggingFaceModels, setHuggingFaceModels] = useState>({})
- const [vercelAiGatewayModels, setVercelAiGatewayModels] = useState>({
- [vercelAiGatewayDefaultModelId]: vercelAiGatewayDefaultModelInfo,
- })
const [mcpServers, setMcpServers] = useState([])
const [mcpMarketplaceCatalog, setMcpMarketplaceCatalog] = useState({ items: [] })
@@ -658,7 +651,6 @@ export const ExtensionStateContextProvider: React.FC<{
groqModels: groqModelsState,
basetenModels: basetenModelsState,
huggingFaceModels,
- vercelAiGatewayModels,
mcpServers,
mcpMarketplaceCatalog,
totalTasksSize,
@@ -704,7 +696,6 @@ export const ExtensionStateContextProvider: React.FC<{
setGroqModels: (models: Record) => setGroqModels(models),
setBasetenModels: (models: Record) => setBasetenModels(models),
setHuggingFaceModels: (models: Record) => setHuggingFaceModels(models),
- setVercelAiGatewayModels: (models: Record) => setVercelAiGatewayModels(models),
setMcpMarketplaceCatalog: (catalog: McpMarketplaceCatalog) => setMcpMarketplaceCatalog(catalog),
setShowMcp,
closeMcpView,