Prerequisites
- A scoped key (
nxsk_v1_...) that carriesconversations:use. Ask Nexio for one: the portal does not issue scoped keys, and an organization API key from the portal gets403 legacy_key_person_routeon these routes. 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 admission answer, The stream for this message:The first frame is
message, a turn_id you generate (a UUID), and Accept: application/json. The answer is 202 with the turn and the path of its stream. Then read the stream: a Server-Sent Events response where each frame is an id: line (the frame’s seq), an event: line, a data: line of JSON, and a blank line. Read frames until a turn_end or error frame arrives.202:conversation. It carries the id of the user message the turn stored. text_delta frames carry the answer in pieces. The turn 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.The turn runs on the platform, not in your request. If the stream connection drops, open it again with after set to the last seq you read; nothing is lost and nothing repeats.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.