fix(groq): strip unsupported store field (#983)

This commit is contained in:
JATMN
2026-05-04 16:21:50 +08:00
committed by GitHub
parent 884746dbe9
commit 6d0953a79c
3 changed files with 38 additions and 1 deletions
+3 -1
View File
@@ -159,11 +159,13 @@ export OPENAI_MODEL=meta-llama/Llama-3.3-70B-Instruct-Turbo
```bash
export CLAUDE_CODE_USE_OPENAI=1
export OPENAI_API_KEY=gsk_...
export GROQ_API_KEY=gsk_...
export OPENAI_BASE_URL=https://api.groq.com/openai/v1
export OPENAI_MODEL=llama-3.3-70b-versatile
```
`GROQ_API_KEY` matches the built-in Groq gateway preset. `OPENAI_API_KEY` also works as a fallback on the generic OpenAI-compatible path, but `GROQ_API_KEY` is the preferred variable for Groq-specific setup.
### Mistral
```bash
+1
View File
@@ -16,6 +16,7 @@ export default defineGateway({
kind: 'openai-compatible',
openaiShim: {
supportsAuthHeaders: true,
removeBodyFields: ['store'],
},
},
preset: {
+34
View File
@@ -4098,6 +4098,40 @@ test('Moonshot: uses max_tokens (not max_completion_tokens) and strips store', a
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'
let requestBody: Record<string, unknown> | undefined
globalThis.fetch = (async (_input, init) => {
requestBody = JSON.parse(String(init?.body))
return new Response(
JSON.stringify({
id: 'chatcmpl-1',
model: 'llama-3.3-70b-versatile',
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: 'llama-3.3-70b-versatile',
system: 'you are groq',
messages: [{ role: 'user', content: 'hi' }],
max_tokens: 256,
stream: false,
})
expect(requestBody?.max_completion_tokens).toBe(256)
expect(requestBody?.max_tokens).toBeUndefined()
expect(requestBody?.store).toBeUndefined()
})
test('Moonshot: echoes reasoning_content on assistant tool-call messages', async () => {
// Regression for: "API Error: 400 {"error":{"message":"thinking is enabled
// but reasoning_content is missing in assistant tool call message at index