agents. A key bound to an account only sees that account’s conversations.
A conversation may have no agent, so
model responses can use it. Items can be appended only to a conversation without an agent (409 conversation_has_agent otherwise): an agent’s runtime keeps its own session history. Endpoints that need an agent answer 409 conversation_has_no_agent on an agent-less one.
Legacy routes
These keep working with the same shape; they now read and write items."stream": true the answer is server-sent events: message.delta events with { "delta": "…" } while the agent writes, tool.started, tool.completed and tool.failed events ({ "tool_call_id", "name", "input"?, "output"?, "error"? }, arguments and results cut at 8,000 characters) as it uses its tools, then one message.completed carrying the stored reply, or an error event ({ "error": { "type", "code", "message" } }). The reply is stored even if your client disconnects mid-stream. Skip event names you don’t know: new ones may be added. To drive an agent from an AG-UI frontend such as CopilotKit, see AG-UI frontends.
Failures. If the agent’s turn fails, the reply comes back with status: "failed" and an error sentence (streamed: an error event with code turn_failed); your message and the failure both stay in the conversation. A turn the agent hasn’t finished within 10 minutes ends this way too, and the conversation takes new messages again. A non-streaming message is also stored if your client disconnects before the reply arrives. Long turns should use "stream": true, because Cloudflare closes a request that sends nothing for 100 seconds (524).
Where the agent runs. Each project gets its own hosted runtime in Allternit’s cloud, started by the project’s first message. While it starts, sending a message answers 503 runtime_starting; retry after a few seconds. An idle runtime sleeps and wakes on the next message; while it wakes, messages also answer 503 runtime_starting (up to about a minute). A message answered with runtime_starting is not stored, so retrying it does not duplicate it. Agent changes reach the runtime before the next message. All of a project’s agents share the project’s runtime; each account’s data stays separate in the API, and the runtime keeps each conversation in its own session.
Limits. content is 1–16,000 characters. One message at a time per conversation: a second one while the agent is still answering gets 409 conversation_busy.
Billing. Each reply records its model tokens as tokens_in and tokens_out usage, billed at the model provider’s list price plus 15%. An agent on your own model key (model: "anthropic/…" with PUT /v1/model_keys/anthropic) records the tokens at no charge; you pay your provider directly. Once the project reaches its monthly spend cap, sending a message answers 402 spend_cap_reached and the agent doesn’t run (Billing and spend caps).
Errors: conversation_has_agent, conversation_has_no_agent, model_key_missing, model_key_sync_failed, invalid_content, invalid_metadata, agent_not_found, conversation_not_found, conversation_busy, runtime_starting, runtime_unavailable, agent_sync_failed, session_failed, insufficient_scope, spend_cap_reached, spend_check_unavailable.