Bots work in the background. A send returns at once with a
cursor. You then poll the chat with that cursor until the bots finish, ask a question, fail, or are stopped. There is no streaming and there are no webhooks.
Authentication and access
SendAuthorization: Bearer KREA_API_KEY with every request to https://api.krea.ai. The Bots API uses the same keys as the rest of the public API.
The key’s workspace and person decide what you can see:
- Bots: your own bots, and the bots shared with the workspace.
- Chats: only the chats you belong to. A chat you are not in returns
404, also for teammates in the same workspace.
403:
403 with code: "bots_unavailable". Stop is never refused for the plan, so running work can always be stopped.
Every chat response includes a url that opens the chat in the Krea app. Messages sent over the API are marked via API there, and carry "via": "API" when you read them back.
Billing
Bot turns use the workspace’s compute unit balance, exactly like turns in the Krea app. They do not use the API balance. Usage limits set on a bot or on a chat apply too.
Send a message and poll for the reply
SetKREA_API_KEY in your environment first. Choose Bash with curl and jq, Python with requests, or Node.js with built-in fetch. You need at least one bot. Create bots in the Krea app; the API does not create them.
1
List your bots
GET /bots returns the bots you can use. Pick a bot’s id.2
Start a chat
POST /bots/chats with bot_id, a title, and a message. Save the returned chat_id and cursor.3
Poll for the reply
Call
GET /bots/chats/{chat_id}/messages with cursor and wait=30. Repeat with the new cursor from each response until status is no longer working.requests with pip install requests. For Node.js, use Node.js 22+ and save the example as example.mjs.
These examples send one message and poll for up to five minutes. They stop on HTTP errors, and exit with an error when the chat ends in any status other than done. They never retry a send automatically. If a send request times out, the first request may have posted the message. Repeat it with the same idempotency_key, or read the chat before you send again.
When the wait budget runs out, the bot keeps working. Save the chat ID and cursor to resume polling later.
Start a chat
POST /bots/chats returns 201 with chat_id, title, message_id, cursor, bots, and url.
A new chat opened without a
message has the bot say hi. That greeting is a bot turn and is billed like one. Opening a direct chat that already exists returns that chat. Without a message, message_id is null.
Send a follow-up
POST /bots/chats/{chat_id}/messages posts a message into an existing chat and returns 202 with a new cursor:
cURL
text takes up to 8,000 characters. Send text, at least one attachment, or both.
Retry a send safely
A send starts a billed bot turn, so sending twice by accident costs twice.POST /bots/chats and POST /bots/chats/{chat_id}/messages accept an optional idempotency_key, a string of your choosing that names the request:
Poll for new messages
GET /bots/chats/{chat_id}/messages takes two query parameters:
Keep your HTTP client timeout longer than
wait. The response describes the chat since cursor:
Each response only carries what is new since
cursor. Collect text, media, and files across reads if you need the whole reply.
To read a chat’s history instead, use GET /bots/chats/{chat_id}. It returns a page of messages, newest page first, with limit from 1 to 100 (default 30). Pass the returned before value as before to page back.
Attachments
POST /bots/chats and POST /bots/chats/{chat_id}/messages accept up to 10 attachments per message. Each is { url, name?, content_type? }:
url accepts an http(s) URL, such as the asset URL returned by POST /assets, or a Krea Files URI file:<uuid> that you can access. name and content_type are optional strings of up to 255 characters. A Krea file that is missing or not accessible returns 404 with code: "attachment_not_found".
Question cards
A bot can stop and ask before it continues. The read then returnsstatus: "needs_input" with a question:
POST /bots/chats/{chat_id}/questions/{question_id}/answer, then poll again with the cursor the answer returns:
cURL
kind:
Answering a question that was already answered returns
404.
Group chats
A chat with several bots, with teammates, or with a title is a group chat. Start one withbot_ids and, optionally, member_ids:
cURL
- Every bot must be one you can use, or the request returns
404. - Every person in
member_idsmust be in the workspace, or the request returns400. - A private bot works only with its owner. A chat with other people needs bots that are shared with the workspace, or the request returns
400.
people in the chats you share with them, from GET /bots/chats and GET /bots/chats/{chat_id}.
Who answers
The first bot inbot_ids leads the chat, and lead_bot_id names it. A message that names no bot goes to the lead. To speak to a specific bot, write @ and its name in the message, for example @Thumby make the logo bigger.
Every response says which bot it is about. Each message carries author.id and author.name, a question carries bot_id, and each entry in working carries bot_id. In a poll, status stays working until every bot in the chat is at rest.
Add and remove bots and people
POST /bots/chats/{chat_id}/members takes bot_ids, member_ids, or both, and returns who is in the chat now: chat_id, title, kind, lead_bot_id, bots, people, and url. Anyone in the chat can add. Adding to a direct chat turns it into a group chat. Bots and people already in the chat are left as they are.
cURL
{ "chat_id": "...", "removed": { "kind": "bot", "id": "..." }, "left": false }:
Anyone else gets
403 (forbidden). The person who started a chat cannot leave it, and a direct chat’s bot cannot be removed; both return 400. Delete the chat instead. Removing a bot or a person stops the work the bot was doing, or the work bots were doing for that person.
Delete a chat
DELETE /bots/chats/{chat_id} deletes a direct or group chat for everyone in it and returns { "chat_id": "...", "deleted": true }. Only the person who started the chat or a workspace admin can delete it; anyone else in the chat gets 403 (forbidden). Every bot turn and helper working in the chat stops. A deleted chat returns 404 from then on, and opening a direct chat with the same bot again starts a new one.
cURL
Stop a turn
POST /bots/chats/{chat_id}/stop stops every bot working in the chat, and their helpers. Both body fields are optional:
cURL
status: "stopped" and finished: true.
Out of compute units and usage limits
A send returns202 even when the workspace has no compute units left, or when a usage limit is spent. The turn does not run. The hold shows when you read the chat:
These three are billing holds, not faults. Other codes report a turn that failed:
refused, busy, timeout, provider, server, context, claude_billing, and unknown.
After you add compute units, call POST /bots/chats/{chat_id}/retry to resume the held bots, or send a new message. Retry takes no body and returns { "retried": true, "out_of_compute": false } when a bot resumed. While the balance is still empty it does nothing and returns { "retried": false, "out_of_compute": true }. Poll again after a retry.
Errors
Endpoint errors use{ "error": "...", "code": "..." }. Only error is required. A turn that fails after the send was accepted appears as status: "failed" in a successful read instead.
The
429 limit only guards against runaway clients: 60 writes and 600 reads per minute per user. Writes are start, send, answer, stop, retry, delete, and adding or removing bots and people. Long polling with wait=30 stays far below the read limit.
Not in this version
- Creating, editing, or deleting bots, and bot settings. Manage bots in the Krea app.
- The vault.
- Webhooks and streaming. Poll with
waitinstead. - Renaming or archiving a chat. Do that in the Krea app.