Gemini 3 models fail with "Invalid JSON payload received. Unknown name 'parameters'" error
OpenCode GitHub Issue Report
Issue Title
Gemini 3 models fail with "Invalid JSON payload received. Unknown name 'parameters'" error when using antigravity-auth plugin
Issue Description
When using google/antigravity-gemini-3-flash or google/antigravity-gemini-3-pro models, OpenCode fails with a 400 error due to invalid tool schema format for Gemini API.
Error Message
Invalid JSON payload received. Unknown name "parameters" at 'request.tools[0]': Cannot find field.
Status: 400
Requested Model: antigravity-gemini-3-flash
Effective Model: gemini-3-flash
Endpoint: https://daily-cloudcode-pa.sandbox.googleapis.com/v1internal:streamGenerateContent?alt=sse
Tool Debug Payload (Problematic)
The tool schema being sent to Gemini contains an incorrectly formatted structure:
[{
"functionDeclarations": [...],
"parameters": {
"type": "OBJECT",
"properties": {
"_placeholder": {
"type": "BOOLEAN",
"description": "Placeholder. Always pass true."
}
},
"required": ["_placeholder"]
}
}]
Expected Behavior
Tool schemas should be formatted according to Gemini API specifications, with:
- Proper
type: "object"(lowercase) - No
_placeholderparameters - No unsupported JSON Schema fields like
$schema - String-only enum values
Environment
- OpenCode Version: v1.1.23 (latest)
- Plugin: [email protected]
- OS: Windows
- Model: google/antigravity-gemini-3-flash (all variants fail)
- Project: J:\apps\max-Translator\max-ai-omni-translator
Related Issues
- OpenCode #3140: "AI_APICallError: GenerateContentRequest.tools[0].function_declarations[32].parameters. required[0]: property is not defined"
- OpenCode #4512: "sanitize tools for Gemini 3 compatibility" (fixed in PR #4538 but issue persists)
- OpenCode #4665: "OpenCode plus Zen Gemini 3 Pro model causes errors"
- Qwen Code #1186: "API Error 400 with Gemini model: Invalid JSON payload received. Unknown name '$schema'"
Reproduction Steps
- Install opencode-antigravity-auth@beta plugin
- Configure google/antigravity-gemini-3-flash model
- Run:
opencode run "Hello" --model=google/antigravity-gemini-3-flash - Observe 400 error with "Unknown name 'parameters'" message
Workaround
Claude models (antigravity-claude-sonnet-4-5-thinking) work correctly with the same configuration.
Suggested Fix
Implement proper tool schema sanitization for Gemini API:
- Remove
$schemafield from tool parameter schemas - Convert non-string enum values to strings
- Ensure
typefield uses lowercase values - Remove placeholder parameters like
_placeholder - Validate schema against Gemini's expected format
See OpenCode PR #4538 for previous attempts at fixing similar issues.
This issue might be a duplicate of existing issues. Please check:
- #3140: AI_APICallError with Gemini API tool schema validation (similar 'parameters' and 'required' property issues)
- #8036: Schema validation error with Google/Gemini models (enum values not being strings - same root cause)
- #365: Google provider tool call schema mismatches with Gemini models (same error pattern with function_declarations)
- #4512: sanitize tools for Gemini 3 compatibility (Gemini enum validation failures - related root cause)
- #4665: OpenCode plus Zen Gemini 3 Pro model causes errors (Gemini tool schema validation - same issue pattern)
- #2082: JSON schema validation errors affecting Gemini and other providers (related tool schema issue)
These issues all relate to tool schema formatting problems when interfacing with Gemini API. The root cause appears to be improper sanitization of tool schemas before sending to the Gemini API (missing required fields, incorrect enum types, unsupported fields like $schema, etc.).
Feel free to ignore if your specific case differs.
believe this is a bug in ur plugin
I'm encountering the same issue
Using with github-copilot vendor:
Using with google/antigravity
opencode run --model google/antigravity-gemini-3-pro-high "hi" Error: Invalid JSON payload received. Unknown name "parameters" at 'request.tools[0]': Cannot find field.
[Debug Info] Requested Model: antigravity-gemini-3-pro-high Effective Model: gemini-3-pro-high Project: *********** Endpoint: https://daily-cloudcode-pa.sandbox.googleapis.com/v1internal:streamGenerateContent?alt=sse Status: 400 Request ID: N/A Tool Debug Missing: 1 Tool Debug Summary: idx=0, hasCustom=true, customSchema=true, hasFunction=false, functionSchema=false