Authentication: This endpoint accepts either key type:
- Agent API key (
ak_*) — scoped to a single agent. Recommended for embedded widgets and other client-side use where a leaked key should not expose your full account. Generate from the agent’s settings. - Platform API key (
thns_sk_*) — full account access. Use from trusted server-side code. Generate from Dashboard → Settings → API Keys.
Authorization: Bearer <key>.Path Parameters
Target agent’s public ID (ag_*)
Request Body
User message text
Session ID for conversation memory. Reuse the same ID to continue a conversation
Session Behavior
- With
session_id: The agent remembers previous messages in this session. Use for multi-turn conversations. - Without
session_id: A new session is created automatically. Each request is treated as independent.
Response 200
Response Fields
Agent’s text response
Session ID (reuse for follow-up messages)
Tokens in the prompt
Tokens in the response
Total tokens consumed
Example — Multi-Turn Conversation
Turn 1:Errors
| Code | Description |
|---|---|
401 | Missing or invalid API key |
402 | Insufficient balance |
404 | Agent not found |
429 | Rate limit exceeded |

