@@ -26,6 +26,7 @@ import { getVercelModels } from '@/lib/ai-gateway/providers/gateway-models-cache
2626import type { AnthropicProviderOptions } from '@ai-sdk/anthropic' ;
2727import { isFableModel } from '@/lib/ai-gateway/providers/anthropic.constants' ;
2828import { isDeepseekModel } from '@/lib/ai-gateway/providers/deepseek' ;
29+ import type { KiloExclusiveModel } from '@/lib/ai-gateway/providers/kilo-exclusive-model' ;
2930
3031const getVercelRoutingPercentage = createCachedFetch (
3132 async ( ) => {
@@ -38,21 +39,33 @@ const getVercelRoutingPercentage = createCachedFetch(
3839 DEFAULT_VERCEL_PERCENTAGE
3940) ;
4041
42+ function hasOpenRouterExclusiveProviderOptions ( request : GatewayRequest ) {
43+ if ( request . body . provider ?. data_collection === 'deny' ) {
44+ console . debug ( '[hasOpenRouterExclusiveProviderOptions] has data_collection==deny' ) ;
45+ return true ;
46+ }
47+ if ( ( request . body . provider ?. ignore ?. length ?? 0 ) > 0 ) {
48+ console . debug ( '[hasOpenRouterExclusiveProviderOptions] has ignore' ) ;
49+ return true ;
50+ }
51+ if ( request . body . provider ?. zdr ) {
52+ // there's a zeroDataRetention option on Vercel, but it works differently
53+ // ZDR has to be set manually per provider
54+ console . debug ( '[hasOpenRouterExclusiveProviderOptions] has zdr' ) ;
55+ return true ;
56+ }
57+ return false ;
58+ }
59+
4160export async function shouldRouteToVercel (
4261 requestedModel : string ,
62+ kiloExclusiveModel : KiloExclusiveModel | null ,
4363 request : GatewayRequest ,
4464 randomSeed : string
4565) {
46- if ( request . body . provider ?. data_collection === 'deny' ) {
47- console . debug (
48- `[shouldRouteToVercel] not routing to Vercel because data_collection=deny is not supported`
49- ) ;
50- return false ;
51- }
52-
53- if ( ( request . body . provider ?. ignore ?. length ?? 0 ) > 0 ) {
66+ if ( hasOpenRouterExclusiveProviderOptions ( request ) ) {
5467 console . debug (
55- ` [shouldRouteToVercel] not routing to Vercel because provider.ignore is not supported`
68+ ' [shouldRouteToVercel] not routing to Vercel because of unsupported provider options'
5669 ) ;
5770 return false ;
5871 }
@@ -64,7 +77,7 @@ export async function shouldRouteToVercel(
6477 return false ;
6578 }
6679
67- if ( isDeepseekModel ( requestedModel ) ) {
80+ if ( ! kiloExclusiveModel ?. flags . includes ( 'vercel-routing' ) && isDeepseekModel ( requestedModel ) ) {
6881 // https://kilo-code.slack.com/archives/C0A4SA041DE/p1781743079721409
6982 console . debug (
7083 '[shouldRouteToVercel] not routing to Vercel because some of its DeepSeek providers have tool call issues'
0 commit comments