Send Completion Message
Available for: Text Generator apps.
Sends a request to a text-generation app and returns the generated text.
Authorizations
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
Request body to create a completion message.
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.
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.
The text to process. Legacy field; newer apps pass this inside inputs instead.
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.
streaming, blocking 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.
- Option 1
- Option 2
Response
Successful response. The content type and structure depend on the response_mode parameter in the request.
- If
response_modeisblocking, returnsapplication/jsonwith aCompletionResponseobject. - If
response_modeisstreaming, returnstext/event-streamwith a stream ofChunkCompletionEventobjects.
Event type, fixed as message.
Task ID for request tracking and the Stop Completion Message Generation API.
Unique ID of this response event.
Unique message ID. Use this as the message_id parameter when calling feedback or suggested questions endpoints.
App mode, fixed as completion.
Complete response content.
Metadata including usage and retriever resources.
Message creation timestamp (Unix epoch seconds).