Chat
The Chat API is how your users interact with thinnestAI agents. Send a message, get a response — it’s that simple. Under the hood, you get streaming, session persistence, and intelligent rate limiting.Quick Start
Send a message to your agent:Chat API Endpoint
POST /chat
Send a message to an agent and receive a response. Request Body:| Field | Type | Required | Description |
|---|---|---|---|
agent_id | string | Yes | The ID of the agent to chat with |
message | string | Yes | The user’s message |
session_id | string | No | Session ID for conversation continuity. If omitted, a new session is created. |
stream | boolean | No | Enable streaming responses (default: true) |
metadata | object | No | Additional context to pass to the agent |
Streaming Responses (SSE)
By default, the Chat API streams responses using Server-Sent Events (SSE). This gives your users a real-time typing experience instead of waiting for the full response.How SSE Works
Whenstream: true (the default), the response is delivered as a series of events:
Consuming SSE in JavaScript
Consuming SSE in Python
Session Management
Sessions maintain conversation history so your agent remembers previous messages.How Sessions Work
- New conversation: Omit
session_id— the API creates a new session and returns its ID. - Continue conversation: Include the
session_idfrom a previous response. - Session storage: Conversation history is stored in PostgreSQL and persists across requests.
- Session expiry: Sessions remain active for 24 hours of inactivity by default.
Managing Sessions
Session Metadata
You can pass metadata with each message to provide additional context:Rate Limiting
The Chat API enforces rate limits to ensure fair usage and platform stability.Default Limits
| Plan | Requests per Minute | Concurrent Connections |
|---|---|---|
| Free | 20 | 2 |
| Pro | 120 | 10 |
| Enterprise | Custom | Custom |
Rate Limit Headers
Every response includes rate limit information:Handling Rate Limits
When you exceed the limit, you receive a429 Too Many Requests response:
Error Handling
| Status Code | Meaning | Action |
|---|---|---|
| 200 | Success | Process the response |
| 400 | Bad request (missing fields) | Check your request body |
| 401 | Invalid API key | Verify your credentials |
| 404 | Agent not found | Check the agent ID |
| 429 | Rate limited | Wait and retry |
| 500 | Server error | Retry with backoff |
| 503 | Service temporarily unavailable | Retry after a moment |
Next Steps
- Embed Widget — Add chat to your website with zero code.
- Agents — Configure the agents behind your chat.
- Knowledge Sources — Give your agent information to draw from.

