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
55 changes: 37 additions & 18 deletions apps/web/src/lib/ai-gateway/models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import {
claude_opus_4_6_stealth_model,
} from './providers/anthropic.constants';
import { deepseek_v4_pro_discounted_model } from './providers/deepseek';
import { gpt_5_6_sol_stealth_model } from './providers/openai-exclusive';
import {
gpt_5_6_sol_discounted_model,
gpt_5_6_sol_stealth_model,
} from './providers/openai-exclusive';
import { tencent_hy3_free_model } from './providers/tencent';
import { gemma_4_26b_a4b_it_free_model } from './providers/google';
import { longcat_2_free_model } from './providers/longcat';
Expand Down Expand Up @@ -115,33 +118,46 @@ describe('isFreeModel', () => {
expect(claude_opus_4_6_stealth_model.public_id).toBe('stealth/claude-opus-4.6');
});

test('registers GPT-5.6 Sol as a Martian stealth model', () => {
expect(findKiloExclusiveModel('stealth/gpt-5.6-sol')).toBe(gpt_5_6_sol_stealth_model);
expect(gpt_5_6_sol_stealth_model.internal_id).toBe('openai/gpt-5.6-sol:optimized');
expect(gpt_5_6_sol_stealth_model.gateway).toBe('martian');
expect(getInferenceProvider(gpt_5_6_sol_stealth_model)?.slug).toBe('stealth');
expect(gpt_5_6_sol_stealth_model.pricing?.tiers).toEqual([
test('registers the discounted GPT-5.6 Sol OpenAI endpoint', async () => {
expect(findKiloExclusiveModel(gpt_5_6_sol_discounted_model.public_id)).toBe(
gpt_5_6_sol_discounted_model
);
expect(gpt_5_6_sol_discounted_model).toMatchObject({
internal_id: 'openai/gpt-5.6-sol',
gateway: 'vercel',
flags: ['reasoning', 'vision'],
inference_provider_restriction: ['openai'],
});
expect(
await hasBestEffortGuessDataCollectionRequirement(gpt_5_6_sol_discounted_model.public_id)
).toBe(false);
expect(gpt_5_6_sol_discounted_model.pricing?.tiers).toEqual([
{
start_context_length: 0,
pricing: {
prompt_per_million: 4,
completion_per_million: 24,
input_cache_read_per_million: 0.4,
input_cache_write_per_million: 5,
prompt_per_million: 2.5,
completion_per_million: 15,
input_cache_read_per_million: 0.25,
input_cache_write_per_million: 3.125,
},
},
{
start_context_length: 272_000,
pricing: {
prompt_per_million: 8,
completion_per_million: 36,
input_cache_read_per_million: 0.8,
input_cache_write_per_million: 10,
prompt_per_million: 5,
completion_per_million: 22.5,
input_cache_read_per_million: 0.5,
input_cache_write_per_million: 6.25,
},
},
]);
});

test('keeps the previous GPT-5.6 Sol stealth discount disabled', () => {
expect(gpt_5_6_sol_stealth_model.status).toBe('disabled');
expect(findKiloExclusiveModel(gpt_5_6_sol_stealth_model.public_id)).toBeNull();
});

test('all Kilo exclusive models should have either no pricing or valid ordered pricing tiers', () => {
for (const model of kiloExclusiveModels) {
if (model.pricing) {
Expand Down Expand Up @@ -364,15 +380,18 @@ describe('getKiloExclusiveInferenceProviderRestriction', () => {
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']));
expect(getKiloExclusiveInferenceProviderRestriction(tencent_hy3_free_model.public_id)).toEqual(
new Set(['tencent'])
);
});

test('does not treat unrestricted exclusives or unknown ids as restricted', () => {
expect(
getKiloExclusiveInferenceProviderRestriction(gpt_5_6_sol_stealth_model.public_id)
).toBeUndefined();
expect(getKiloExclusiveInferenceProviderRestriction(gpt_5_6_sol_stealth_model.public_id)).toBe(
undefined
);
expect(
getKiloExclusiveInferenceProviderRestriction(gemma_4_26b_a4b_it_free_model.public_id)
).toBeUndefined();
Expand Down
10 changes: 8 additions & 2 deletions apps/web/src/lib/ai-gateway/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ import { longcat_2_free_model } from '@/lib/ai-gateway/providers/longcat';
import { isGrokModel } from '@/lib/ai-gateway/providers/xai';
import { isClaudeModel } from '@/lib/ai-gateway/providers/anthropic.constants';
import { GPT_CURRENT_MODEL_ID, isOpenAiModel } from '@/lib/ai-gateway/providers/openai';
import { gpt_5_6_sol_stealth_model } from '@/lib/ai-gateway/providers/openai-exclusive';
import {
gpt_5_6_sol_discounted_model,
gpt_5_6_sol_stealth_model,
} from '@/lib/ai-gateway/providers/openai-exclusive';
import { GLM_CURRENT_MODEL_ID } from '@/lib/ai-gateway/providers/zai';
import { deepseekDiscountedModels } from '@/lib/ai-gateway/providers/deepseek';
import { type ProviderId } from '@/lib/ai-gateway/providers/types';
Expand Down Expand Up @@ -97,7 +100,9 @@ export const preferredModels = [
CLAUDE_SONNET_CURRENT_MODEL_ID,
CLAUDE_OPUS_CURRENT_MODEL_ID,
GPT_CURRENT_MODEL_ID,
...(gpt_5_6_sol_stealth_model.status === 'public' ? [gpt_5_6_sol_stealth_model.public_id] : []),
...(gpt_5_6_sol_discounted_model.status === 'public'
? [gpt_5_6_sol_discounted_model.public_id]
: []),
GLM_CURRENT_MODEL_ID,
KIMI_CURRENT_MODEL_ID,
MINIMAX_CURRENT_MODEL_ID,
Expand Down Expand Up @@ -134,6 +139,7 @@ export const kiloExclusiveModels = [
...deepseekDiscountedModels,
qwen36_plus_stealth_model,
gpt_5_6_sol_stealth_model,
gpt_5_6_sol_discounted_model,
claude_opus_4_8_stealth_model,
claude_opus_4_7_stealth_model,
claude_sonnet_4_6_stealth_model,
Expand Down
38 changes: 37 additions & 1 deletion apps/web/src/lib/ai-gateway/providers/openai-exclusive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const gpt_5_6_sol_stealth_model: KiloExclusiveModel = {
display_name: 'Stealth: GPT-5.6 Sol (20% off)',
description:
"Your prompts and completions may be retained and used to train or improve the provider's services. This third-party-served variant of GPT-5.6 Sol is offered at 20% lower cost than standard GPT-5.6 Sol pricing and is not served by OpenAI or Kilo Code.",
status: 'public',
status: 'disabled',
context_length: 1_050_000,
max_completion_tokens: 128_000,
gateway: 'martian',
Expand Down Expand Up @@ -35,3 +35,39 @@ export const gpt_5_6_sol_stealth_model: KiloExclusiveModel = {
},
inference_provider_restriction: [],
};

export const gpt_5_6_sol_discounted_model: KiloExclusiveModel = {
public_id: 'openai/gpt-5.6-sol-discounted',
internal_id: 'openai/gpt-5.6-sol',
display_name: 'OpenAI: GPT-5.6 Sol (50% off)',
description:
'GPT-5.6 Sol served by OpenAI through Vercel AI Gateway at 50% lower cost than other available inference providers. This promotion runs through September 18, 2026.',
status: 'public',
context_length: 1_050_000,
max_completion_tokens: 128_000,
gateway: 'vercel',
flags: ['reasoning', 'vision'],
pricing: {
tiers: [
{
start_context_length: 0,
pricing: {
prompt_per_million: 2.5,
completion_per_million: 15,
input_cache_read_per_million: 0.25,
input_cache_write_per_million: 3.125,
},
},
{
start_context_length: 272_000,
pricing: {
prompt_per_million: 5,
completion_per_million: 22.5,
input_cache_read_per_million: 0.5,
input_cache_write_per_million: 6.25,
},
},
],
},
inference_provider_restriction: ['openai'],
};
11 changes: 11 additions & 0 deletions apps/web/src/lib/ai-gateway/providers/vercel/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,17 @@ describe('applyVercelSettings managed requests', () => {
expect(getVercelInferenceProvidersMock).toHaveBeenCalledWith('openai/gpt-5');
});

it('does not add managed OpenAI BYOK to the discounted GPT-5.6 Sol endpoint', async () => {
process.env.OPENAI_API_KEY = 'openai-managed-key';
const request = managedRequest({ only: ['openai'] });

await applyManagedVercelSettings('openai/gpt-5.6-sol-discounted', request);

expect(request.body.model).toBe('openai/gpt-5.6-sol');
expect(request.body.providerOptions?.gateway?.only).toEqual(['openai']);
expect(request.body.providerOptions?.gateway?.byok).toBeUndefined();
});

it('does not add managed OpenAI credentials when Vercel does not offer OpenAI', async () => {
process.env.OPENAI_API_KEY = 'openai-managed-key';
const request = managedRequest();
Expand Down
3 changes: 3 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 @@ -21,6 +21,7 @@ import type { AnthropicProviderOptions } from '@ai-sdk/anthropic';
import { getRuntimeGatewayRoutingConfig } from '@/lib/ai-gateway/providers/routing-config';
import { passesRoutingPercentage } from '@/lib/ai-gateway/providers/routing-percentage';
import { getEnvVariable } from '@/lib/dotenvx';
import { gpt_5_6_sol_discounted_model } from '@/lib/ai-gateway/providers/openai-exclusive';

export function hasCompatibleVercelInferenceProvider(
openRouterInferenceProviders: string[],
Expand Down Expand Up @@ -266,9 +267,11 @@ export async function applyVercelSettings(

const gatewayOptions = requestToMutate.body.providerOptions.gateway;
const openAiApiKey = getEnvVariable('OPENAI_API_KEY');
// OpenAI BYOK must also be disabled in the Vercel GUI so this model uses Vercel's discounted endpoint.
if (
gatewayOptions &&
openAiApiKey &&
requestedModel !== gpt_5_6_sol_discounted_model.public_id &&
vercelInferenceProviders?.includes('openai') &&
(!gatewayOptions.only || gatewayOptions.only.includes('openai'))
) {
Expand Down
10 changes: 5 additions & 5 deletions apps/web/src/tests/openrouter-models-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@/lib/ai-gateway/providers/anthropic.constants';
import { deepseek_v4_pro_discounted_model } from '@/lib/ai-gateway/providers/deepseek';
import { GPT_CURRENT_MODEL_ID } from '@/lib/ai-gateway/providers/openai';
import { gpt_5_6_sol_stealth_model } from '@/lib/ai-gateway/providers/openai-exclusive';
import { gpt_5_6_sol_discounted_model } from '@/lib/ai-gateway/providers/openai-exclusive';
import { QWEN37_PLUS_MODEL_ID } from '@/lib/ai-gateway/providers/qwen';
import { tencent_hy3_free_model } from '@/lib/ai-gateway/providers/tencent';

Expand Down Expand Up @@ -37,13 +37,13 @@ describe('OpenRouter Models Config', () => {
expect(preferredModels).not.toContain(model);
});

if (gpt_5_6_sol_stealth_model.status === 'public') {
expect(preferredModels).toContain(gpt_5_6_sol_stealth_model.public_id);
if (gpt_5_6_sol_discounted_model.status === 'public') {
expect(preferredModels).toContain(gpt_5_6_sol_discounted_model.public_id);
expect(preferredModels.indexOf(GPT_CURRENT_MODEL_ID)).toBeLessThan(
preferredModels.indexOf(gpt_5_6_sol_stealth_model.public_id)
preferredModels.indexOf(gpt_5_6_sol_discounted_model.public_id)
);
} else {
expect(preferredModels).not.toContain(gpt_5_6_sol_stealth_model.public_id);
expect(preferredModels).not.toContain(gpt_5_6_sol_discounted_model.public_id);
}
});
});