Create chat completions

Generate completions for a conversation based on the assistant's capabilities and conversation history.

post/v1/chat/completions

Request

  • Base URL
    https://api.runbear.io
  • Auth
    HTTP bearer

Request body

assistant_idstring uuid required

Unique identifier of the assistant

thread_idstring uuid

Unique identifier of the thread

streamboolean

Whether to stream the completion results

Example request

{
  "assistant_id": "0fade940-133f-49e6-bf4b-8f662186479b",
  "messages": [
    {
      "role": "assistant",
      "content": "I'd be happy to help you write a business plan. A comprehensive business plan typically includes several key sections..."
    },
    {
      "role": "user",
      "content": "Can you help me write a business plan?"
    }
  ]
}

Response

Either a single JSON object (stream absent or false) or a stream. A newline-delimited JSON (NDJSON) stream: one complete JSON object per line, each terminated by \n. Despite the text/event-stream media type this is not Server-Sent Events — there is no data: prefix and no blank-line record separator, so an off-the-shelf SSE parser will not read it. Split the body on \n and JSON.parse each non-empty line, buffering any trailing partial line across reads: a line can straddle a transport chunk boundary. A *_delta event carries the whole value so far rather than an increment, so replace what you are holding instead of appending to it; note that thread.message.delta snapshots can transiently include tool-status text and are not guaranteed to grow monotonically. The stream normally ends with {"event":"done"} — a connection aborted or stalled mid-turn ends without one.

threadIdstring required

Unique identifier of the thread

Changes

No recorded changes to this operation across all 1 revision of this API.