Get a turn's status

Polls an agent turn's status without holding the SSE stream open

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

Returns where a turn has got to, without holding a stream open.

This is for clients that cannot consume SSE — a serverless function that would time out, a webhook worker, a batch job. Fire agent_ask, keep the threadResponseId from the init frame, disconnect, then poll here until the turn settles and read it with Get a turn's result.

Basic Usage

GET /v2/projects/../stream/agent_ask/7/status
{
  "threadResponseId": 7,
  "threadId": 5,
  "status": "FINISHED"
}

Status values

StatusMeaning
NOT_STARTEDThe turn is provisioning or still running. Keep polling.
FINISHEDThe turn completed. Read it with Get a turn's result.
FAILEDThe turn errored. The error event is in the result.
INTERRUPTEDThe turn was cancelled, or the client disconnected mid-turn.

Polling pattern

// 1. Start the turn and read only the init frame, then close the connection.
const { threadResponseId } = await startTurnAndReadInit({
  projectId: 1,
  question: 'Which 5 states have the most customers?',
});

// 2. Poll until the turn settles.
let status = 'NOT_STARTED';
while (status === 'NOT_STARTED') {
  await sleep(2000);
  ({ status } = await getStatus(threadResponseId));
}

// 3. Read the whole turn back.
const { events } = await getResult(threadResponseId);

The API key is authorized against the project that owns the turn, so you do not pass a project id here.

🔗

Learn more


Path Params
integer
required
Responses

Language
Credentials
Bearer
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json