← All notes

Gemini function calling in the Gen AI SDK: automatic vs manual

Answer: With the Google Gen AI Python SDK you can pass a Python function directly as a tool, and it will be automatically called and responded by default. If you do not want automatic function calling, you can disable it with AutomaticFunctionCallingConfig(disable=True).

How the SDK builds the declaration

The Gemini cookbook says the SDK builds a FunctionDeclaration schema from your Python function by inspecting the function name, the docstring (used for the description), and parameter names and type annotations.

ANY mode

If function calling mode is ANY, the model will always return function call parts. With a Python function as a tool, the SDK keeps doing automatic function calling until it reaches the maximum remote calls, which defaults to 10.

Manual handling

Without automatic function calling, you have to call the function yourself, for example with if function_call.name == ... and **function_call.args.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: google-gemini/cookbook (GitHub), Function calling quickstart, Apache-2.0 (https://raw.githubusercontent.com/google-gemini/cookbook/main/LICENSE); googleapis/python-genai (GitHub), Google Gen AI Python SDK README, Apache-2.0 (https://raw.githubusercontent.com/googleapis/python-genai/main/LICENSE). Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: google-gemini/cookbook (GitHub), Function calling quickstart, Apache-2.0 (https://raw.githubusercontent.com/google-gemini/cookbook/main/LICENSE); googleapis/python-genai (GitHub), Google Gen AI Python SDK README, Apache-2.0 (https://raw.githubusercontent.com/googleapis/python-genai/main/LICENSE).

Cite this

Permanent ID: iil:note:c2cq7wt4

iinventedlight. 2026. "Gemini function calling in the Gen AI SDK: automatic vs manual." iinventedlight Library, iil:note:c2cq7wt4, version of 2026-11-16. https://iinventedlight.com/library/notes/ao-tools-gemini-function-calling/. License: CC-BY-4.0.

@misc{iil_note_c2cq7wt4,
  author = {{iinventedlight}},
  title = {{Gemini function calling in the Gen AI SDK: automatic vs manual}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-16},
  url = {https://iinventedlight.com/library/notes/ao-tools-gemini-function-calling/},
  note = {Permanent ID iil:note:c2cq7wt4. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/ao-tools-gemini-function-calling.md.