Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
docs: Rewrite Google GenAI provider page with Steps pattern and agentic loop
Sushmithamallesh1a55a4f81a41
diff --git a/docs/content/docs/providers/google.mdx b/docs/content/docs/providers/google.mdxindex a085a51a9..7dee0f876 100644--- a/docs/content/docs/providers/google.mdx+++ b/docs/content/docs/providers/google.mdx@@ -1,14 +1,16 @@---title: Google Gen AIdescription: Build an agent with Gemini and enable it to use 800+ tools with Composio.-keywords: [gemini]+keywords: [gemini, google genai]----The Google provider transforms Composio tools into a format compatible with Gemini's function calling capabilities through its API.+The Google Gen AI provider transforms Composio tools into a format compatible with [Gemini's function calling](https://ai.google.dev/gemini-api/docs/function-calling) capabilities.-## Setup+<Steps>+<Step>+**Install**-<Tabs items={["Python", "TypeScript"]}>+<Tabs groupId="language" items={["Python", "TypeScript"]} persist><Tab value="Python">```bashpip install composio composio_google google-genai@@ -20,10 +22,25 @@ npm install @composio/core @composio/google @google/genai```</Tab></Tabs>+</Step>-## Usage+<Step>+**Configure API Keys**-<Tabs items={["Python", "TypeScript"]}>+<Callout type="info">+Set `COMPOSIO_API_KEY` with your API key from [Settings](https://platform.composio.dev/?next_page=/settings) and `GOOGLE_API_KEY` with your [Google API key](https://aistudio.google.com/apikey).+</Callout>++```txt title=".env"+COMPOSIO_API_KEY=xxxxxxxxx+GOOGLE_API_KEY=xxxxxxxxx+```+</Step>++<Step>+**Create session and run**++<Tabs groupId="language" items={["Python", "TypeScript"]} persist><Tab value="Python">```pythonfrom composio import Composio@@ -39,17 +56,26 @@ session = composio.create(user_id="user_123")tools = session.tools()config = types.GenerateContentConfig(tools=tools)-chat = client.chats.create(model="gemini-2.0-flash", config=config)response = chat.send_message("Star the composiohq/composio repository on github")++# Agentic loop — keep executing tool calls until the model responds with text+while response.function_calls:+ parts = []+ for fc in response.function_calls:+ result = composio.provider.execute_tool_call(user_id="user_123", function_call=fc)+ parts.append(types.Part.from_function_response(name=fc.name, response=result))+ response = chat.send_message(parts)+print(response.text)```</Tab><Tab value="TypeScript">```typescript+// @noErrorsimport { Composio } from '@composio/core';import { GoogleProvider } from '@composio/google';-import { GoogleGenAI } from '@google/genai';+import { GoogleGenAI, type Part } from '@google/genai';const composio = new Composio({provider: new GoogleProvider(),@@ -60,25 +86,39 @@ const ai = new GoogleGenAI({ apiKey: process.env.GOOGLE_API_KEY! });const session = await composio.create("user_123");const tools = await session.tools();-const response = await ai.models.generateContent({- model: 'gemini-2.0-flash-001',- contents: "Star the composiohq/composio repository on github",+const chat = ai.chats.create({+ model: 'gemini-2.0-flash',config: {tools: [{ functionDeclarations: tools }],},});-if (response.functionCalls && response.functionCalls.length > 0) {- const functionCall = {- name: response.functionCalls[0].name || '',- args: response.functionCalls[0].args || {},- };- const result = await composio.provider.executeToolCall("user_123", functionCall);- console.log(result);-} else {- console.log(response.text);+let response = await chat.sendMessage({+ message: "Star the composiohq/composio repository on github",+});++// Agentic loop — keep executing tool calls 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("user_123", {+ 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);```</Tab></Tabs>-+</Step>+</Steps>