Skip to main content

aiThreadsOpenOrCreate

AiOpenOrCreateResult aiThreadsOpenOrCreate(AiThreadsOpenOrCreateRequest)

POST /api/2.0/ai/threads/open-or-create

Open or create

Opens a chat thread and returns it with its history, or creates one whose title is generated from the first message supplied in the request. That first message is not persisted: follow up with POST api/2.0/ai/threads/append-user-message to store it, or start the round directly with POST api/2.0/ai/ai/send-with-stream. Unlike create this takes a whole resolved profile object rather than an ID, and a request without one answers 404 because no model could be bound. A supplied entityId has to be a room the caller can open; anything that is not an agent room folds to the global scope instead of being rejected.

Parameters​

NameInTypeDescriptionNotes
AiThreadsOpenOrCreateRequestbodyAiThreadsOpenOrCreateRequest[required]

Responses​

Status codeDescriptionTypeResponse headers
200The thread that was opened or created, with its prior messages. A created one carries the generated title.AiOpenOrCreateResult-
401Missing asc_auth_key cookie or Authorization header.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-
404The entityId names a room the caller cannot open, or no live AI profile is bound to it.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​

AiOpenOrCreateResult

Authorization​

cookieAuth, bearerAuth

HTTP request headers​

  • Content-Type: application/json
  • Accept: application/json