Guides
Sessions
What it is for
By default Antarya is stateless: each request carries the whole conversation, as the conversations guide shows. A session keeps the turns for you. You create it once, pass its id as session_id and send only the new message. Use one when you do not want to hold and resend the history yourself.
Create a session and send a turn
curl https://antarya.ai/v1/sessions \
-H "Authorization: Bearer $ANTARYA_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
# use the id from the create reply as session_id
curl https://antarya.ai/v1/chat \
-H "Authorization: Bearer $ANTARYA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"session_id": "sess_4f2a9c1e7b3d48a6915e0c2d8f7a6b31",
"messages": [{"role": "user", "content": "Summarise the termination clause."}]
}'Output
{
"id": "req_04",
"content": [
{"type": "text", "text": "Either side can end the agreement with 30 days of written notice."}
],
"stop_reason": "end_turn",
"usage": {"input_tokens": 18, "output_tokens": 16}
}Continue it
Send the next turn with the same session_id. The saved turns go before your messages, so you send only what is new.
reply = client.chat.create(
session_id=session.id,
messages=[{"role": "user", "content": "Draft a reply that accepts those terms."}],
)When a request succeeds, the new turns and the reply are saved. A failed or refused request saves nothing, so you can send it again.
List, read and delete
curl https://antarya.ai/v1/sessions \
-H "Authorization: Bearer $ANTARYA_API_KEY"has_more is true when another page exists. Deleting a session removes the turns stored in it.
Limits
- An account holds at most 1,000 sessions, and every key on the account can use them.
- Paging, the session object and the other fields are in the sessions reference.