Skip to Content
Docs

Quickstart

Make an API key, then start your first turn of Awen's agent and download what it made.

Early access

The API opens organisation by organisation. When it is open to you, Settings → Connected apps shows an API keys view.

1. Make a key

  1. In Awen, open Settings → Connected apps → API keys, and choose Create key.
  2. Name it, choose what it can do, and when it expires. To make things with Awen, turn on Write and Create.
  3. Awen asks you to confirm it's you with a code, then shows the key once. Copy it into your server's secrets.

Keep the key on a server. Awen refuses a call that a web browser sends. See Authentication.

export AWEN_API_KEY="awen_sk_…"

2. Check the key

Every operation is a POST to https://app.awen.ai/api/v1/<operation> with a JSON body.

curl https://app.awen.ai/api/v1/whoami \
  -H "Authorization: Bearer $AWEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

The answer names you, your organisation, the key's permissions, your plan and your usage.

3. Start a turn

list_projects gives each project's project_id. create_with_awen asks Awen's agent to make something there, as you would in a conversation. It answers at once with a turn_id, while the agent works.

curl https://app.awen.ai/api/v1/create_with_awen \
  -H "Authorization: Bearer $AWEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: launch-cover-001" \
  -d '{"project_id": "<project_id>", "prompt": "A lookbook cover for our SS27 campaign", "image_count": 1}'

The Idempotency-Key header is required here: if your call fails and you send it again with the same key, Awen answers with the same turn and charges once. See Idempotency.

4. Wait for it, then download

get_turn waits up to wait_seconds (30 at most) for the turn to change. Call it again while status is working. Once it is completed, ask for include_downloads to get a download link for each file.

let state = await awen("get_turn", { turn_id: turn.turn_id, wait_seconds: 30 });
while (state.status === "working") {
  state = await awen("get_turn", { turn_id: turn.turn_id, wait_seconds: 30, cursor: state.cursor });
}
const done = await awen("get_turn", { turn_id: turn.turn_id, include_downloads: true });
for (const file of done.files) console.log(file.download_url);

A download link works for 5 minutes. Read Turns for the other statuses, and the reference for every operation.

On this page