Skip to main content
POST
/
chat
curl -X POST https://api.thinnest.ai/chat \
  -H "Authorization: Bearer $THINNESTAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "agent_id": "ag_c47e7c97_b2f2",
  "message": "What are your business hours?",
  "session_id": "sess_customer_001"
}'
{
  "response": "Our business hours are Monday through Friday, 9 AM to 6 PM EST. We're also available on Saturdays from 10 AM to 2 PM.",
  "session_id": "sess_customer_001",
  "usage": {
    "input_tokens": 45,
    "output_tokens": 32,
    "total_tokens": 77
  },
  "tool_calls": []
}
curl -X POST https://api.thinnest.ai/chat \
  -H "Authorization: Bearer $THINNESTAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "agent_id": "ag_c47e7c97_b2f2",
  "message": "What are your business hours?",
  "session_id": "sess_customer_001"
}'

Request Body

agent_id
string
required
Target agent ID (ag_*)
message
string
required
User message text
session_id
string
Session ID for conversation memory. Reuse to continue a conversation
stream
boolean
default:"false"
Enable streaming response (use Stream endpoint instead)
metadata
object
default:"null"
Additional context passed to the agent (e.g., user info, page URL)

Response 200

{
  "response": "Our business hours are Monday through Friday, 9 AM to 6 PM EST. We're also available on Saturdays from 10 AM to 2 PM.",
  "session_id": "sess_customer_001",
  "usage": {
    "input_tokens": 45,
    "output_tokens": 32,
    "total_tokens": 77
  },
  "tool_calls": []
}

Response Fields

response
string
Agent’s text response
session_id
string
Session ID — reuse for follow-up messages
usage.input_tokens
integer
Tokens consumed by the prompt
usage.output_tokens
integer
Tokens in the agent’s response
usage.total_tokens
integer
Total tokens consumed (billed)
tool_calls
array
Tools the agent invoked during this response

Example with Metadata

{
  "agent_id": "ag_c47e7c97_b2f2",
  "message": "I need help with my order",
  "session_id": "sess_customer_001",
  "metadata": {
    "user_name": "Jane Doe",
    "user_email": "jane@example.com",
    "page_url": "https://store.example.com/orders/12345"
  }
}

Errors

CodeDescription
401Missing or invalid authentication
402Insufficient balance
404Agent not found
429Rate limit exceeded

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

origin
string | null

Body

application/json

Request schema for embed chat messages.

publish_id
string
required
message
string
required
session_id
string | null

Response

Successful Response