diff --git a/src/services/api/openaiShim.test.ts b/src/services/api/openaiShim.test.ts index a38828123..7d6a2bdd2 100644 --- a/src/services/api/openaiShim.test.ts +++ b/src/services/api/openaiShim.test.ts @@ -4130,6 +4130,38 @@ test('Cerebras: strips unsupported store on chat_completions (#1023)', async () expect(requestBody?.store).toBeUndefined() }) +test('Local provider (vLLM/Ollama/etc.): strips unsupported store on chat_completions (#672)', async () => { + process.env.OPENAI_BASE_URL = 'http://localhost:8000/v1' + process.env.OPENAI_API_KEY = 'sk-local' + + let requestBody: Record | undefined + globalThis.fetch = (async (_input, init) => { + requestBody = JSON.parse(String(init?.body)) + return new Response( + JSON.stringify({ + id: 'chatcmpl-1', + model: 'qwen-3.5-27b', + choices: [ + { message: { role: 'assistant', content: 'ok' }, finish_reason: 'stop' }, + ], + usage: { prompt_tokens: 3, completion_tokens: 1, total_tokens: 4 }, + }), + { headers: { 'Content-Type': 'application/json' } }, + ) + }) as FetchType + + const client = createOpenAIShimClient({}) as OpenAIShimClient + await client.beta.messages.create({ + model: 'qwen-3.5-27b', + system: 'you are local', + messages: [{ role: 'user', content: 'hi' }], + max_tokens: 64, + stream: false, + }) + + expect(requestBody?.store).toBeUndefined() +}) + test('Groq: keeps max_completion_tokens and strips unsupported store', async () => { process.env.OPENAI_BASE_URL = 'https://api.groq.com/openai/v1' process.env.OPENAI_API_KEY = 'gsk-test' diff --git a/src/services/api/openaiShim.ts b/src/services/api/openaiShim.ts index a840dff06..704f7d7dd 100644 --- a/src/services/api/openaiShim.ts +++ b/src/services/api/openaiShim.ts @@ -1613,7 +1613,8 @@ class OpenAIShimMessages { (shimConfig.removeBodyFields ?? []).includes('store') || isGeminiMode() || hasGeminiApiHost(request.baseUrl) || - hasCerebrasApiHost(request.baseUrl) + hasCerebrasApiHost(request.baseUrl) || + isLocal if ( shimConfig.maxTokensField === 'max_tokens' &&