Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix: sanitize tool schemas for Gemini provider (#173)

diegosouzapw8d5891a382d7
diff --git a/open-sse/translator/request/openai-to-gemini.ts b/open-sse/translator/request/openai-to-gemini.ts
index dcc06dca80..6f3ca2ab65 100644
--- a/open-sse/translator/request/openai-to-gemini.ts
+++ b/open-sse/translator/request/openai-to-gemini.ts
@@ -180,7 +180,9 @@ function openaiToGeminiBase(model, body, stream) {
functionDeclarations.push({
name: t.name,
description: t.description || "",
- parameters: t.input_schema || { type: "object", properties: {} },
+ parameters: cleanJSONSchemaForAntigravity(
+ t.input_schema || { type: "object", properties: {} }
+ ),
});
}
// OpenAI format
@@ -189,7 +191,9 @@ function openaiToGeminiBase(model, body, stream) {
functionDeclarations.push({
name: fn.name,
description: fn.description || "",
- parameters: fn.parameters || { type: "object", properties: {} },
+ parameters: cleanJSONSchemaForAntigravity(
+ fn.parameters || { type: "object", properties: {} }
+ ),
});
}
}
@@ -206,9 +210,7 @@ function openaiToGeminiBase(model, body, stream) {
// Extract the schema (may be nested under .schema key)
const schema = body.response_format.json_schema.schema || body.response_format.json_schema;
if (schema && typeof schema === "object") {
- // Remove unsupported keywords for Gemini (it uses a subset of JSON Schema)
- const { $schema, additionalProperties, ...cleanSchema } = schema;
- result.generationConfig.responseSchema = cleanSchema;
+ result.generationConfig.responseSchema = cleanJSONSchemaForAntigravity(schema);
}
} else if (body.response_format.type === "json_object") {
result.generationConfig.responseMimeType = "application/json";