> ## Documentation Index
> Fetch the complete documentation index at: https://composio-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Google

> Build an agent with Gemini or Google ADK and enable it to use 1000+ tools with Composio.

The Google provider formats Composio tools for [Gemini](https://ai.google.dev/) and the [Google Agent Development Kit (ADK)](https://google.github.io/adk-docs/). Pick the tab that matches your setup.

> [tab] Gemini
>
> In Python, the Gemini provider (`composio_gemini`) wraps Composio tools as typed callables, and the `google-genai` SDK's Automatic Function Calling executes tool calls inside the chat loop for you. In TypeScript, the Google provider transforms Composio tools into Gemini function declarations, and you run the loop: execute each call with `composio.provider.executeToolCall(session, functionCall)`, feed the result back, and repeat until the model replies with text.
>
> Object arguments that declare no properties preserve arbitrary nested keys in both providers. The TypeScript provider also adds `type: "object"` to schema nodes that declare `properties` without a type, which is the shape Gemini expects for object schemas.
>
> If you use the Python `composio_google` provider with a manual Gemini loop, pass the Session to `composio.provider.execute_tool_call(session=session, function_call=function_call)` or `composio.provider.handle_response(session=session, response=response)`. Both helpers execute through that Session. Calls with `user_id` use direct execution for tools fetched with `tools.get()`. The `composio_gemini` callables in the example below already carry the Session.
>
> If you turn off Automatic Function Calling in `composio_gemini`, pass `session=session` to `composio.provider.handle_response(response, session=session)` for tools fetched with `session.tools()`. For tools fetched with `composio.tools.get(user_id="alice", ...)`, use `composio.provider.handle_response(response, user_id="alice")`. Each call uses the selected fetch's schema validation (including schema modifiers) and execution modifiers. Session calls also preserve session routing, so local custom tools in a `COMPOSIO_MULTI_EXECUTE_TOOL` batch run in process.
>
> > [!WARNING]
> >
> > You can omit `user_id` and `session` from `GeminiProvider.handle_response` only when the provider has wrapped tools for a single user or session. Once it has wrapped tools for more than one, omitting both raises `ValueError` and executes nothing. Always pass the matching identity when you share a `Composio` instance across users or sessions. Automatic Function Calling already uses callables bound to their user or session.
>
> **1. Install**
>
> **Install**
>
> > [tab] Python
> >
> > ```bash uv theme={null}
> > uv add composio composio_gemini google-genai
> > ```
> >
> > ```bash pip theme={null}
> > pip install composio composio_gemini google-genai
> > ```
>
> > [tab] TypeScript
> >
> > ```bash npm theme={null}
> > npm install @composio/core @composio/google @google/genai
> > ```
> >
> > ```bash pnpm theme={null}
> > pnpm add @composio/core @composio/google @google/genai
> > ```
> >
> > ```bash yarn theme={null}
> > yarn add @composio/core @composio/google @google/genai
> > ```
> >
> > ```bash bun theme={null}
> > bun add @composio/core @composio/google @google/genai
> > ```
>
> **2. Configure API Keys**
>
> **Configure API Keys**
>
> > [!NOTE]
> >
> > Set `COMPOSIO_API_KEY` with your API key from [Settings](https://dashboard.composio.dev/~/project/settings/api-keys?utm_source=docs\&utm_medium=content\&utm_campaign=docs-providers-google) and `GOOGLE_API_KEY` with your [Google API key](https://aistudio.google.com/apikey).
>
> ```txt .env theme={null}
> COMPOSIO_API_KEY=xxxxxxxxx
> GOOGLE_API_KEY=xxxxxxxxx
> ```
>
> **3. Create session and run**
>
> **Create session and run**
>
> > [tab] Python
> >
> > ```python theme={null}
> > from composio import Composio
> > from composio_gemini import GeminiProvider
> > from google import genai
> > from google.genai import types
> >
> > composio = Composio(provider=GeminiProvider())
> > client = genai.Client()
> >
> > # Create a session for your user
> > session = composio.create(user_id="user_123")
> > tools = session.tools()
> >
> > config = types.GenerateContentConfig(tools=tools)
> > chat = client.chats.create(model="gemini-3-pro-preview", config=config)
> >
> > # Automatic Function Calling executes tool calls inside the chat loop
> > response = chat.send_message(
> >     "Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'"
> > )
> > print(response.text)
> > ```
>
> > [tab] TypeScript
> >
> > ```typescript theme={null}
> > import { Composio } from '@composio/core';
> > import { GoogleProvider } from '@composio/google';
> > import { GoogleGenAI, type Part } from '@google/genai';
> >
> > const composio = new Composio({
> >     provider: new GoogleProvider(),
> > });
> > const ai = new GoogleGenAI({ apiKey: process.env.GOOGLE_API_KEY! });
> >
> > // Create a session for your user
> > const session = await composio.create("user_123");
> > const tools = await session.tools();
> >
> > const chat = ai.chats.create({
> >     model: 'gemini-3-pro-preview',
> >     config: {
> >         tools: [{ functionDeclarations: tools }],
> >     },
> > });
> >
> > let response = await chat.sendMessage({
> >     message: "Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'",
> > });
> >
> > // Agentic loop: execute each tool call through the session until the model responds with text
> > while (response.functionCalls && response.functionCalls.length > 0) {
> >     const parts: Part[] = [];
> >     for (const fc of response.functionCalls) {
> >         const result = await composio.provider.executeToolCall(session, {
> >             name: fc.name || '',
> >             args: (fc.args || {}) as Record<string, unknown>,
> >         });
> >         parts.push({
> >             functionResponse: {
> >                 id: fc.id,
> >                 name: fc.name,
> >                 response: JSON.parse(result),
> >             },
> >         });
> >     }
> >     response = await chat.sendMessage({ message: parts });
> > }
> >
> > console.log(response.text);
> > ```
>
> > [!NOTE]
> >
> > Pass the session to `executeToolCall` when the model received tools from `session.tools()`. The helper preserves the provider's argument normalization and executes the call through that session, so session meta-tools such as `COMPOSIO_SEARCH_TOOLS` keep working. For tools fetched via [`tools.get`](https://composio-preview.mintlify.site/docs/tools-direct/executing-tools), pass the user ID instead. Passing a session requires `@composio/core` ≥ 0.17.0 with `@composio/google` ≥ 0.12.0; on earlier versions, execute session tools with [`session.execute()`](https://composio-preview.mintlify.site/docs/how-composio-works#executing-session-tools). The Python Gemini tab needs neither: Automatic Function Calling runs provider-wrapped callables, which carry the session.

> [tab] ADK
>
> The Google ADK provider transforms Composio tools into ADK's `FunctionTool` format. Unlike Gemini function calling, ADK runs the tool loop for you: hand the tools to an `Agent`, and the `Runner` executes calls and continues until the agent produces a final response. ADK integration is Python-only.
>
> **1. Install**
>
> **Install**
>
> ```bash uv theme={null}
> uv add composio composio_google_adk google-adk
> ```
>
> ```bash pip theme={null}
> pip install composio composio_google_adk google-adk
> ```
>
> **2. Configure API Keys**
>
> **Configure API Keys**
>
> > [!NOTE]
> >
> > Set `COMPOSIO_API_KEY` with your API key from [Settings](https://dashboard.composio.dev/~/project/settings/api-keys?utm_source=docs\&utm_medium=content\&utm_campaign=docs-providers-google) and `GOOGLE_API_KEY` with your [Google API key](https://aistudio.google.com/apikey).
>
> ```txt .env theme={null}
> COMPOSIO_API_KEY=xxxxxxxxx
> GOOGLE_API_KEY=xxxxxxxxx
> ```
>
> **3. Create session and run**
>
> **Create session and run**
>
> ```python theme={null}
> from composio import Composio
> from composio_google_adk import GoogleAdkProvider
> from google.adk.agents import Agent
> from google.adk.runners import Runner
> from google.adk.sessions import InMemorySessionService
> from google.genai import types
>
> composio = Composio(provider=GoogleAdkProvider())
>
> # Create a session for your user
> session = composio.create(user_id="user_123")
> tools = session.tools()
>
> agent = Agent(
>     name="email_agent",
>     model="gemini-3-pro-preview",
>     instruction="You are an AI agent that sends emails using Gmail.",
>     tools=tools,
> )
>
> session_service = InMemorySessionService()
> adk_session = session_service.create_session_sync(
>     app_name="email_agent",
>     user_id="user_123",
>     session_id="session_1",
> )
> runner = Runner(
>     agent=agent,
>     app_name="email_agent",
>     session_service=session_service,
> )
>
> content = types.Content(
>     role="user",
>     parts=[types.Part(text="Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'")],
> )
>
> events = runner.run(user_id="user_123", session_id="session_1", new_message=content)
> for event in events:
>     if event.is_final_response() and event.content and event.content.parts:
>         print(event.content.parts[0].text)
> ```
>
> ### Argument validation
>
> The Python Google ADK provider validates tool arguments against the tool's JSON schema before execution. It preserves every key the schema allows, including keys allowed by `additionalProperties` or `patternProperties`. If the model omits an optional argument, the schema's declared default applies; arguments without defaults stay absent. Invalid `patternProperties` or schema-valued `additionalProperties` raise an error when the tool is wrapped.
>
> > [!WARNING]
> >
> > Invalid arguments return an error result to the agent: `{"successful": false, "error": "...", "data": null}`. Values must match their declared types: `"5"` is rejected for an integer argument. For schemas with named properties, unknown top-level keys are rejected unless the schema allows them.
>
> ADK builds tool declarations from named parameters, so a wholly free-form argument object isn't advertised as open and the model may omit its keys. Free-form objects nested under a declared argument work with ADK.

## Next

> [card] [What is a session?](https://composio-preview.mintlify.site/docs/how-composio-works.md)
>
> How sessions scope users, tools, and auth, and how to reuse them across requests.
