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
30 changes: 28 additions & 2 deletions apps/web/src/lib/ai-gateway/providers/direct-byok/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ jest.mock('./direct-byok-definitions', () => ({
{
id: 'supported-model',
name: 'Supported Model',
flags: ['reasoning'],
context_length: 4096,
max_completion_tokens: 1024,
},
{
id: 'non-reasoning-model',
name: 'Non-reasoning Model',
context_length: 4096,
max_completion_tokens: 1024,
},
Expand Down Expand Up @@ -56,9 +63,9 @@ jest.mock('./direct-byok-definitions', () => ({

async function loadDirectByokModule() {
const directByokProviders = (await import('./direct-byok-definitions')).default;
const { getDirectByokModel } = await import('.');
const { getDirectByokModel, getDirectByokModelsForUser } = await import('.');

return { directByokProviders, getDirectByokModel };
return { directByokProviders, getDirectByokModel, getDirectByokModelsForUser };
}

describe('getDirectByokModel', () => {
Expand Down Expand Up @@ -88,4 +95,23 @@ describe('getDirectByokModel', () => {
expect(directByokProviders[0].models).toHaveBeenCalledTimes(1);
expect(directByokProviders[1].models).not.toHaveBeenCalled();
});

test('advertises only the reasoning parameter for reasoning models', async () => {
const { getDirectByokModelsForUser } = await loadDirectByokModule();
const { getBYOKforUser } = await import('@/lib/ai-gateway/byok');
jest
.mocked(getBYOKforUser)
.mockResolvedValueOnce([{ providerId: 'chutes-byok', decryptedAPIKey: 'test-key' }]);

const models = await getDirectByokModelsForUser('user-id');

expect(models[0].supported_parameters).toEqual([
'max_tokens',
'temperature',
'tools',
'reasoning',
]);
expect(models[1].supported_parameters).toEqual(['max_tokens', 'temperature', 'tools']);
expect(models.flatMap(model => model.supported_parameters)).not.toContain('include_reasoning');
});
});
4 changes: 3 additions & 1 deletion apps/web/src/lib/ai-gateway/providers/direct-byok/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ function convertModel(
is_moderated: false,
},
per_request_limits: null,
supported_parameters: ['max_tokens', 'temperature', 'tools', 'reasoning', 'include_reasoning'],
supported_parameters: ['max_tokens', 'temperature', 'tools'].concat(
model.flags?.includes('reasoning') ? ['reasoning'] : []
),
default_parameters: {},
preferredIndex: model.flags?.includes('recommended') ? preferredIndex : undefined,
hasUserByokAvailable: true,
Expand Down