@devries-cameron20 / composio Mirror · read-only
Fork 0

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 21, 06:00 UTC

next
md 103 lines 2.52 KB
Rendered Raw
1 # Google GenAI Provider
2
3 The Google GenAI Provider allows you to integrate Google's Generative AI models (Gemini) with Composio tools.
4
5 ## Installation
6
7 ```bash
8 # Using npm
9 npm install @composio/core @composio/google @google/genai
10
11 # Using yarn
12 yarn add @composio/core @composio/google @google/genai
13
14 # Using pnpm
15 pnpm add @composio/core @composio/google @google/genai
16 ```
17
18 ## Usage
19
20 ```typescript
21 import { Composio } from '@composio/core';
22 import { GoogleProvider } from '@composio/google';
23 import { GoogleGenAI } from '@google/genai';
24
25 // Initialize Google GenAI
26 const ai = new GoogleGenAI({
27 apiKey: process.env.GEMINI_API_KEY,
28 });
29
30 // Initialize Composio with Google Provider
31 const composio = new Composio({
32 apiKey: process.env.COMPOSIO_API_KEY,
33 provider: new GoogleProvider(),
34 });
35
36 // Get tools
37 const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER');
38
39 // Define task
40 const task = "Fetch the details of the user 'haxzie'";
41
42 // Generate content with function calling
43 const response = await ai.models.generateContent({
44 model: 'gemini-3.7-flash',
45 contents: task,
46 config: {
47 tools: [{ functionDeclarations: tools }],
48 },
49 });
50
51 // Handle function calls
52 if (response.functionCalls) {
53 console.log(`Calling tool ${response.functionCalls[0].name}`);
54 const result = await provider.executeToolCall(
55 'default',
56 {
57 name: response.functionCalls[0].name,
58 args: response.functionCalls[0].args
59 }
60 );
61 console.log(JSON.parse(result).data);
62 }
63 ```
64
65 ## Configuration Options
66
67 The Google GenAI provider supports various initialization options:
68
69 ### Gemini Developer API (API Key)
70
71 ```typescript
72 const ai = new GoogleGenAI({
73 apiKey: process.env.GEMINI_API_KEY,
74 });
75 ```
76
77 ### Vertex AI
78
79 ```typescript
80 const ai = new GoogleGenAI({
81 vertexai: {
82 project: 'your-project-id',
83 location: 'us-central1',
84 apiVersion: 'v1',
85 },
86 });
87 ```
88
89 ## Supported Models
90
91 - `gemini-3.7-flash` - Fast, efficient default model for most use cases
92 - `gemini-3.1-pro-preview` - Advanced model with enhanced reasoning and coding capabilities
93 - `gemini-3.5-flash-lite` - Fastest and lowest-cost option for lightweight tasks
94 - `gemini-2.5-flash` - Fast model with thinking capabilities
95 - `gemini-2.5-pro` - Advanced reasoning model
96
97 ## Function Calling
98
99 The provider automatically converts Composio tools to the Google GenAI function declaration format, making it easy to use function calling with Gemini models.
100
101 ## Examples
102
103 See the [examples/google](../../examples/google) directory for complete examples of using the Google GenAI provider with Composio.