Skip to content
2 changes: 1 addition & 1 deletion apps/web/src/app/api/openrouter/embeddings/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export async function POST(request: NextRequest): Promise<NextResponseType<unkno
const effectiveProvider = provider;

if (userByok && userByok.length > 0 && provider.id === 'vercel') {
requestBodyParsed.model = mapModelIdToVercel(requestBodyParsed.model);
requestBodyParsed.model = mapModelIdToVercel(requestBodyParsed.model, false);
}

const upstreamBody = buildUpstreamBody(requestBodyParsed);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/lib/ai-gateway/byok/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function getModelUserByokProviders(modelId: string): Promise<UserBy
return [];
}
const providers =
vercelModelMetadata[mapModelIdToVercel(modelId)]?.endpoints
vercelModelMetadata[mapModelIdToVercel(modelId, false)]?.endpoints
.map(ep => VercelUserByokInferenceProviderIdSchema.safeParse(ep.tag).data)
.filter(providerId => providerId !== undefined) ?? [];
if (providers.length === 0) {
Expand Down
8 changes: 6 additions & 2 deletions apps/web/src/lib/ai-gateway/providers/vercel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
VercelInferenceProviderConfig,
VercelProviderConfig,
} from '@/lib/ai-gateway/providers/openrouter/types';
import { isReasoningExplicitlyDisabled } from '@/lib/ai-gateway/providers/openrouter/request-helpers';
import { mapModelIdToVercel } from '@/lib/ai-gateway/providers/vercel/mapModelIdToVercel';
import { StoredModelSchema } from '@kilocode/db';
import * as z from 'zod';
Expand Down Expand Up @@ -73,7 +74,7 @@ export async function shouldRouteToVercel(
}

const vercelModels = await getVercelModels();
const vercelModelId = mapModelIdToVercel(requestedModel);
const vercelModelId = mapModelIdToVercel(requestedModel, isReasoningExplicitlyDisabled(request));
if (!vercelModels.includes(vercelModelId)) {
console.debug(`[shouldRouteToVercel] model not found in Vercel model list`);
return false;
Expand Down Expand Up @@ -135,7 +136,10 @@ export function applyVercelSettings(
requestToMutate: GatewayRequest,
userByok: BYOKResult[] | null
) {
requestToMutate.body.model = mapModelIdToVercel(requestedModel);
requestToMutate.body.model = mapModelIdToVercel(
requestedModel,
isReasoningExplicitlyDisabled(requestToMutate)
);

if (userByok) {
if (userByok.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ const vercelModelIdMapping: Record<string, string | undefined> = {
'qwen/qwen3-32b': 'alibaba/qwen-3-32b',
};

export function mapModelIdToVercel(modelId: string) {
export function mapModelIdToVercel(modelId: string, reasoningExplicitlyDisabled: boolean) {
const hardcodedVercelId = vercelModelIdMapping[modelId];
if (hardcodedVercelId) {
if (reasoningExplicitlyDisabled && hardcodedVercelId.endsWith('-reasoning')) {
return hardcodedVercelId.replace(/-reasoning$/, '-non-reasoning');
}
return hardcodedVercelId;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/routers/byok-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function fetchSupportedModels() {
result['codestral'] = ['Codestral (mistralai/codestral-2508)'];

for (const openRouterModel of Object.values(openRouterModelMetadata.data)) {
const vercelModel = vercelModelMetadata.data[mapModelIdToVercel(openRouterModel.id)];
const vercelModel = vercelModelMetadata.data[mapModelIdToVercel(openRouterModel.id, false)];
if (!vercelModel) continue;
if (vercelModel.id.includes('codestral')) continue;
if (vercelModel.type !== 'language') continue;
Expand Down
Loading