Skip to main content

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: Example Request:
Non-Streaming Response:

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

When stream: 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_id from 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:
Your agent’s tools can access this metadata to personalize responses.

Rate Limiting

The Chat API enforces rate limits to ensure fair usage and platform stability.

Default Limits

Rate Limit Headers

Every response includes rate limit information:

Handling Rate Limits

When you exceed the limit, you receive a 429 Too Many Requests response:
Implement exponential backoff in your client:

Error Handling

Next Steps