Skip to main content

aiSendWithStreamOpenAI

AiOpenAIStreamChunk aiSendWithStreamOpenAI(AiSendStreamBody)

POST /api/2.0/ai/ai/send-with-stream-openai

Stream a chat in OpenAI format

The same chat round as send-with-stream, re-encoded as a server-sent-events stream of OpenAI chat.completion.chunk objects terminated by a [DONE] sentinel. Thread handling, persistence, title generation and the profile pre-flight are identical, and a tool call ends the stream with finish_reason: tool_calls instead of a pause event - resume it through the same approve and deny operations. Unlike send-with-stream it does not reject an empty user message and does not enforce the per-kind attachment cap, so validate both before calling. Choose this route only for a client that already speaks the OpenAI wire format; POST api/2.0/ai/ai/send-with-stream is the native one.

Parameters​

NameInTypeDescriptionNotes
AiSendStreamBodybodyAiSendStreamBody[required]

Responses​

Status codeDescriptionTypeResponse headers
200Server-sent events stream of OpenAI chat.completion.chunk objects, terminated by a [DONE] sentinel.AiOpenAIStreamChunk-
400The prompt is empty, or no AI profile could be resolved for the requested action.AiErrorResponse-
401Missing asc_auth_key cookie or Authorization header.AiErrorResponse-
402The portal has no paid AI quota left, so the profile bound to this action cannot be dispatched. error carries the portal's explanation in the caller's language.AiErrorResponse-
403AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API.AiErrorResponse-
413The request body is larger than 100 KB, the JSON parser's limit on this route.AiErrorResponse-
500Unhandled failure. The reason is logged server-side and never echoed back.AiErrorResponse-

Return type​

AiOpenAIStreamChunk

Authorization​

cookieAuth, bearerAuth

HTTP request headers​

  • Content-Type: application/json
  • Accept: text/event-stream, application/json