Send a message to an AI Studio Agent and get a response, with optional streaming and multi-turn conversation support.
conversationId in every response that you can pass in subsequent requests to maintain context.POST /{agent_name}/stream and uses Server-Sent Events (SSE).
| Type | Fields | Description |
|---|---|---|
start | conversation_id | Agent started processing the request |
content | content | Text chunk from the agent’s response |
tool_use | tool_name | Agent is invoking an MCP tool |
end | - | Agent finished generating the response |
error | error | An error occurred during processing |
Conversation class automatically manages conversation context across messages, passing the
conversationId between turns so the agent retains full history.
a prefix (Python) or are natively async (TypeScript):
| Sync | Async |
|---|---|
agent.call() | await agent.acall() |
agent.stream() | await agent.astream() |
conv.send() | await conv.asend() |
| Code | Exception | Description |
|---|---|---|
401 | AuthenticationError | Invalid or expired JWT token |
403 | AgentNotEnabledError | Agent exists but is not API-enabled |
404 | AgentNotFoundError | No agent with the given name exists |
429 | RateLimitError | Too many requests — retry after the indicated delay |
500 | AgentExecutionError | Internal error during agent execution |