Send a request to the text generation application.
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.
Request body to create a completion message.
Allows the entry of various variable values defined by the App. The inputs parameter contains multiple key/value pairs, with each key corresponding to a specific variable and each value being the specific value for that variable. The text generation application requires at least one key/value pair to be inputted.
{ "query": "Translate 'hello' to Spanish." }The mode of response return.
streaming: Streaming mode (recommended), implements a typewriter-like output through SSE (Server-Sent Events).blocking: Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long). Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds in blocking mode for long processes.streaming, blocking "streaming"
User identifier, used to define the identity of the end-user for retrieval and statistics. Should be uniquely defined by the developer within the application.
"user-12345"
File list, suitable for inputting files (images) combined with text understanding and answering questions, available only when the model supports Vision capability.
{
"type": "image",
"transfer_method": "remote_url",
"url": "https://example.com/image.png"
}Successful response. The content type and structure depend on the response_mode parameter in the request.
response_mode is blocking, returns application/json with a CompletionResponse object.response_mode is streaming, returns text/event-stream with a ChunkCompletionResponse stream.Response object for blocking mode completion.
Event type, for blocking mode this is typically 'message'.
"message"
Unique message ID.
App mode, fixed as completion for this response type (Note: MD also mentions 'chat', using 'completion' from example).
"completion"
Complete response content.
Message creation timestamp (Unix epoch).
1705395332