Skip to main content
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.
In both cases, pass the key as a Bearer token: Authorization: Bearer <key>.
For external integrations, use the V1 agent chat endpoint with either an Agent API Key or a Platform API Key. Create keys from the dashboard.
curl -X POST https://api.thinnest.ai/v1/agents/{agent_id}/chat \
  -H "Authorization: Bearer $THINNESTAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "message": "What are your business hours?",
  "session_id": "sess_customer_jane_001"
}'

Path Parameters

agent_id
string
required
Target agent’s public ID (ag_*)

Request Body

message
string
required
User message text
session_id
string
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": "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_jane_001",
  "usage": {
    "input_tokens": 45,
    "output_tokens": 32,
    "total_tokens": 77
  }
}

Response Fields

response
string
Agent’s text response
session_id
string
Session ID (reuse for follow-up messages)
usage.input_tokens
integer
Tokens in the prompt
usage.output_tokens
integer
Tokens in the response
usage.total_tokens
integer
Total tokens consumed

Example — Multi-Turn Conversation

Turn 1:
// Request
{ "message": "What products do you sell?", "session_id": "sess_001" }

// Response
{ "response": "We sell three main product lines: ...", "session_id": "sess_001" }
Turn 2:
// Request (same session_id continues the conversation)
{ "message": "How much does the premium plan cost?", "session_id": "sess_001" }

// Response (agent remembers context from Turn 1)
{ "response": "The premium plan for our Enterprise product is $99/month...", "session_id": "sess_001" }

Errors

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