Start a Chao Session
This guide walks you through fetching Chao context for a Project and starting a Chao-powered coaching session.
Prerequisites
- A Chainabit account with a valid access token
- An active AI entitlement on your plan
- At least one Project already created in your account
curlavailable in your terminal (or use the JavaScript/Python examples)
Step 1: Find your Project ID
You need the UUID of the Project you want to coach. Retrieve your Projects from the Productivity API:
curl "https://api.chainabit.com/api/v1/chainies" \
-H "Authorization: Bearer $TOKEN"Note the id field — this is your chainyId.
Step 2: Fetch Chao context
Before starting a session, confirm the Chao context resolves for your Project. This also verifies your entitlement and that the Project belongs to your account.
curl "https://api.chainabit.com/api/v1/ai/chao/context?chainyId=$CHAINY_ID" \
-H "Authorization: Bearer $TOKEN"A successful response returns memories and a productivity snapshot. If you receive a 404, the Project ID is invalid or does not belong to your account.
Step 3: Create a Chao session
Create an AI session with assistantType: "chao" and bind it to your Project:
curl -X POST "https://api.chainabit.com/api/v1/ai/sessions" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "My Project Coach",
"assistantType": "chao",
"primaryContextType": "chainy",
"primaryContextId": "'"$CHAINY_ID"'"
}'| Field | Value | Description |
|---|---|---|
assistantType | "chao" | Activates the Chao behavioral advisor |
primaryContextType | "chainy" | Scopes the session to a specific Project |
primaryContextId | your Project UUID | Binds Chao context to this Project |
mode | "approval" / "auto" / "plan" | Controls how write tools execute (see Session Modes); defaults to "approval" |
Step 4: Send your first message
Send a message to the session. Chao automatically injects the resolved context:
curl -X POST "https://api.chainabit.com/api/v1/ai/sessions/$SESSION_ID/messages" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"content": "How am I doing with my Morning Run chain?"}'To receive the AI response as a stream, see Stream AI Responses.
Next Steps
- Chao Context Reference — full endpoint schema and error codes
- Chao Context Model — how context is assembled and why
- Sessions Reference — manage session lifecycle
- Stream AI Responses — receive Chao responses via SSE