Providers

Google Gen AI Provider

Use Composio with Gemini through the Google Gen AI SDK

The Google provider transforms Composio tools into a format compatible with Gemini's function calling capabilities through it's API

Setup

pip install google-genai composio_google
npm install @google/genai
npm i @composio/core @composio/gemini
from composio import Composio
from composio_gemini import GeminiProvider
from google import genai
from google.genai import types

# Create composio client
composio = Composio(provider=GeminiProvider())
# Create google client
client = genai.Client()
import {class Composio<TProvider extends BaseComposioProvider<unknown, unknown, unknown> = OpenAIProvider>
This is the core class for Composio. It is used to initialize the Composio SDK and provide a global configuration.
Composio
} from '@composio/core';
import {class GoogleProvider
Google GenAI Provider for Composio SDK Implements the BaseNonAgenticProvider to wrap Composio tools for use with Google's GenAI API
GoogleProvider
} from '@composio/google'
import {class GoogleGenAI
The Google GenAI SDK.
@remarksProvides access to the GenAI features through either the {@link https://cloud.google.com/vertex-ai/docs/reference/rest Gemini API} or the {@link https://cloud.google.com/vertex-ai/docs/reference/rest Vertex AI API}. The {@link GoogleGenAIOptions.vertexai} value determines which of the API services to use. When using the Gemini API, a {@link GoogleGenAIOptions.apiKey} must also be set, when using Vertex AI {@link GoogleGenAIOptions.project} and {@link GoogleGenAIOptions.location} must also be set.@exampleInitializing the SDK for using the Gemini API: ```ts import {GoogleGenAI} from '@google/genai'; const ai = new GoogleGenAI({apiKey: 'GEMINI_API_KEY'}); ```@exampleInitializing the SDK for using the Vertex AI API: ```ts import {GoogleGenAI} from '@google/genai'; const ai = new GoogleGenAI({ vertexai: true, project: 'PROJECT_ID', location: 'PROJECT_LOCATION' }); ```
GoogleGenAI
} from '@google/genai'
const const composio: Composio<GoogleProvider>composio = new new Composio<GoogleProvider>(config?: ComposioConfig<GoogleProvider> | undefined): Composio<GoogleProvider>
Creates a new instance of the Composio SDK. The constructor initializes the SDK with the provided configuration options, sets up the API client, and initializes all core models (tools, toolkits, etc.).
@paramconfig - Configuration options for the Composio SDK@paramconfig.apiKey - The API key for authenticating with the Composio API@paramconfig.baseURL - The base URL for the Composio API (defaults to production URL)@paramconfig.allowTracking - Whether to allow anonymous usage analytics@paramconfig.provider - The provider to use for this Composio instance (defaults to OpenAIProvider)@example```typescript // Initialize with default configuration const composio = new Composio(); // Initialize with custom API key and base URL const composio = new Composio({ apiKey: 'your-api-key', baseURL: 'https://api.composio.dev' }); // Initialize with custom provider const composio = new Composio({ apiKey: 'your-api-key', provider: new CustomProvider() }); ```
Composio
({
apiKey?: string | null | undefined
The API key for the Composio API.
@example'sk-1234567890'
apiKey
: "your-composio-api-key",
provider?: GoogleProvider | undefined
The tool provider to use for this Composio instance.
@examplenew OpenAIProvider()
provider
: new new GoogleProvider(): GoogleProvider
Creates a new instance of the GoogleProvider. This provider enables integration with Google's GenAI API, supporting both the Gemini Developer API and Vertex AI implementations.
@example```typescript // Initialize the Google provider const provider = new GoogleProvider(); // Use with Composio const composio = new Composio({ apiKey: 'your-api-key', provider: new GoogleProvider() }); // Use the provider to wrap tools for Google GenAI const googleTools = provider.wrapTools(composioTools); ```
GoogleProvider
()
}) const const ai: GoogleGenAIai = new new GoogleGenAI(options: GoogleGenAIOptions): GoogleGenAI
The Google GenAI SDK.
@remarksProvides access to the GenAI features through either the {@link https://cloud.google.com/vertex-ai/docs/reference/rest Gemini API} or the {@link https://cloud.google.com/vertex-ai/docs/reference/rest Vertex AI API}. The {@link GoogleGenAIOptions.vertexai} value determines which of the API services to use. When using the Gemini API, a {@link GoogleGenAIOptions.apiKey} must also be set, when using Vertex AI {@link GoogleGenAIOptions.project} and {@link GoogleGenAIOptions.location} must also be set.@exampleInitializing the SDK for using the Gemini API: ```ts import {GoogleGenAI} from '@google/genai'; const ai = new GoogleGenAI({apiKey: 'GEMINI_API_KEY'}); ```@exampleInitializing the SDK for using the Vertex AI API: ```ts import {GoogleGenAI} from '@google/genai'; const ai = new GoogleGenAI({ vertexai: true, project: 'PROJECT_ID', location: 'PROJECT_LOCATION' }); ```
GoogleGenAI
({
GoogleGenAIOptions.apiKey?: string | undefined
The API Key, required for Gemini API clients.
@remarksRequired on browser runtimes.
apiKey
: "your-gemini-api-key"
})

Usage

user_id = "0000-1111-2222"
tools = composio.tools.get(user_id, tools=["COMPOSIO_SEARCH_DUCK_DUCK_GO_SEARCH"])

# Create genai client config
config = types.GenerateContentConfig(tools=tools)

# # Use the chat interface.
chat = client.chats.create(model="gemini-2.0-flash", config=config)
response = chat.send_message("search about the latest info on windsurf acquisition.")
print(response.text)
// Use a unique identifier for each user in your application
const const user_id: "your-external-user-id"user_id = "your-external-user-id"

// Get tools - this returns already wrapped tools when using GoogleProvider
const const tools: GoogleGenAIToolCollectiontools = await const composio: Composio<GoogleProvider>composio.Composio<GoogleProvider>.tools: Tools<unknown, unknown, GoogleProvider>
List, retrieve, and execute tools
tools
.Tools<unknown, unknown, GoogleProvider>.get<GoogleProvider>(userId: string, slug: string, options?: ToolOptions | undefined): Promise<GoogleGenAIToolCollection> (+1 overload)
Get a specific tool by its slug. This method fetches the tool from the Composio API and wraps it using the provider.
@paramuserId - The user id to get the tool for@paramslug - The slug of the tool to fetch@paramoptions - Optional provider options including modifiers@returnsThe wrapped tool@example```typescript // Get a specific tool by slug const hackerNewsUserTool = await composio.tools.get('default', 'HACKERNEWS_GET_USER'); // Get a tool with schema modifications const tool = await composio.tools.get('default', 'GITHUB_GET_REPOS', { modifySchema: (toolSlug, toolkitSlug, schema) => { // Customize the tool schema return {...schema, description: 'Custom description'}; } }); ```
get
(const user_id: "your-external-user-id"user_id, 'HACKERNEWS_GET_USER')
const const response: GenerateContentResponseresponse = await const ai: GoogleGenAIai.GoogleGenAI.models: Modelsmodels.Models.generateContent: (params: GenerateContentParameters) => Promise<GenerateContentResponse>
Makes an API request to generate content with a given model. For the `model` parameter, supported formats for Vertex AI API include: - The Gemini model ID, for example: 'gemini-2.0-flash' - The full resource name starts with 'projects/', for example: 'projects/my-project-id/locations/us-central1/publishers/google/models/gemini-2.0-flash' - The partial resource name with 'publishers/', for example: 'publishers/google/models/gemini-2.0-flash' or 'publishers/meta/models/llama-3.1-405b-instruct-maas' - `/` separated publisher and model name, for example: 'google/gemini-2.0-flash' or 'meta/llama-3.1-405b-instruct-maas' For the `model` parameter, supported formats for Gemini API include: - The Gemini model ID, for example: 'gemini-2.0-flash' - The model name starts with 'models/', for example: 'models/gemini-2.0-flash' - For tuned models, the model name starts with 'tunedModels/', for example: 'tunedModels/1234567890123456789' Some models support multimodal input and output.
@paramparams - The parameters for generating content.@returnThe response from generating content.@example```ts const response = await ai.models.generateContent({ model: 'gemini-2.0-flash', contents: 'why is the sky blue?', config: { candidateCount: 2, } }); console.log(response); ```
generateContent
({
GenerateContentParameters.model: string
ID of the model to use. For a list of models, see `Google models <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.
model
: 'gemini-2.0-flash-001',
GenerateContentParameters.contents: ContentListUnion
Content of the request.
contents
: "Search for the user 'pg's",
GenerateContentParameters.config?: GenerateContentConfig | undefined
Configuration that contains optional model parameters.
config
: {
GenerateContentConfig.tools?: ToolListUnion | undefined
Code that enables the system to interact with external systems to perform an action outside of the knowledge and scope of the model.
tools
: [{ Tool.functionDeclarations?: FunctionDeclaration[] | undefined
Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating FunctionCall in the response. User should provide a FunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 512 function declarations can be provided.
functionDeclarations
: const tools: GoogleGenAIToolCollectiontools }],
}, }); if (const response: GenerateContentResponseresponse.GenerateContentResponse.functionCalls: FunctionCall[] | undefined
Returns the function calls from the first candidate in the response.
@remarksIf there are multiple candidates in the response, the function calls from the first one will be returned. If there are no function calls in the response, undefined will be returned.@example```ts const controlLightFunctionDeclaration: FunctionDeclaration = { name: 'controlLight', parameters: { type: Type.OBJECT, description: 'Set the brightness and color temperature of a room light.', properties: { brightness: { type: Type.NUMBER, description: 'Light level from 0 to 100. Zero is off and 100 is full brightness.', }, colorTemperature: { type: Type.STRING, description: 'Color temperature of the light fixture which can be `daylight`, `cool` or `warm`.', }, }, required: ['brightness', 'colorTemperature'], }; const response = await ai.models.generateContent({ model: 'gemini-2.0-flash', contents: 'Dim the lights so the room feels cozy and warm.', config: { tools: [{functionDeclarations: [controlLightFunctionDeclaration]}], toolConfig: { functionCallingConfig: { mode: FunctionCallingConfigMode.ANY, allowedFunctionNames: ['controlLight'], }, }, }, }); console.debug(JSON.stringify(response.functionCalls)); ```
functionCalls
&& const response: GenerateContentResponseresponse.GenerateContentResponse.functionCalls: FunctionCall[]
Returns the function calls from the first candidate in the response.
@remarksIf there are multiple candidates in the response, the function calls from the first one will be returned. If there are no function calls in the response, undefined will be returned.@example```ts const controlLightFunctionDeclaration: FunctionDeclaration = { name: 'controlLight', parameters: { type: Type.OBJECT, description: 'Set the brightness and color temperature of a room light.', properties: { brightness: { type: Type.NUMBER, description: 'Light level from 0 to 100. Zero is off and 100 is full brightness.', }, colorTemperature: { type: Type.STRING, description: 'Color temperature of the light fixture which can be `daylight`, `cool` or `warm`.', }, }, required: ['brightness', 'colorTemperature'], }; const response = await ai.models.generateContent({ model: 'gemini-2.0-flash', contents: 'Dim the lights so the room feels cozy and warm.', config: { tools: [{functionDeclarations: [controlLightFunctionDeclaration]}], toolConfig: { functionCallingConfig: { mode: FunctionCallingConfigMode.ANY, allowedFunctionNames: ['controlLight'], }, }, }, }); console.debug(JSON.stringify(response.functionCalls)); ```
functionCalls
.Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.
length
> 0) {
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v24.x/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(`Calling tool ${const response: GenerateContentResponseresponse.GenerateContentResponse.functionCalls: FunctionCall[]
Returns the function calls from the first candidate in the response.
@remarksIf there are multiple candidates in the response, the function calls from the first one will be returned. If there are no function calls in the response, undefined will be returned.@example```ts const controlLightFunctionDeclaration: FunctionDeclaration = { name: 'controlLight', parameters: { type: Type.OBJECT, description: 'Set the brightness and color temperature of a room light.', properties: { brightness: { type: Type.NUMBER, description: 'Light level from 0 to 100. Zero is off and 100 is full brightness.', }, colorTemperature: { type: Type.STRING, description: 'Color temperature of the light fixture which can be `daylight`, `cool` or `warm`.', }, }, required: ['brightness', 'colorTemperature'], }; const response = await ai.models.generateContent({ model: 'gemini-2.0-flash', contents: 'Dim the lights so the room feels cozy and warm.', config: { tools: [{functionDeclarations: [controlLightFunctionDeclaration]}], toolConfig: { functionCallingConfig: { mode: FunctionCallingConfigMode.ANY, allowedFunctionNames: ['controlLight'], }, }, }, }); console.debug(JSON.stringify(response.functionCalls)); ```
functionCalls
[0].FunctionCall.name?: string | undefined
Optional. The name of the function to call. Matches [FunctionDeclaration.name].
name
}`);
const
const functionCall: {
    name: string;
    args: Record<string, unknown>;
}
functionCall
= {
name: stringname: const response: GenerateContentResponseresponse.GenerateContentResponse.functionCalls: FunctionCall[]
Returns the function calls from the first candidate in the response.
@remarksIf there are multiple candidates in the response, the function calls from the first one will be returned. If there are no function calls in the response, undefined will be returned.@example```ts const controlLightFunctionDeclaration: FunctionDeclaration = { name: 'controlLight', parameters: { type: Type.OBJECT, description: 'Set the brightness and color temperature of a room light.', properties: { brightness: { type: Type.NUMBER, description: 'Light level from 0 to 100. Zero is off and 100 is full brightness.', }, colorTemperature: { type: Type.STRING, description: 'Color temperature of the light fixture which can be `daylight`, `cool` or `warm`.', }, }, required: ['brightness', 'colorTemperature'], }; const response = await ai.models.generateContent({ model: 'gemini-2.0-flash', contents: 'Dim the lights so the room feels cozy and warm.', config: { tools: [{functionDeclarations: [controlLightFunctionDeclaration]}], toolConfig: { functionCallingConfig: { mode: FunctionCallingConfigMode.ANY, allowedFunctionNames: ['controlLight'], }, }, }, }); console.debug(JSON.stringify(response.functionCalls)); ```
functionCalls
[0].FunctionCall.name?: string | undefined
Optional. The name of the function to call. Matches [FunctionDeclaration.name].
name
|| '',
args: Record<string, unknown>args: const response: GenerateContentResponseresponse.GenerateContentResponse.functionCalls: FunctionCall[]
Returns the function calls from the first candidate in the response.
@remarksIf there are multiple candidates in the response, the function calls from the first one will be returned. If there are no function calls in the response, undefined will be returned.@example```ts const controlLightFunctionDeclaration: FunctionDeclaration = { name: 'controlLight', parameters: { type: Type.OBJECT, description: 'Set the brightness and color temperature of a room light.', properties: { brightness: { type: Type.NUMBER, description: 'Light level from 0 to 100. Zero is off and 100 is full brightness.', }, colorTemperature: { type: Type.STRING, description: 'Color temperature of the light fixture which can be `daylight`, `cool` or `warm`.', }, }, required: ['brightness', 'colorTemperature'], }; const response = await ai.models.generateContent({ model: 'gemini-2.0-flash', contents: 'Dim the lights so the room feels cozy and warm.', config: { tools: [{functionDeclarations: [controlLightFunctionDeclaration]}], toolConfig: { functionCallingConfig: { mode: FunctionCallingConfigMode.ANY, allowedFunctionNames: ['controlLight'], }, }, }, }); console.debug(JSON.stringify(response.functionCalls)); ```
functionCalls
[0].FunctionCall.args?: Record<string, unknown> | undefined
Optional. The function parameters and values in JSON object format. See [FunctionDeclaration.parameters] for parameter details.
args
|| {},
}; const const result: stringresult = await const composio: Composio<GoogleProvider>composio.Composio<GoogleProvider>.provider: GoogleProvider
The tool provider instance used for wrapping tools in framework-specific formats
provider
.GoogleProvider.executeToolCall(userId: string, tool: GoogleGenAIFunctionCall, options?: ExecuteToolFnOptions, modifiers?: ExecuteToolModifiers): Promise<string>
Executes a tool call from Google GenAI. This method processes a function call from Google's GenAI API, executes the corresponding Composio tool, and returns the result.
@paramuserId - The user ID for authentication and tracking@paramtool - The Google GenAI function call to execute@paramoptions - Optional execution options like connected account ID@parammodifiers - Optional execution modifiers for tool behavior@returnsThe result of the tool execution as a JSON string@example```typescript // Execute a tool call from Google GenAI const functionCall = { name: 'SEARCH_TOOL', args: { query: 'composio documentation' } }; const result = await provider.executeToolCall( 'user123', functionCall, { connectedAccountId: 'conn_xyz456' } ); // Parse the result and use it in your application const searchResults = JSON.parse(result); console.log(searchResults); // You can also use the result to continue the conversation const genAI = new GoogleGenerativeAI('YOUR_API_KEY'); const model = genAI.getGenerativeModel({ model: 'gemini-pro' }); await model.generateContent({ contents: [ { role: 'user', parts: [{ text: 'Search for Composio' }] }, { role: 'model', parts: [{ functionResponse: { name: 'SEARCH_TOOL', response: result } }] } ] }); ```
executeToolCall
(const user_id: "your-external-user-id"user_id,
const functionCall: {
    name: string;
    args: Record<string, unknown>;
}
functionCall
);
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v24.x/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(`Result: ${const result: stringresult}`);
} else { var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v24.x/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('No function calls in the response');
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v24.x/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(const response: GenerateContentResponseresponse.GenerateContentResponse.text: string | undefined
Returns the concatenation of all text parts from the first candidate in the response.
@remarksIf there are multiple candidates in the response, the text from the first one will be returned. If there are non-text parts in the response, the concatenation of all text parts will be returned, and a warning will be logged. If there are thought parts in the response, the concatenation of all text parts excluding the thought parts will be returned.@example```ts const response = await ai.models.generateContent({ model: 'gemini-2.0-flash', contents: 'Why is the sky blue?', }); console.debug(response.text); ```
text
);
}

Modifiers

Modifiers are functions that can be used to intercept and optionally modify the schema, the tool call request and the response from the tool call.

OpenAI provider modifiers are the standard framework modifiers. Read more here: Modifying tool schemas