await agent.run({
	options: {
		voice: true // allow audio output
	},
	inputs: {
		message: "Hello!"
	},
	hooks: {
		onToken: (token) => console.log(token)
	}
});
{
	"run_id": "RUN_1",
	"session_id": "SESSION_1",
	"content": "Hey, how can I assist you?",
	"audio": [],
	"tools_calls": []
}

The run method is the primary way to interact with an agent. It initiates the agent’s processing based on the provided inputs and returns the generated response.

Agents can call external tools. check addTool

Arguments

Takes one argument passed as an object with the following properties:

inputs
Inputs
required

Used to specify the input properties for the agent run. It should be an object adhering to the Inputs structure. You can pass a text message, list of audio files, and a list of images.

Reference to Inputs

options
RunOptions

Used to specify the run options, like the session ID, run ID, voice output, and some other options.

Reference to RunOptions

hooks
Hooks

Allows you to provide a Hooks object to establish real-time communication channels with the agent during its processing.

Reference to Hooks

Response

response
Promise<AgentResponse>

The run method returns a Promise that resolves to an AgentResponse object upon successful agent run completion. This object contains the agent’s generated response and other relevant information about the run.

Reference to AgentResponse

await agent.run({
	options: {
		voice: true // allow audio output
	},
	inputs: {
		message: "Hello!"
	},
	hooks: {
		onToken: (token) => console.log(token)
	}
});
{
	"run_id": "RUN_1",
	"session_id": "SESSION_1",
	"content": "Hey, how can I assist you?",
	"audio": [],
	"tools_calls": []
}