Skip to main content
POST
/
chat-messages
Error
A valid request URL is required to generate request examples
{
  "event": "message",
  "task_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "message_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "conversation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "mode": "chat",
  "answer": "<string>",
  "metadata": {
    "usage": {
      "prompt_tokens": 123,
      "prompt_unit_price": "<string>",
      "prompt_price_unit": "<string>",
      "prompt_price": "<string>",
      "completion_tokens": 123,
      "completion_unit_price": "<string>",
      "completion_price_unit": "<string>",
      "completion_price": "<string>",
      "total_tokens": 123,
      "total_price": "<string>",
      "currency": "USD",
      "latency": 123
    },
    "retriever_resources": [
      {
        "position": 123,
        "dataset_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "dataset_name": "<string>",
        "document_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "document_name": "<string>",
        "segment_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "score": 123,
        "content": "<string>"
      }
    ]
  },
  "created_at": 123
}

Authorizations

Authorization
string
header
required

API Key authentication. For all API requests, include your API Key in the Authorization HTTP Header, prefixed with 'Bearer '. Example: Authorization: Bearer {API_KEY}. Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.

Body

application/json

Request body to send a chat message.

query
string
required

User Input/Question content.

user
string
required

User identifier, unique within the application. Note: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface.

inputs
object

Allows the entry of various variable values defined by the App. Contains key/value pairs. Default {}.

response_mode
enum<string>
default:streaming

Mode of response return. streaming (recommended) uses SSE. blocking returns after completion (may be interrupted for long processes; not supported in Agent Assistant mode). Cloudflare timeout is 100s.

Available options:
streaming,
blocking
conversation_id
string

Conversation ID to continue a conversation. Pass the previous message's conversation_id.

files
object[]

File list (images) for Vision-capable models.

auto_generate_name
boolean
default:true

Auto-generate conversation title. Default true. If false, use conversation rename API with auto_generate: true for async title generation.

Response

Successful response. The content type and structure depend on the response_mode parameter in the request.

  • If response_mode is blocking, returns application/json with a ChatCompletionResponse object.
  • If response_mode is streaming, returns text/event-stream with a stream of ChunkChatEvent objects.

Response object for blocking mode chat completion.

event
string

Event type, fixed as message.

Example:

"message"

task_id
string<uuid>

Task ID for request tracking and stop response API.

id
string<uuid>

Unique ID of this response/message event.

message_id
string<uuid>

Unique message ID.

conversation_id
string<uuid>

Conversation ID.

mode
string

App mode, fixed as chat.

Example:

"chat"

answer
string

Complete response content.

metadata
object
created_at
integer<int64>

Message creation timestamp (Unix epoch seconds).