Turns
How a call to Awen's agent runs, how to follow it, and how to get the files it made.
create_with_awen starts a turn: Awen's agent reads your prompt, answers, and starts the generations it needs.
It answers at once with a turn_id, while the turn runs.
create_with_awenanswers aturn_idat once.get_turnanswers each change whilestatusisworking.- Once it is
completed,get_turnwithinclude_downloadsgives adownload_urlfor each file.
Statuses
status | Means | What to do |
|---|---|---|
working | The agent or one of its generations still runs. | Call get_turn again at once. |
completed | Every file the turn will make is saved. | Read files, or download them. |
failed | The turn could not finish. failure says why. | Tell your user. Do not retry on your own. |
stopped | Someone stopped the turn, with cancel_turn or in Awen. | Nothing more will come. |
A turn can end with a question from the agent. Show it to your user and send the answer as a new turn in the same
conversation, with conversation_id.
Following a turn
get_turn waits up to wait_seconds (0 to 30) and answers as soon as something changes. Pass back the cursor of
the last answer, so you never miss a change between two calls. To follow several turns at once, call get_turns.
textis the agent's reply. It is written once, when generations start.tasksandfileslist what the turn makes, each file with itsmime_type, size and dimensions.cost_usdis what the turn cost, once nothing of it still runs.
Downloading files
Call get_turn with include_downloads: true once the turn is completed. Each file then has a download_url that
works for 5 minutes. Fetch it with no header: the link itself grants access to that one file.
To download files later, or files from elsewhere in a project, use download with their ids.
Stopping a turn
cancel_turn stops a turn that is still working. What it already made stays in the project.