public_html and wire your bot. Don't understand something? Read SETUP.md — it's the manual.Send a task. Receive the agent working live: plan, tool calls, thinking, text, auto-approvals, media generation, files — finished with one done event containing the full conversation as JSON. Key rotation, credit management and pool refills are all internal; a request never waits on anything.
| body field | type | notes |
|---|---|---|
| message | string | required — the task (max 6000 chars) |
| session_id | string | continue a conversation |
| search | bool | web-ground the task |
| tier | string | fast (default) |
| budget_sec | int | max stream seconds (default 170, cap 280) |
curl -N -X POST "https://YOUR-HOST/api/chat" \
-H "Content-Type: application/json" \
-d '{"message":"generate an image of a fox in a snowy forest"}'
event: open data: {"engine":"agent","tier":"fast","search":false}
event: key data: {"credits":100}
event: run data: {"session_id":"sess-…","status":"running"}
event: thinking data: {"delta":"…"}
event: tool data: {"id":"call_…","name":"google_search","state":"running"}
event: tool data: {"id":"call_…","state":"success"}
event: hitl data: {"auto":true,"question":"…","choices":{…}} (answered with the agent's own defaults)
event: media data: {"media_task_id":"…","media_type":"image","status":"PENDING"}
event: media data: {"media_task_id":"…","status":"SUCCEEDED","urls":["https://….png"]}
event: file data: {"filename":"…","downloadUrl":"https://…"}
event: text data: {"delta":"…"}
event: usage data: {"input_tokens":…,"output_tokens":…}
event: credits data: {"left":86}
event: rotate data: {"attempt":1,"reason":"key ran dry — rotating"} (rare; task replays silently)
event: done data: {"ok":true,"conversation":{
"id":"sess-…","message":"…","reply":"…",
"tools":[…],"files":[…],"media":[…],"usage":{…},
"approvals":2,"credits_left":86,"error":null } }
No model pickers, no preset configs — the agent chooses its own tools and settings; any question it raises mid-task is approved with its own defaults.
| call | purpose |
|---|---|
| GET /api/sessions | merged task history across the pool (newest first) |
| GET /api/sessions/{id} | full message list of one conversation |
| GET /api/sessions/{id}/status | live state: IDLE / QUEUED / RUNNING |
| POST /api/sessions/{id}/stop | abort a running task (verified: RUNNING → IDLE) |
| DELETE /api/sessions/{id} | delete a conversation |
| GET /api/media/{taskId} | raw media-task record + URLs |
| GET /api/credits | pool snapshot: keys, buffered credits, keeper state |
| GET /api/info · /api/models | banner + capabilities |
# stop a runaway task from your bot curl -X POST "https://YOUR-HOST/api/sessions/sess-…/stop" # poll while your user waits curl "https://YOUR-HOST/api/sessions/sess-…/status"
• Deploy: upload everything into public_html (Apache rewrite included). Local dev: PHP_CLI_SERVER_WORKERS=8 php -S 0.0.0.0:8080 router.php.
• Errors: JSON {"ok":false,"error":"…"} with proper HTTP codes; stream failures arrive as event: error.
• Stored server-side: anonymous key state and a session map only. Nothing about you, nothing identifiable.