Skip to content

Commit 1807c6a

Browse files
authored
Exclude ZDR from Vercel routing, allow discounted DeepSeek (#4418)
1 parent 9d7c792 commit 1807c6a

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

‎apps/web/src/lib/ai-gateway/providers/get-provider.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export async function getProvider(input: GetProviderInput): Promise<GetProviderR
231231

232232
if (
233233
eligibleForVercelRouting &&
234-
(await shouldRouteToVercel(requestedModel, request, taskId || user.id))
234+
(await shouldRouteToVercel(requestedModel, kiloExclusiveModel, request, taskId || user.id))
235235
) {
236236
return {
237237
kind: 'provider',

‎apps/web/src/lib/ai-gateway/providers/vercel/index.ts‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { getVercelModels } from '@/lib/ai-gateway/providers/gateway-models-cache
2626
import type { AnthropicProviderOptions } from '@ai-sdk/anthropic';
2727
import { isFableModel } from '@/lib/ai-gateway/providers/anthropic.constants';
2828
import { isDeepseekModel } from '@/lib/ai-gateway/providers/deepseek';
29+
import type { KiloExclusiveModel } from '@/lib/ai-gateway/providers/kilo-exclusive-model';
2930

3031
const 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+
4160
export 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

Comments
 (0)