Skip to content

Continue an AI conversation ​

Continue the conversation created in the quickstart. You will send a follow-up, stream its assistant response, and read the saved history without starting duplicate work.

Prerequisites ​

Complete the quickstart first. Keep TOKEN and the real SESSION_ID in the same terminal. You need the applicable AI access and usage coverage; another message can consume usage.

Step 1: Check available providers ​

curl --fail-with-body -sS "https://api.chainabit.com/api/v1/ai/providers" \
  -H "Authorization: Bearer $TOKEN" | jq .

Inspect the current catalogue and access information rather than copying a fixed provider list from an example. This tutorial uses the server's normal selection; it does not require a particular provider or model.

Step 2: Reuse your session ​

Your session is the conversation container. Use the UUID returned by the quickstart. If you need a separate conversation, follow session creation again and retain that response's ID.

Step 3: Send a follow-up ​

FOLLOWUP_RESPONSE="$(curl --fail-with-body -sS -X POST "https://api.chainabit.com/api/v1/ai/sessions/$SESSION_ID/messages" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content":"Turn the checklist into three review questions."}')"
printf '%s\n' "$FOLLOWUP_RESPONSE" | jq .
export MESSAGE_ID="$(printf '%s\n' "$FOLLOWUP_RESPONSE" | jq -er '.data.assistantMessage.id')"

Expect 201 Created. The returned assistant message belongs to this follow-up. Do not reuse the previous answer's message ID or copy a fictional ID from a response sample.

Step 4: Follow the assistant response ​

curl --fail-with-body -sS -N \
  "https://api.chainabit.com/api/v1/ai/sessions/$SESSION_ID/messages/$MESSAGE_ID/stream" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: text/event-stream"

Expect an authenticated event stream. Text arrives through message deltas; terminal events describe the outcome. Treat a failed or cancelled run as that outcome, even if you saw partial text earlier.

Step 5: Read the conversation history ​

curl --fail-with-body -sS "https://api.chainabit.com/api/v1/ai/sessions/$SESSION_ID/messages" \
  -H "Authorization: Bearer $TOKEN" | jq .

Inspect the returned messages and their identifiers. History is a read operation: do not send another message merely to refresh the display.

Handle a dropped connection ​

Reconnect to the same assistant stream with Last-Event-ID set to the last numbered event you received. The connection preamble is not a replayable numbered event. See the streaming reference for replay and terminal behavior.

Separate feature runs ​

A feature run is a separate execution contract. Do not create one as an extra step to complete an already accepted conversation message. Use Features and runs when your application needs that capability, and stream its own returned run ID.

What you built ​

A conversation flow that keeps the session identity, captures each new assistant message, follows its outcome, and reads the saved history.

Next steps ​

Use session reference for organization and lifecycle controls, streaming for a client implementation, or integrations to connect external tools.

Built with purpose. chainabit.com