Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion apps/web/src/lib/ai-gateway/providers/vercel/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { describe, it, expect } from '@jest/globals';
import { getAnthropicProviderOptionsForVercel } from '@/lib/ai-gateway/providers/vercel';
import {
getAnthropicProviderOptionsForVercel,
shouldRouteToVercel,
} from '@/lib/ai-gateway/providers/vercel';
import type { GatewayRequest } from '@/lib/ai-gateway/providers/openrouter/types';

describe('getAnthropicProviderOptionsForVercel', () => {
Expand Down Expand Up @@ -62,3 +65,17 @@ describe('getAnthropicProviderOptionsForVercel', () => {
);
});
});

describe('shouldRouteToVercel', () => {
it('excludes DeepSeek models (Vercel does not provide reasoning_content passthrough)', async () => {
const request: GatewayRequest = {
kind: 'chat_completions',
body: {
model: 'deepseek/deepseek-v4-pro',
messages: [{ role: 'user', content: 'hello' }],
},
};

expect(await shouldRouteToVercel('deepseek/deepseek-v4-pro', request, 'seed')).toBe(false);
});
});
8 changes: 8 additions & 0 deletions apps/web/src/lib/ai-gateway/providers/vercel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ export async function shouldRouteToVercel(
return false;
}

// DeepSeek models excluded — Vercel AI Gateway routes directly to DeepSeek which rejects
// requests where assistant messages omit `reasoning_content` in thinking mode. OpenRouter
// handles that translation from `providerOptions.openrouter.reasoning_details`; Vercel does not.
if (requestedModel.startsWith('deepseek/')) {
console.debug(`[shouldRouteToVercel] DeepSeek models excluded (reasoning_content passthrough)`);
return false;
}

console.debug('[shouldRouteToVercel] randomizing user to either OpenRouter or Vercel');
const passedRandomization =
getRandomNumber('vercel_routing_' + randomSeed, 100) < (await getVercelRoutingPercentage());
Expand Down
Loading