REST APIGeneration

Generate

Run stateless generation.

POST/v1/agents/:agentId/generation

Overview

Get a one-off answer from an agent without starting a session. Use generation for single-shot text or JSON that matches a schema when you do not need to continue the conversation.

Stateless Tool approval

Stateless generation follows the agent's approvalInChat policy, but nobody can approve a tool call mid-request. Calls that need manual approval, fail automatic review, or are escalated by it are blocked. The agent keeps working with the calls it is allowed to make and is told which actions were blocked. See Tool approvals.

Endpoints

GeneratePOST/v1/agents/:agentId/generation

Run stateless generation.

Runs one turn of the agent without saving a session and streams the answer as plain text. Send exactly one of prompt or promptId; variables is allowed only with promptId. With object output, the stream is JSON text that matches your schema. A failure before the stream starts returns a JSON error. Once the stream has started, a failure ends it early and the status stays 200.

Request

Requires bearer authentication and a JSON body.

FieldTypeLocationRequiredDescription
agentIdstringpathrequiredID of the agent.
promptstringbodyThe prompt to answer. Send either prompt or promptId.
promptIdstringbodyID of a saved prompt to use instead of prompt.
variablesobjectbodyValues for the saved prompt's variables. Allowed only with promptId, and must name exactly the prompt's variables.
outputobjectbodyrequiredWhat to stream back: {"type":"text"} for text, or {"type":"object","schema":{…}} for JSON that matches a JSON Schema.
versionintegerbodyAgent version to run. Leave it out to run the current version. 1–2147483647.
userIdstringbodyYour end user's ID, used for usage attribution. Defaults to "".
metadataobjectbodyYour own key-value data, recorded with the usage. Defaults to {}.

Response

Streamed generation output.

Streaming response bodybodyrequired

Streaming response body

Returns 200 OK as text/plain. Streamed generation output.

Open Settings, choose Security, and select Reset password.

Errors

StatusCodesDescription
400validation_failed, provider_required, prompt_variable_missing, prompt_variable_unknownThe request is invalid
401unauthorizedThe credential is missing or invalid
402subscription_required, usage_credit_required, merchant_subscription_required, merchant_balance_requiredAn active subscription or usage credit is required
403merchant_customer_unmappedThe end user cannot run this request
404not_found, agent_version_not_found, workspace_not_foundThe resource was not found
409agent_disabledThe request conflicts with the resource's current state
429quota_exceeded, rate_limitedToo many requests
503service_unavailable, merchant_eligibility_unavailableThe service is temporarily unavailable

See REST errors for the error envelope and shared codes.

cURL

curl --no-buffer --request POST "$BLAZING_AGENTS_BASE_URL/v1/agents/ag_1234567890ABCDEF/generation" \
  --header "Authorization: Bearer $BLAZING_AGENTS_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"prompt":"Explain how to reset a password in one sentence.","output":{"type":"text"}}'

Next