Check my levelCoursesProgramsFor teamsPricing
UKSign inSign up
Check my levelCoursesProgramsFor teamsPricingClaude quizPromptsBlogFAQSearchSign upUK
AcademlCoursesGemini Cookbook: Based on Google MaterialsFunction Calling in the Gemini API
A grid of numbers where code has marked the primesClaude Code terminal: the claude -p command with Read and Edit allowedRetries after a 429 error: each pause is twice as long, then success
Course

Gemini Cookbook: Based on Google Materials

Module 1 · Getting Started with Google GenAI SDK
01First Steps with the Gemini API
Module 2 · Function Calling
02Function Calling in the Gemini API
Module 3 · Working with Audio
03Audio in the Gemini API
Module 4 · File API
04File API: Uploading and Using Files
Module 5 · Context Caching
05Context Caching: Cache Large Documents
Module 6 · Code Execution
06Code Execution: Python Inside Gemini
Module 7 · Embeddings
07Embeddings: Vector Representations in Gemini
Module 8 · Live API
08Live API: Real-Time Multimodal Sessions
Gemini Cookbook: Based on Google Materials · Lesson 2

Function Calling in the Gemini API

Pass functions as tools: the manual function_call → function_result loop with call_id in the Interactions API, automatic calling in SDK chats, history inspection, tool_choice modes and parallel calls.

25 min readUpdated Dec 2, 20263 questions in quizReady prompt included

What Is Function Calling

Function calling lets you describe functions and hand them to the model: it decides when and with what arguments to call them. The model doesn't run the function itself. It returns the name and arguments, and your code makes the call.

The Gemini API offers this in two interfaces:

  • Interactions API (client.interactions.create) — the primary API, which Google recommends for new projects. Functions are described with a JSON schema, and a call and its result are linked by call_id. You run the call loop.
  • Chats on generateContent (client.chats.create) — now legacy but still supported. Only here can the Python SDK call your functions for you (automatic function calling) and build the schema from the name, docstring and type annotations.

You need the google-genai SDK (pip install -U google-genai). The examples use gemini-4-hydrogen: it launched on 2026-11-12, is available on the free tier, and Google recommends it as the upgrade from Gemini 3.8 Flash and the 2.5 models. gemini-2.5-flash is deprecated; since 2026-12-01 requests to it are routed to gemini-3.5-flash-lite.

The rest of this lesson opens after a free sign-up

Sign up with email or Google: the first two lessons of every course stay open for good, and the whole catalog is open for 7 days. No card needed.

Sign up freeOr a trial lesson, no sign-up →
In this lesson
What Is Function CallingDefining Tool FunctionsChat with Automatic Function CallingMath Tools ExampleInspecting Chat HistoryManual Loop on the Interactions APIModes and Parallel CallsAuto Schema GenerationHow Many Functions to PassPracticeReady promptQuiz
CoursesLLM coursesFor teamsPricingFAQBlogAboutPrivacy
© 2026 AcademlDevelopment & promotion —MMIX — Marketing Mix
Get started free