Chat
External Chat
Chat with an agent using API key authentication (for third-party integrations).
The external chat endpoint is designed for third-party applications, websites, and services. It uses Agent API Keys instead of Auth0 JWT.
POST
/v1/agents/{agent_id}/chatChat with an agent using API key authentication.
Path Parameters
Target agent ID (format: ag_*)
Authentication
Use an Agent API Key (ak_*) in the Authorization header:
curl -X POST https://api.thinnest.ai/v1/agents/ag_c47e7c97_b2f2/chat \
-H "Authorization: Bearer ak_your_agent_api_key" \
-H "Content-Type: application/json" \
-d '{"message": "Hello"}'Create API keys via the Create API Key endpoint or from the dashboard.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
agent_id | string | Yes | The agent's public ID (ag_*) |
Request Body
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
message | string | Yes | — | User message text |
session_id | string | No | Auto-generated | Session ID for conversation continuity |
Response 200
{
"response": "We offer three product lines: Starter, Professional, and Enterprise...",
"session_id": "sess_website_visitor_001",
"usage": {
"input_tokens": 42,
"output_tokens": 85,
"total_tokens": 127
}
}When to Use This vs /chat
| Endpoint | Auth | Use Case |
|---|---|---|
POST /chat | Auth0 JWT | Dashboard, internal apps |
POST /v1/agents/{id}/chat | Agent API Key (ak_*) | Websites, third-party apps, embed widgets |
Errors
| Code | Description |
|---|---|
401 | Missing or invalid API key |
402 | Insufficient balance |
404 | Agent not found |
429 | Rate limit exceeded (60 req/min per key) |