POST /v1/agents/runs
Invoke any of your account’s agents by passing the agent identifier in the request body,
Request
| Field | Type | Required | Notes |
|---|---|---|---|
agent | string | yes | Agent identifier (agt_…) from the portal or POST /v1/agents. |
input | string | yes | End-user message. Up to 8000 chars. |
conversation_id | string | no | Continue an existing conversation. Omit to auto-create one. |
?stream=true and read the body as Server-Sent Events. See
Streaming below.
Response
Examples
curl
TypeScript (@meshrouter/sdk ≥ 0.2.0)
Python (meshrouter ≥ 0.2.0)
Streaming
Add?stream=true to receive Server-Sent Events as the agent generates output. Events are
line-delimited; each carries event: and data: lines in the standard SSE format.
TypeScript
Python
Authentication
Send the API key withAuthorization: Bearer mesh_live_…. The key must carry the chat scope.
Issue keys from the portal under API keys.
Errors
| Status | code | When |
|---|---|---|
| 400 | invalid_request | Missing agent or input, or body is not valid JSON. |
| 401 | unauthorized | API key missing or rejected. |
| 402 | insufficient_funds | Account credit balance can’t cover the reserved estimate for this call. |
| 404 | not_found | Agent id does not belong to this account, or the supplied conversation_id does not exist. |
| 429 | conversation_limit_exceeded | Agent has reached its per-agent conversation cap. |
Legacy endpoint
POST /v1/agents/{agentId}/chat (agent id in URL, no agent body field) still works for the
moment. Responses carry a Deprecation: true header and a Sunset date — switch your clients to
POST /v1/agents/runs before the sunset to avoid breakage.