Skip to main content
POST

Authorizations

Authorization
string
header
required

Every request authenticates with an API key: Authorization: Bearer {API_KEY}. App endpoints take an app API key; knowledge endpoints take a knowledge base API key (Get Started).

Keep keys server-side; never embed them in client code. Requests with a missing or invalid key fail with HTTP 401 (unauthorized).

Body

application/json

Request body to create a completion message.

inputs
object
required

Values for the app's input variables, keyed by variable name. The expected names and types come from the user_input_form field of Get App Parameters.

user
string
required

End-user identifier, defined by your app and unique within it. Messages and files are visible only to requests carrying the same user. See End User Identity.

files
object[]

Files to attach to the request. For a local file, first upload it via Upload File, then reference the returned id as upload_file_id with transfer_method: local_file.

query
string
default:""

The text to process. Legacy field; newer apps pass this inside inputs instead.

response_mode
enum<string>

Mode of response return. streaming (recommended) uses SSE. blocking returns after completion (may be interrupted for long processes). Cloudflare timeout is 100 s. When omitted, defaults to blocking behavior.

Available options:
streaming,
blocking

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 CompletionResponse object.
  • If response_mode is streaming, returns text/event-stream with a stream of ChunkCompletionEvent objects.
answer
string

Complete response content.

created_at
integer<int64>

Message creation timestamp (Unix epoch seconds).

event
string

Event type, fixed as message.

id
string<uuid>

Unique ID of this response event.

message_id
string<uuid>

Unique message ID. Use this as the message_id parameter when calling feedback or suggested questions endpoints.

metadata
object

Metadata including usage and retriever resources.

mode
string

App mode, fixed as completion.

task_id
string<uuid>

Task ID for request tracking and the Stop Completion Message Generation API.

Last modified on September 9, 2026