Skip to content

Chat with a single prompt

POST
/ai/text/chat
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.

Media typeapplication/json
object
prompt
required

The message to send. Required.

string
Examples
Exampleprompt
{
"prompt": "Reply with the single word OK."
}

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.

Media typetext/event-stream
string
Examples
Exampleanswer
id: 0
event: message
data: ""
id: 1
event: message
data: "OK"
id: -1
event: content-end
data: {"time": "2026-10-19 11:27:46"}

No authentication key was sent.

Media typeapplication/json

Authentication failures use an error key rather than message.

object
error
required
string
Examples
Examplemissing

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.

Media typeapplication/json

Authentication failures use an error key rather than message.

object
error
required
string
Examples
Exampleexpired
{
"error": "JWT passport expired: Passport expired"
}

The request body failed validation.

Media typeapplication/json
object
message
required

The first validation message.

string
errors
required

Validation messages keyed by field name.

object
key
additional properties
Array<string>
Examplegenerated
{
"message": "example",
"errors": {
"additionalProperty": [
"example"
]
}
}