Run an agent generation
Sends messages to the agent, resolves its tools, and runs the AI model loop. Background by default: returns 202 Accepted with a generation_id to poll via GET /v1/projects/{project_id}/generations/{generation_id}. Pass ?wait=true to block and receive the result inline, where client tools pause the generation and return requires_action. Streaming (stream: true) implies waiting. Pass idempotency_key to make a retry safe: a request whose key is already claimed runs nothing and answers 202 with the generation the key names.
A credential scoped to a project the agent is shared with, through an accepted share, runs it in that project: on the publisher's configuration, recorded, metered and governed in the grantee project.
Request
- Base URL: https://api.naturali.ai
- URL: https://api.naturali.ai/v1/projects/{project_id}/agents/{agent_id}/generate
- Auth: one of:
- HTTP bearer
- OAuth 2 (authorization code, authorization URL https://api.naturali.ai/authorize, token URL https://api.naturali.ai/token, scopes: mcp:access)
Path parameters
Agent public ID
Query parameters
When omitted or false (default), the generation runs in the background and 202 Accepted is returned immediately with a generation_id to poll. Pass true to block until the generation settles and receive the result. Mutually exclusive with stream: true. An MCP tool call always waits.
Headers
The request's deduplication key. Equivalent to idempotency_key in the request body; sending both with different values is 400 VALIDATION_FAILED. A non-empty string of at most 255 characters.
Request body
Example request
{
"metadata": {
"author": "John",
"revision": 2
},
"idempotency_key": "discord-1287654321098765432",
"knowledge_config": {
"tags": {
"team": "finance",
"env": "prod"
}
}
}Response
Generation result or SSE stream (only when ?wait=true or stream: true)
Example response
{
"id": "gen_V1StGXR8Z5jdHi6B",
"trace_id": "trace_V1StGXR8Z5jdHi6B",
"ai_provider_id": "aip_V1StGXR8Z5jdHi6B"
}Changes
No recorded changes to this operation across all 1 revision of this API.