agent_swap handoffs and resolving tool calls, until the turn settles, then returns the final assistant text. For a multi-turn conversation where you keep and replay the transcript yourself, use Turn instead.
Path parameters
Request
- Header:
Authorization: Bearer $GRADIENT_API_KEY. The key needs theagents:invokescope. See Authentication. - Header:
content-type: text/plain. - Body: the user’s message as plain UTF-8 text, up to 1 MB. It must not be empty.
Response
On success the engine returns200 with a single field:
Errors
Every invoke is recorded as a production trace, so calls made this way show up alongside chat and voice conversations in the console.