Skip to content

Gemini tool calls format causing AI_APICallError #1052

Closed

Description

@jeanmatthieu

Hello,

Using Gemini 2.5 Pro I'm getting an AI_APICallError error every message I send to the LLM.

This is the error I got from my proxy

{"message":"Failed to parse request: failed to parse request: proto: syntax error (line 1:13263): unexpected token {","request_id":"5f","details":"failed to parse request: proto: syntax error (line 1:13263): unexpected token {"}

Looking at the payload and response from my proxy it seems that tools are passed as a dictionary and perhaps my proxy expects an array ?
This is what is sent by opencode

{
"tools": 
    {
      "functionDeclarations": [
        {
          "name": string,
          "description": string,
          "parameters": {
            object (OpenAPI Object Schema)
          }
        }
      ]
    }
  ,
}

while https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/function-calling suggests tools should be an array such as

"tools": [
    {
      "functionDeclarations": [
        {
          "name": string,
          "description": string,
          "parameters": {
            object (OpenAPI Object Schema)
          }
        }
      ]
    }
  ],

But I dont know if this is an issue in opencode or if my proxy that should handle both use case so I decided to report it here first.

Thank you !

Activity

  1. self-assigned this
    on Jul 16, 2025
  2. jeanmatthieu commented on Jul 21, 2025

    @jeanmatthieu
    Author

    Hi @necaris, thanks I have tied with version 0.3.46 and the issue still occurs on my end.

  3. martinffx commented on Aug 4, 2025

    @martinffx

    yes, also seem to be running into this. Gemini does not seem to be able to use my MCP Tools?

  4. necaris commented on Aug 4, 2025

    @necaris
    Contributor

    Please see #1232 -- this is due to limitations in the Gemini API, so when MCP tools (or builtin ones) use JSON Schema elements that Gemini doesn't support, everything falls over.

  5. rekram1-node commented on Dec 28, 2025

    @rekram1-node
    Contributor

    [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions