Skip to content

Commit 164f475

Browse files
feat(ai-gateway): gate Vercel routing for exclusive models with vercel-routing flag (#3005)
* feat(ai-gateway): add vercel-routing flag to gate Vercel routing for exclusive models Kilo-exclusive models are now only eligible for random Vercel routing when they carry the new 'vercel-routing' flag or are not exclusive at all. This prevents surprises such as StepFun Flash (an exclusive model on OpenRouter) suddenly being routed through Vercel if Vercel begins hosting it. The flag is set only on the currently disabled MiniMax M2.5 free model for now. * refactor(ai-gateway): drop redundant openrouter check and inline defaultProvider --------- Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
1 parent a320291 commit 164f475

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,20 @@ export async function getProvider(
175175
}
176176

177177
const kiloExclusiveModel = kiloExclusiveModels.find(m => m.public_id === requestedModel);
178-
const defaultProvider =
179-
Object.values(PROVIDERS).find(p => p.id === kiloExclusiveModel?.gateway) ??
180-
PROVIDERS.OPENROUTER;
178+
const eligibleForVercelRouting =
179+
!kiloExclusiveModel || kiloExclusiveModel.flags.includes('vercel-routing');
181180

182181
if (
183-
defaultProvider.id === 'openrouter' &&
182+
eligibleForVercelRouting &&
184183
(await shouldRouteToVercel(requestedModel, request, taskId || user.id))
185184
) {
186185
return { provider: PROVIDERS.VERCEL_AI_GATEWAY, userByok: null, bypassAccessCheck: false };
187186
}
188187

189188
return {
190-
provider: defaultProvider,
189+
provider:
190+
Object.values(PROVIDERS).find(p => p.id === kiloExclusiveModel?.gateway) ??
191+
PROVIDERS.OPENROUTER,
191192
userByok: null,
192193
bypassAccessCheck: false,
193194
};

apps/web/src/lib/ai-gateway/providers/kilo-exclusive-model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from '@/lib/ai-gateway/providers/openrouter/inference-provider-id';
66
import type { ProviderId } from '@/lib/ai-gateway/providers/types';
77

8-
export type KiloExclusiveModelFlag = 'reasoning' | 'vision' | 'stealth';
8+
export type KiloExclusiveModelFlag = 'reasoning' | 'vision' | 'stealth' | 'vercel-routing';
99

1010
export type Usage = {
1111
uncachedInputTokens: number;

apps/web/src/lib/ai-gateway/providers/minimax.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const minimax_m25_free_model: KiloExclusiveModel = {
88
context_length: 204800,
99
max_completion_tokens: 131072,
1010
status: 'disabled',
11-
flags: ['reasoning'],
11+
flags: ['reasoning', 'vercel-routing'],
1212
gateway: 'openrouter',
1313
internal_id: 'minimax/minimax-m2.5',
1414
pricing: null,

0 commit comments

Comments
 (0)