Skip to content
Merged
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
6 changes: 3 additions & 3 deletions apps/web/src/lib/ai-gateway/models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,6 @@ describe('shouldRedactModelNameInMicrodollarUsage', () => {

describe('getKiloExclusiveInferenceProviderRestriction', () => {
test('returns the routing allow-list for restricted exclusive models', () => {
expect(
getKiloExclusiveInferenceProviderRestriction(deepseek_v4_pro_discounted_model.public_id)
).toEqual(new Set(['deepseek']));
expect(
getKiloExclusiveInferenceProviderRestriction(gpt_5_6_sol_discounted_model.public_id)
).toEqual(new Set(['openai']));
Expand All @@ -389,6 +386,9 @@ describe('getKiloExclusiveInferenceProviderRestriction', () => {
});

test('does not treat unrestricted exclusives or unknown ids as restricted', () => {
expect(
getKiloExclusiveInferenceProviderRestriction(deepseek_v4_pro_discounted_model.public_id)
).toBeUndefined();
expect(getKiloExclusiveInferenceProviderRestriction(gpt_5_6_sol_stealth_model.public_id)).toBe(
undefined
);
Expand Down
5 changes: 3 additions & 2 deletions apps/web/src/lib/ai-gateway/providers/deepseek.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ export function isDeepseekModel(model: string) {
return model.includes('deepseek');
}

// DeepSeek now uses time-of-day based pricing, which our static pricing catalog does not support.
export const deepseek_v4_pro_discounted_model: KiloExclusiveModel = {
public_id: 'deepseek/deepseek-v4-pro:discounted',
internal_id: 'deepseek/deepseek-v4-pro-0813',
display_name: 'DeepSeek: DeepSeek V4 Pro 0813 (lowest price)',
description:
'This DeepSeek V4 Pro 0813 endpoint provides the lowest cost for multi-turn conversations for this model. This is accomplished with an exceptionally low cache read price. By using this endpoint you agree prompts and completions may be retained by DeepSeek and used to train future models.',
status: 'public',
status: 'disabled',
context_length: 1048576,
max_completion_tokens: 384000,
gateway: 'openrouter',
Expand All @@ -37,7 +38,7 @@ const deepseek_v4_flash_discounted_model: KiloExclusiveModel = {
display_name: 'DeepSeek: DeepSeek V4 Flash 0731 (lowest price)',
description:
'This DeepSeek V4 Flash 0731 endpoint provides the lowest cost for multi-turn conversations for this model. This is accomplished with an exceptionally low cache read price. By using this endpoint you agree prompts and completions may be retained by DeepSeek and used to train future models.',
status: 'public',
status: 'disabled',
context_length: 1048576,
max_completion_tokens: 384000,
gateway: 'openrouter',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jest.mock('@/lib/ai-gateway/byok', () => ({

import { computeCloudAgentNextBalanceCheckEligibility } from './balance-check-eligibility';

const KILO_EXCLUSIVE_MODEL = 'deepseek/deepseek-v4-pro:discounted';
const KILO_EXCLUSIVE_MODEL = 'openai/gpt-5.6-sol-discounted';
const NON_EXCLUSIVE_MODEL = 'anthropic/claude-sonnet-4';

const fakeDb = {} as never;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type BalanceCheckModelEligibility = {
* configured that can serve it, so the session is billed against the
* user's own key rather than their balance.
*
* Kilo-exclusive models (e.g. `deepseek/deepseek-v4-pro:discounted`) are
* Kilo-exclusive models (e.g. `openai/gpt-5.6-sol-discounted`) are
* always excluded from the BYOK bypass: they are Kilo-funded and platform
* billed, so even when `getModelUserByokProviders` reports a provider that
* can route the model, they must still go through the worker-side balance
Expand Down
22 changes: 9 additions & 13 deletions apps/web/src/lib/model-allow.server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,32 +155,28 @@ describe('model access predicates', () => {
test('provider allow list hides restricted exclusive models when every restricted provider is disabled', async () => {
const isAllowed = createAllowPredicateFromProviderAllowList(
undefined,
['openai', 'fireworks'],
lookup({ 'deepseek/deepseek-v4-pro': ['fireworks', 'deepseek'] })
['deepseek', 'fireworks'],
lookup({ 'openai/gpt-5.6-sol': ['fireworks', 'openai'] })
);

await expect(isAllowed('deepseek/deepseek-v4-pro:discounted')).resolves.toBe(false);
await expect(isAllowed('deepseek/deepseek-v4-pro')).resolves.toBe(true);
await expect(isAllowed('openai/gpt-5.6-sol-discounted')).resolves.toBe(false);
await expect(isAllowed('openai/gpt-5.6-sol')).resolves.toBe(true);
});

test('provider allow list keeps restricted exclusive models when a restricted provider remains enabled', async () => {
const isAllowed = createAllowPredicateFromProviderAllowList(
undefined,
['openai', 'deepseek'],
lookup({ 'deepseek/deepseek-v4-pro': ['fireworks'] })
['openai', 'fireworks'],
lookup({ 'openai/gpt-5.6-sol': ['fireworks'] })
);

await expect(isAllowed('deepseek/deepseek-v4-pro:discounted')).resolves.toBe(true);
await expect(isAllowed('openai/gpt-5.6-sol-discounted')).resolves.toBe(true);
});

test('provider allow list still evaluates restricted exclusive models missing from the snapshot', async () => {
const isAllowed = createAllowPredicateFromProviderAllowList(
undefined,
['deepseek'],
lookup({})
);
const isAllowed = createAllowPredicateFromProviderAllowList(undefined, ['openai'], lookup({}));

await expect(isAllowed('deepseek/deepseek-v4-pro:discounted')).resolves.toBe(true);
await expect(isAllowed('openai/gpt-5.6-sol-discounted')).resolves.toBe(true);
await expect(isAllowed('stealth/gpt-5.6-sol')).resolves.toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ describe('effective organization model access', () => {
context({
organization: {
...context().organization,
settings: { provider_allow_list: ['openai', 'fireworks'], model_deny_list: [] },
settings: { provider_allow_list: ['deepseek', 'fireworks'], model_deny_list: [] },
},
defaultPolicies: [{ type: 'model_access', data: { mode: 'all' } }],
})
);
const catalogLookup = async () => new Set(['fireworks', 'deepseek']);
const catalogLookup = async () => new Set(['fireworks', 'openai']);

expect(
await getEffectiveModelDecision(policy, 'deepseek/deepseek-v4-pro:discounted', catalogLookup)
await getEffectiveModelDecision(policy, 'openai/gpt-5.6-sol-discounted', catalogLookup)
).toEqual({ allowed: false, denialSource: 'organization_provider' });
});

Expand All @@ -280,19 +280,19 @@ describe('effective organization model access', () => {
context({
organization: {
...context().organization,
settings: { provider_allow_list: ['openai', 'deepseek'], model_deny_list: [] },
settings: { provider_allow_list: ['openai', 'fireworks'], model_deny_list: [] },
},
defaultPolicies: [{ type: 'model_access', data: { mode: 'all' } }],
})
);
const decision = await getEffectiveModelDecision(
policy,
'deepseek/deepseek-v4-pro:discounted',
'openai/gpt-5.6-sol-discounted',
async () => new Set(['fireworks'])
);

expect(decision.allowed).toBe(true);
expect([...decision.eligibleProviderRoutes!]).toEqual(['deepseek']);
expect([...decision.eligibleProviderRoutes!]).toEqual(['openai']);
});

it('does not apply exclusive restrictions to the unsuffixed catalog model', async () => {
Expand All @@ -305,16 +305,16 @@ describe('effective organization model access', () => {
defaultPolicies: [{ type: 'model_access', data: { mode: 'all' } }],
})
);
const catalogLookup = async () => new Set(['fireworks', 'deepseek']);
const catalogLookup = async () => new Set(['fireworks', 'openai']);

const exclusive = await getEffectiveModelDecision(
policy,
'deepseek/deepseek-v4-pro:discounted',
'openai/gpt-5.6-sol-discounted',
catalogLookup
);
const catalogModel = await getEffectiveModelDecision(
policy,
'deepseek/deepseek-v4-pro',
'openai/gpt-5.6-sol',
catalogLookup
);

Expand All @@ -328,7 +328,7 @@ describe('effective organization model access', () => {
context({
organization: {
...context().organization,
settings: { provider_allow_list: ['openai', 'deepseek'], model_deny_list: [] },
settings: { provider_allow_list: ['openai'], model_deny_list: [] },
},
defaultPolicies: [{ type: 'model_access', data: { mode: 'all' } }],
})
Expand All @@ -337,7 +337,7 @@ describe('effective organization model access', () => {

const restricted = await getEffectiveModelDecision(
policy,
'deepseek/deepseek-v4-pro:discounted',
'openai/gpt-5.6-sol-discounted',
emptySnapshot
);
const unrestricted = await getEffectiveModelDecision(
Expand All @@ -347,7 +347,7 @@ describe('effective organization model access', () => {
);

expect(restricted.allowed).toBe(true);
expect([...restricted.eligibleProviderRoutes!]).toEqual(['deepseek']);
expect([...restricted.eligibleProviderRoutes!]).toEqual(['openai']);
expect(unrestricted).toEqual({ allowed: false, denialSource: 'organization_model' });
});
});