Skip to main content

AI Conversation API

The AI Conversation API provides a stateless, streaming chat endpoint for interacting with the platform's AI. It can be scoped to a specific work for context-aware responses.

All endpoints require JWT authentication.

Endpoint

MethodEndpointDescription
POST/api/ai-conversations/chat/streamSend a chat message and receive a streaming response

Chat Stream

Send a message and receive a streaming NDJSON response:

curl -X POST http://localhost:3100/api/ai-conversations/chat/stream \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{ "role": "user", "content": "What categories should I use for a design tools work?" }
],
"workId": "optional-work-id"
}'

Request Body

FieldTypeRequiredDescription
messagesarrayYesArray of chat messages ({ role, content })
modelstringNoOverride the AI model
temperaturenumberNoOverride the temperature
workIdstringNoScope the conversation to a specific work
providerOverridestringNoOverride the AI provider plugin

Response

The response is a stream of newline-delimited JSON (NDJSON). Each line is a JSON object:

{"content":"Here"}
{"content":" are"}
{"content":" some"}
{"content":" suggested"}
{"content":" categories"}
{"done":true}
FieldTypeDescription
contentstringA chunk of the AI response text
donebooleantrue when the response is complete
errorstringError message if something went wrong