Guides
Conversations
Conversations
Build multi-turn experiences on the stateless Generate API.
The Generate API is stateless. For multi-turn experiences, send prior messages with each request, or use the SDK's Chat helper to manage conversation history in your application.
With the API
Send the conversation so far in messages, oldest first, ending with the new user message. A request can carry up to 40 messages.
curl https://api.aivana.ai/v1/generate \
-H "X-API-Key: $AIVANA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{ "role": "user", "content": "A customer wants a refund after 40 days." },
{ "role": "assistant", "content": "Offer store credit and explain the policy." },
{ "role": "user", "content": "They are now threatening a chargeback." }
]
}'With the SDKs
chat = aivana.Chat(system="You are a support lead. Three bullets maximum.")
chat.send("A customer wants a refund after 40 days.")
chat.send("They're now threatening a chargeback.") # remembers the aboveHistory and cost
The full history is sent again with each question, so long conversations use more input tokens per turn. The part a run reuses from cache is charged as cached input, at 30% of the input rate, and the rest as standard input. Cache reuse is automatic and may expire after inactivity. Trim or summarize old turns when a conversation runs long.
Learn more
Parameters
Every option the Generate API accepts.
Quickstart Guide
Get your key and make your first request in minutes.
Try the Playground
Experiment with Aivana MMI — no account or code required.
Still have questions? We are here to help!