Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 09:30 UTC
docs: Rewrite Google GenAI provider page with Steps pattern and agentic loop
- Restructured with Steps (Install, Configure API Keys, Create session) - Added agentic loop using Chat API for both Python and TypeScript - Python uses execute_tool_call + Part.from_function_response - TypeScript uses executeToolCall + functionResponse parts - Added groupId/persist tabs for cross-step language sync - Pending full e2e test (blocked on SDK fix PR #2644 for examples stripping) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sushmithamallesh committed
Feb 17, 2026 at 14:19 UTC
1a55a4f81a41288f6a88f0a22f3c63de95f3d85b
1 file changed
+61
-21
docs/content/docs/providers/google.mdx
+61
-21
@@ -1,14 +1,16 @@
1
---
2
title: Google Gen AI
3
description: Build an agent with Gemini and enable it to use 800+ tools with Composio.
4
-keywords: [gemini]
4
+keywords: [gemini, google genai]
5
---
6
7
-The Google provider transforms Composio tools into a format compatible with Gemini's function calling capabilities through its API.
7
+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.
8
9
-## Setup
9
+<Steps>
10
+<Step>
11
+**Install**
12
11
-<Tabs items={["Python", "TypeScript"]}>
13
+<Tabs groupId="language" items={["Python", "TypeScript"]} persist>
14
<Tab value="Python">
15
```bash
16
pip install composio composio_google google-genai
@@ -20,10 +22,25 @@ npm install @composio/core @composio/google @google/genai
22
```
23
</Tab>
24
</Tabs>
25
+</Step>
26
24
-## Usage
27
+<Step>
28
+**Configure API Keys**
29
26
-<Tabs items={["Python", "TypeScript"]}>
30
+<Callout type="info">
31
+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).
32
+</Callout>
33
+
34
+```txt title=".env"
35
+COMPOSIO_API_KEY=xxxxxxxxx
36
+GOOGLE_API_KEY=xxxxxxxxx
37
+```
38
+</Step>
39
+
40
+<Step>
41
+**Create session and run**
42
+
43
+<Tabs groupId="language" items={["Python", "TypeScript"]} persist>
44
<Tab value="Python">
45
```python
46
from composio import Composio
@@ -39,17 +56,26 @@ session = composio.create(user_id="user_123")
56
tools = session.tools()
57
58
config = types.GenerateContentConfig(tools=tools)
42
-
59
chat = client.chats.create(model="gemini-2.0-flash", config=config)
60
response = chat.send_message("Star the composiohq/composio repository on github")
61
+
62
+# Agentic loop — keep executing tool calls until the model responds with text
63
+while response.function_calls:
64
+ parts = []
65
+ for fc in response.function_calls:
66
+ result = composio.provider.execute_tool_call(user_id="user_123", function_call=fc)
67
+ parts.append(types.Part.from_function_response(name=fc.name, response=result))
68
+ response = chat.send_message(parts)
69
+
70
print(response.text)
71
```
72
</Tab>
73
<Tab value="TypeScript">
74
```typescript
75
+// @noErrors
76
import { Composio } from '@composio/core';
77
import { GoogleProvider } from '@composio/google';
52
-import { GoogleGenAI } from '@google/genai';
78
+import { GoogleGenAI, type Part } from '@google/genai';
79
80
const composio = new Composio({
81
provider: new GoogleProvider(),
@@ -60,25 +86,39 @@ const ai = new GoogleGenAI({ apiKey: process.env.GOOGLE_API_KEY! });
86
const session = await composio.create("user_123");
87
const tools = await session.tools();
88
63
-const response = await ai.models.generateContent({
64
- model: 'gemini-2.0-flash-001',
65
- contents: "Star the composiohq/composio repository on github",
89
+const chat = ai.chats.create({
90
+ model: 'gemini-2.0-flash',
91
config: {
92
tools: [{ functionDeclarations: tools }],
93
},
94
});
95
71
-if (response.functionCalls && response.functionCalls.length > 0) {
72
- const functionCall = {
73
- name: response.functionCalls[0].name || '',
74
- args: response.functionCalls[0].args || {},
75
- };
76
- const result = await composio.provider.executeToolCall("user_123", functionCall);
77
- console.log(result);
78
-} else {
79
- console.log(response.text);
96
+let response = await chat.sendMessage({
97
+ message: "Star the composiohq/composio repository on github",
98
+});
99
+
100
+// Agentic loop — keep executing tool calls until the model responds with text
101
+while (response.functionCalls && response.functionCalls.length > 0) {
102
+ const parts: Part[] = [];
103
+ for (const fc of response.functionCalls) {
104
+ const result = await composio.provider.executeToolCall("user_123", {
105
+ name: fc.name || '',
106
+ args: (fc.args || {}) as Record<string, unknown>,
107
+ });
108
+ parts.push({
109
+ functionResponse: {
110
+ id: fc.id,
111
+ name: fc.name,
112
+ response: JSON.parse(result),
113
+ },
114
+ });
115
+ }
116
+ response = await chat.sendMessage({ message: parts });
117
}
118
+
119
+console.log(response.text);
120
```
121
</Tab>
122
</Tabs>
84
-
123
+</Step>
124
+</Steps>