Skip to main content
Run the Alfera worker on a question and get back an answer built from your workspace memory. There are two ways to call this endpoint: streaming (the default) and queued. Use streaming when you can hold a connection open and want to show the answer as it is typed. Use queued when you are inside a webhook handler, a serverless function, or a job queue, and need to return immediately and poll later.

Endpoint

Required scope: answers.write

Streaming mode (default)

Streaming is the default behavior when you omit the stream field or set it to true. The response is text/event-stream.

Request fields

string
required
The question you want the worker to answer. 1 to 8000 characters.
string
Your own thread key. Reuse it to continue a conversation. 1 to 200 characters.
object
{ id, name? }. Name the person so the worker can surface facts about them.
string
Which worker answers. Defaults to main. 1 to 200 characters.
boolean
Defaults to true. Keep it true for streaming mode.
array
Pass ["sources"] to receive the facts the answer was built from.

Example request

Event sequence

The stream sends five possible event names and no others. Every stream ends with done.

Example stream

Streaming creates are not idempotent. Retrying after a disconnect starts a new run. For retry safety, use queued mode with an Idempotency-Key.

Queued mode

Set stream: false to queue the question and receive an answer_id immediately. Poll GET /v1/answers/:answer_id until the status is completed or failed.

Extra fields for queued mode

boolean
required
Must be false.
string
Retry key. Send the same key with the same body to get the same answer_id without creating a second run.

Example request

Queued response

Idempotency rules

  • Repeating the same Idempotency-Key with the exact same body returns the original response: same answer_id, no second run.
  • Reusing the same key with a different request returns 409 idempotency_key_reused.
  • Always generate a fresh key for each new question.

Read an answer

Poll this endpoint until status is completed or failed.

Query parameters

string
Pass sources to include the grounding facts. sources is the only supported value.

Example request

Example response

Polling guidance

Answers take seconds to minutes. Poll every 1 to 2 seconds, not every 50 milliseconds. The rate limit is shared with your other calls. While status is not completed, output_text is "".

Status lifecycle

A failed answer carries an error object with the same shape as the stream’s answer.failed event.

Error codes