Chat with a single prompt
const url = 'https://ai.work.optidata.cloud/api/ai/text/chat';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"prompt":"Reply with the single word OK."}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://ai.work.optidata.cloud/api/ai/text/chat \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "prompt": "Reply with the single word OK." }'Sends one message to the assistant and streams the answer back as
server-sent events (see Streamed chat responses in the overview).
For a conversation with earlier turns or instructions, use
POST /ai/text/chat/contextual.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
The message to send. Required.
Examples
{ "prompt": "Reply with the single word OK."}Responses
Section titled “ Responses ”The answer, streamed as server-sent events. Each message event’s
data is a JSON-encoded piece of text; a final content-end event
closes the stream.
Examples
id: 0event: messagedata: ""
id: 1event: messagedata: "OK"
id: -1event: content-enddata: {"time": "2026-10-19 11:27:46"}No authentication key was sent.
Authentication failures use an error key rather than message.
object
Examples
No bearer token sent
{ "error": "JWT passport exception: Missing bearer token in request"}The authentication key is expired or not recognised. Get a fresh one and retry.
Authentication failures use an error key rather than message.
object
Examples
{ "error": "JWT passport expired: Passport expired"}The request body failed validation.
object
The first validation message.
Validation messages keyed by field name.
object
Examplegenerated
{ "message": "example", "errors": { "additionalProperty": [ "example" ] }}