Four function-calling modes
- AUTO (default) — the model picks: call a tool, or reply with text.
- ANY — the model must call at least one function. Useful for workflows where text-only is invalid.
- NONE — the model is forbidden from calling tools, even if they're declared. Useful when you've registered tools but want a single text-only turn.
- VALIDATED — like ANY, but with strict schema adherence enforced.
You can also restrict which tools the model is allowed to call this turn via allowed_function_names.
Call format — what the model emits
When the model decides to call a tool, the response's candidates[0].content.parts contains one or more function_call parts. Each has:
name— which tool to call.args— the JSON object matching your declared parameters.id— opaque identifier (always present on Gemini 3+; sometimes absent on 2.5).
Response format — what you send back
You execute the tool and send the result back in the next user turn as a function_response part:
name— must match the original call.response— your result, wrapped in{"result": ...}.id— match the call's id when present.
Gemini vs OpenAI roles
This is where memorizing OpenAI hurts you: Gemini's tool-result role is "user", not "tool". You're conceptually saying "the user provided the tool's output." Multiple tool results go in the same user turn as multiple parts, not as separate messages.