Skip to Content
Docs
ReferenceRead

Follow several turns

POST
/get_turns

Follows up to 10 turns create_with_awen started, in one call. Each turn reads as get_turn reads it: status, task_counts, files, more_tasks, failure, cost_usd and its reply's text, with the same meanings. The call waits up to wait_seconds (0 to 30, default 15) and answers as soon as any turn changes, or at once when none can change any more, so call it again at once while a turn is working, with no other pause. Pass the last cursor back with the same turn_ids, so a change between two calls is not missed: a turn's text is then left out when it has not changed since that answer. A turn that is not found answers error and no other field. Call get_turn for a turn's tasks and why each failed, and with include_downloads for its files' download links.

Needs a key with awen:read. Costs 2 units of the key's rate limit.

Authorization

apiKey
headerAuthorizationBearer <token>

An API key from Settings → Connected apps → API keys, sent as Authorization: Bearer awen_sk_…. Keep it on a server: a request from a web page is refused.

Request Body

application/json
  1. body
turn_ids*array<>

The turn_ids create_with_awen returned, conversations' active_turn_id, or answers' turn_id from fetch on a conversation.

Items1 <= items <= 10
cursor?string

The cursor of the last answer. Without it, the wait starts from the turns as they are now.

Length1 <= length <= 4096
wait_seconds?integer

How long to wait for a change. 0 answers at once.

Range0 <= value <= 30

Response Body

The operation's answer.

application/json
  1. response
turns*array<|>
cursor*string
Example Request
curl -X POST 'https://app.awen.ai/api/v1/get_turns' \  -H 'Content-Type: application/json' \  -d '{  "turn_ids": [    "string"  ]}'
Example Response
{  "turns": [    {      "turn_id": "string",      "conversation_id": "string",      "project_id": "string",      "status": "working",      "files": [        {          "id": "string",          "entry_id": "string",          "media_id": "string",          "revision_id": "string",          "kind": "folder",          "name": "string",          "url": "string",          "mime_type": "string",          "size_bytes": 0,          "width": 1,          "height": 1,          "duration_seconds": 1,          "download_url": "string"        }      ],      "more_tasks": true,      "failure": "string",      "cost_usd": 0,      "url": "string",      "text": "string",      "task_counts": {        "running": 0,        "completed": 0,        "failed": 0      }    }  ],  "cursor": "string"}

Follow a turn POST

Reads a turn create_with_awen started: its status, its reply's text, its tasks and the files it saved. status is working, completed, failed or stopped. The reply ends when generations start, and the turn stays working until their tasks end. completed means every file it will make is saved; a task that failed says why in failure, so tell the user and never retry on your own. text is written as generations start and never changes: it can still say an image is generating, and it is null when the reply has no words, so read status and files to know what is ready, and fetch a file for the prompt awen used. tasks and files list at most 50 tasks: more_tasks is true when the turn made more, and list_files shows them all. The call waits up to wait_seconds (0 to 30, default 15) and answers as soon as something changes, so call it again at once while status is working, with no other pause. A turn can end with a question, with or without files: show it to the user and wait, and never answer it yourself. cost_usd is what the turn's model calls and generations were charged. It is null until nothing of the turn still runs, and where usage is hidden from members; titles, summaries and file descriptions are charged apart. Pass the last cursor back, so a change between two calls is not missed. files name each file by id with its mime_type, size_bytes, width, height and duration_seconds, each null when unknown. With include_downloads, each file also has a download_url valid 5 minutes, or null when it cannot be downloaded; without it, pass an id to fetch for one. To follow several turns at once, call get_turns. Needs a key with awen:read. Costs 1 to 4 units of the key's rate limit, by its arguments.

List conversations POST

Lists the user's own awen conversations in a project, or across their projects without project_id, most recently updated first, archived ones included, 50 at a time. Pass a conversation's id to fetch to read it. active_turn_id names the turn running in a conversation, or still making its files, for get_turn: null means nothing runs there. It can lag get_turn by a few seconds, and get_turn decides. A page leaves out conversations in projects the user can no longer open, so it can hold fewer than 50, or none: keep passing next_cursor back as cursor until it is null. Needs a key with awen:read. Costs 1 unit of the key's rate limit.