POST /v1/agents/{id}/ag-ui speaks it, so any HTTP client that can read server-sent events, or any AG-UI client library, can talk to your agent directly. Scope agents.
Each run is one turn of a conversation: the same key auth, spend cap, one-turn-at-a-time rule, hosted runtime and token billing apply, and the reply is stored on the conversation like any other message.
Request
The body is AG-UI’sRunAgentInput:
Response
Server-sent events, onedata: line of JSON per AG-UI event:
- Text before a tool call is closed with
TEXT_MESSAGE_END; text after it is a new message. - Tool arguments arrive in one
TOOL_CALL_ARGSevent, once the runtime knows them. Arguments and results are cut at 8,000 characters. A tool that failed reports its error as theTOOL_CALL_RESULTcontent. - A failed turn ends with
RUN_ERROR({ "message", "code": "turn_failed" }) instead ofRUN_FINISHED.
401/403 for the key, 402 spend_cap_reached or 402 payment_method_required, 409 conversation_busy (a run on this thread is still going), 503 runtime_starting (retry in a few seconds, as with messages).
Read the stream with fetch
Keep your Allternit key on your server. The endpoint takes a POST, so the browserEventSource API (GET only) can’t call it; read the stream with fetch instead. This works in Node 18+, Deno, Bun and edge runtimes:
Compatible AG-UI clients
Any client that sendsRunAgentInput and reads AG-UI events over SSE works. Point it at the endpoint above with the Authorization header:
- The AG-UI client libraries (
HttpAgentfrom@ag-ui/clientin TypeScript, and the Python SDK). See docs.ag-ui.com. - CopilotKit, through an AG-UI
HttpAgentregistered in its runtime. - Any framework or chat UI that lists AG-UI support.
client.conversations.runAgentAgUiStream(agentId, body) in TypeScript and client.conversations.run_agent_ag_ui_stream(agent_id, messages=[…]) in Python.
Errors: invalid_messages, invalid_content, invalid_thread_id, plus those of sending a message.