1
0
forked from boos/BoosAPI

Merge pull request #137 from weijiafu14/fix/gemini-strip-unknown-request-fields

fix: use allowlist for Gemini native request fields to prevent 400 on unknown fields
This commit is contained in:
Cita
2026-03-17 19:09:11 +08:00
committed by GitHub
@@ -194,14 +194,22 @@ export const geminiGenerateContentInbound = {
next.generationConfig = generationConfig;
}
const strippedKeys = new Set([
'reasoning',
'reasoning_effort',
'reasoning_budget',
// Only forward fields that Gemini API supports. Unknown fields
// (e.g. requestId, frequency_penalty) cause upstream 400 errors.
const allowedPassthroughKeys = new Set([
'contents',
'systemInstruction',
'cachedContent',
'safetySettings',
'generationConfig',
'tools',
'toolConfig',
'labels',
'model',
]);
for (const [key, value] of Object.entries(body)) {
if (strippedKeys.has(key)) continue;
if (!allowedPassthroughKeys.has(key)) continue;
if (next[key] !== undefined) continue;
next[key] = cloneJsonValue(value);
}