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
Calling Modes
Parallel and Multi-Step Calls
- Parallel: one turn may return several
function_callparts (e.g. two cities at once); execute each and return allfunction_responseparts 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
enuminstead 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_schemastructured 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
Related Links
- This group: Native Calls · Multimodal & Code Execution · Cache Billing
- OpenAI counterpart: OpenAI Function Calling
- Official Google docs:
ai.google.dev/gemini-api/docs/function-calling