Prerequisites
- An API key. Either an organization API key from the portal (Settings, then API keys) or a scoped key (
nxsk_v1_...) that carriesconversations:use. The examples read the key from theNEXIO_API_KEYenvironment variable. See Authentication and access. - A Conversation instance with at least one published version. Create and publish one in the portal under Conversations, or see Versions and publish. The examples use the slug
workspace-assistant. - An
end_uservalue for the person your application is serving. The examples useu_dana_ortiz. Send the same value on every request for that person’s conversations.
1
Confirm the instance is published
List the instance’s released versions. For an instance you manage yourself, an empty list means turns will return Response
409 instance_not_published. An instance that follows another instance (a follower) runs the versions released on the instance it follows, so its own list can be empty while turns work.200:2
Create a conversation
Create a conversation for the end user. Response
title and scope are optional. scope is a JSON object your application can use to remember what the conversation is about. It never grants access to anything.201:3
Send a message and read the stream
Post a turn with The stream for this message:The first frame is
message. The response is a Server-Sent Events stream: each frame is an event: line, a data: line of JSON, and a blank line. Read frames until a turn_end or error frame arrives. Set no client read timeout shorter than the 10-minute server limit on a segment.conversation. It carries the turn_id and the id of the user message the turn stored. text_delta frames carry the answer in pieces. The stream ends with exactly one turn_end or error frame. The answer text depends on the instance’s system prompt and tools; the frame shapes do not. Every frame type is described on Turns and streaming.If the connection drops, the turn still runs to completion on the server and is stored. Fetch the conversation to see the result.4
Read the stored conversation
Fetch the conversation with the same Response
end_user. The response holds the most recent 500 messages of the branch the conversation serves, oldest first.200:config_version_hash records which released config answered. parent_message_id links messages on their branch; see Branching.