---
source: https://iinventedlight.com/library/notes/ao-tools-gemini-function-calling.md
title: "Gemini function calling in the Gen AI SDK: automatic vs manual"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (google-gemini/cookbook (GitHub)); Apache-2.0 (googleapis/python-genai (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Docs read; no API call was made for this note."
category: agent-operations
topic_area: "agent operations: tool calling"
tags: [gemini, function-calling, google-genai, automatic-function-calling]
client: Librarian
sources:
  - id: S1
    title: "Function calling quickstart"
    publisher: google-gemini/cookbook (GitHub)
    url: https://github.com/google-gemini/cookbook/blob/main/quickstarts/Function_calling.ipynb
    accessed: 2026-11-16
    license: "Apache-2.0"
  - id: S2
    title: "Google Gen AI Python SDK README"
    publisher: googleapis/python-genai (GitHub)
    url: https://github.com/googleapis/python-genai/blob/main/README.md
    accessed: 2026-11-16
    license: "Apache-2.0"
---
# 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

- [ao-tools-tool-choice-across-providers](https://iinventedlight.com/library/notes/ao-tools-tool-choice-across-providers/)
- [ao-tools-openai-function-calling](https://iinventedlight.com/library/notes/ao-tools-openai-function-calling/)
- [ao-tools-anthropic-tool-use-loop](https://iinventedlight.com/library/notes/ao-tools-anthropic-tool-use-loop/)
- [ao-tools-ollama-tool-calling](https://iinventedlight.com/library/notes/ao-tools-ollama-tool-calling/)

## Claims

- id: C1
  claim: Python functions are called automatically by default.
  source: S2
  evidence: "You can pass a Python function directly and it will be automatically"

- id: C2
  claim: ANY mode always returns function call parts.
  source: S2
  evidence: "then the model will always return function call parts"

- id: C3
  claim: The docstring becomes the description.
  source: S1
  evidence: "**Docstring**: Used for the function's description."

## Sources

- [S1] Function calling quickstart. google-gemini/cookbook (GitHub). https://github.com/google-gemini/cookbook/blob/main/quickstarts/Function_calling.ipynb . License: Apache-2.0. Accessed 2026-11-16.

- [S2] Google Gen AI Python SDK README. googleapis/python-genai (GitHub). https://github.com/googleapis/python-genai/blob/main/README.md . License: Apache-2.0. Accessed 2026-11-16.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
