Skip to main content
The Gemini native format fully supports Function Calling: the model outputs “which function + what arguments”, you execute locally and return the result, and the model produces the final answer. The loop matches OpenAI’s FC, but the field formats are entirely different and cannot be mixed. This page is based on the official Google documentation (ai.google.dev/gemini-api/docs/function-calling, as of June 2026).

Format Differences vs OpenAI

One easy mistake: Gemini’s function_call.args is a structured object, not a JSON string — no json.loads needed.

The Full Call Loop

Gemini 3 thought signatures must be returned: the function_call part carries an encrypted thought_signature, and the second request must include the model’s entire reply Content unchanged in the history (step 4 above). A missing signature breaks the reasoning chain and can fail the request. The official google-genai SDK handles this automatically with the pattern above; don’t strip the field in hand-written REST calls.

Calling Modes

Parallel and Multi-Step Calls

  • Parallel: one turn may return several function_call parts (e.g. two cities at once); execute each and return all function_response parts together
  • Multi-step: the model can chain “call → inspect result → call again”; loop until the response has no more function_call. Cap the loop to avoid runaway spend

Best Practices

  • Descriptions are written for the model: spell out “when to call me”; narrow parameters with enum instead of free-form strings
  • Keep tool definitions stable: they participate in cache prefix matching — churn hurts cache hits
  • Need deterministic JSON output rather than an external tool? Consider response_schema structured output instead of FC (see the Native Calls parameter table)
  • For sandboxed computation, use the built-in code_execution tool instead of writing your own calculator function

Common Pitfalls