Run an Agent
POST /api/run
The primary endpoint to send a message to your agent and receive a response.
Request
POST https://api.auteryn.ai/api/runBody:
{ "query": "string (required)", "task_id": "string (optional — continue an existing conversation)", "stream": true, "context": { "user_id": "string (optional)", "user_name": "string (optional)", "metadata": {} }}| Field | Required | Description |
|---|---|---|
query | ✅ | The message or task to send to the agent |
task_id | ❌ | Pass to continue an existing conversation. Omit to start new. |
stream | ❌ | true for SSE streaming (default), false for single JSON response |
context.user_id | ❌ | Your internal user ID |
context.metadata | ❌ | Any key-value pairs your instructions can reference |
Responses
Content-Type: text/event-stream
data: {"type":"run_started","run_id":"run_abc","task_id":"task_xyz"}
data: {"type":"text_chunk","content":"Let me check the open bugs..."}
data: {"type":"tool_call","tool":"github","action":"list_issues","params":{"state":"open","label":"P1"}}
data: {"type":"tool_result","tool":"github","result":{"count":3}}
data: {"type":"text_chunk","content":"I found 3 open P1 issues:"}
data: {"type":"run_completed","run_id":"run_abc","credits_used":6,"duration_ms":3241}{ "run_id": "run_abc123", "task_id": "task_xyz789", "status": "completed", "output": "There are 3 open P1 issues: ...", "credits_used": 6, "duration_ms": 3241, "tool_calls": [ { "tool": "github", "action": "list_issues", "params": {"state": "open", "label": "P1"}, "result_summary": "Found 3 issues" } ]}Code examples
import httpx, json
with httpx.stream( "POST", "https://api.auteryn.ai/api/run", headers={ "Authorization": "Bearer afk_your_key", "X-Agent-Id": "agent_xyz", }, json={"query": "What are the open P1 GitHub issues?"},) as r: for line in r.iter_lines(): if line.startswith("data: "): event = json.loads(line[6:]) if event["type"] == "text_chunk": print(event["content"], end="", flush=True)const response = await fetch("https://api.auteryn.ai/api/run", { method: "POST", headers: { "Authorization": "Bearer afk_your_key", "X-Agent-Id": "agent_xyz", "Content-Type": "application/json", }, body: JSON.stringify({ query: "Summarize open issues", stream: false }),});const { output } = await response.json();console.log(output);curl -X POST https://api.auteryn.ai/api/run \ -H "Authorization: Bearer afk_your_key" \ -H "X-Agent-Id: agent_xyz" \ -H "Content-Type: application/json" \ -d '{"query":"Summarize open GitHub issues","stream":false}'