Skip to main content
POST
Run Agent

Query Parameters

string
The session ID to continue the agent session conversation. If not provided, a new agent session will be created.

Request Body

string
required
The task or message to run the agent with.
string
A system prompt to provide system information to the agent. The Agents API defaults to the Agentbase default system prompt.
string
default:"base"
The mode of the agent. Can be flash, base or max. Flash mode is great for simple, one-off tasks. Base mode is much faster and cheaper, with comparable performance to max mode. The Agents API defaults to base.
Workflow[]
A set of declarative workflows for the agent to execute. Each workflow is a DAG (Directed Acyclic Graph) of steps that the agent interprets and executes dynamically. The agent decides how to implement each step based on its description, making this a truly AI-native workflow system rather than a deterministic workflow builder.
Workflow Schema:
  • id (string, required): Unique identifier for the workflow
  • name (string, required): Name of the workflow
  • description (string, required): What the workflow accomplishes
  • steps (array, required): Array of step objects
Step Schema:
  • id (string, required): Unique identifier for the step
  • name (string, required): Name of the step
  • description (string, required): What the step should accomplish - the agent interprets this to decide HOW to execute
  • depends_on (string[], required): Array of step IDs that must complete before this step runs. Empty array means the step can run immediately. Steps with no dependencies run in parallel.
Advanced Step Options:
  • optional (boolean, optional): Whether the step can be skipped if it fails
  • retry_policy (object, optional): Retry configuration for the step
  • output_schema (object, optional): JSON schema for expected output validation
string[]
A set of rules to provide to the agent. Rules are a set of constraints that the agent must follow. Defaults to no rules.
{name: string, description: string}[]
A set of agent configurations that enables the agent to transfer conversations to other specialized agents. When provided, the main agent will have access to seamless handoffs between agents based on the conversation context.
This enables multi-agent workflows where specialized agents handle specific types of requests.
{serverName: string, serverUrl: string, auth?: object}[]
A set of MCP servers to provide to the agent. MCP servers configs are not stored within the agent, so each request must include the MCP servers configs, and you can modify them each time. You need to provide both serverName and serverUrl. Optionally include auth for authentication. We have backward compatibility with the old /sse endpoint.
boolean
Whether to run the agent asynchronously on the server. When set to true, the agent runs in the background and you can use the callback parameter to receive agent message events. Defaults to false.
{url: string, headers: object}
A callback endpoint configuration to send agent message events back to. Use this with background: true to receive events at your specified endpoint.
{id: string, name: string}[]
A set of datastores to provide to the agent. Datastores are a set of data sources that the agent can utilize. Datastores are either databases or documents as the knowledge base.
{name: string, description: string, query: string}[]
A set of custom actions based on datastore (database) queries. Allows you to quickly define actions that the agent can use to query your datastores.
boolean
Whether to stream the agent messages token by token. Defaults to false.
{schedule: string | number | Date, message: string}[]
A set of scheduled tasks to run the agent with messages at specific times or intervals. Each schedule can be defined using:
  • A number (seconds from now): 10 runs in 10 seconds
  • A Date string: "2025-01-01" runs at that specific date/time
  • A cron expression: "*/10 * * * *" runs every 10 minutes
Each scheduled task will trigger the agent with the specified message at the scheduled time. Returns task IDs that can be used to cancel schedules later.
{name: string, strict: boolean, schema: object}
Configuration for an extra final output event that processes the entire agent message thread and produces a structured output based on the provided JSON schema.
See Streaming Message Types for event details.