Overview
The Agents API provides direct access to individual AI agents in your organization. Unlike the Chat Completions API which routes requests through an orchestrator, this API allows you to invoke specific agents directly for targeted tasks.Direct Agent Invocation: Use this API when you know exactly which agent should handle your request. For intelligent routing across multiple agents, use the Chat Completions API instead.
Authentication
All endpoints require API key authentication with specific scopes:Default Scopes: The
agents:list and agents:invoke scopes are enabled by default when creating API keys. No additional configuration is needed.X-API-Key header:
Agent Types
Agents in the system are categorized by their execution pattern:List Agents
Retrieve a list of available agents in your organization.Endpoint
Query Parameters
Request Example
cURL
Python
Response
Status Code:200 OK
Response Fields
Agent Object Fields
Invoke Agent (Non-Streaming)
Send a message to a specific agent and receive the complete response.Endpoint
Path Parameters
Request Body
Request Example
cURL
Python
Response
Status Code:200 OK
Response Fields
Invoke Agent (Streaming)
Send a message and receive the response as a real-time stream using Server-Sent Events (SSE).Endpoint
Request Body
Request Example
cURL
Python
JavaScript
SSE Response Format
The streaming response uses OpenAI-compatible format withchoices array:
Streaming Response Example
Chunk Object Fields
Session Continuity
You can maintain conversation context by reusing thesession_id from previous responses:
Python
Error Responses
Common Errors
400 Bad Request - Invalid Agent Type Filter
400 Bad Request - Inactive Agent
402 Payment Required - Insufficient Credits
403 Forbidden - No Subscription
403 Forbidden - Insufficient Scopes
404 Not Found
Best Practices
Choosing the Right Agent
Choosing the Right Agent
Use the List Agents endpoint to discover available agents and their capabilities:
Handling Streaming Responses
Handling Streaming Responses
For streaming responses, implement proper SSE parsing:
Error Handling
Error Handling
Implement comprehensive error handling for production use:
Session Management
Session Management
Efficiently manage sessions for multi-turn conversations:
Related Resources
Authentication
Learn about API key scopes and authentication
Chat Completions
Use orchestrated multi-agent conversations
Sessions API
Manage and retrieve conversation sessions
Error Codes
Full list of error codes and solutions
