Text Generator
Overview
The text generation application offers non-session support and is ideal for translation, article writing, summarization AI, and more.
Base URL
Authentication
The Service API uses API-Key authentication.
Important: 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.
For all API requests, include your API Key in the Authorization HTTP Header:
API Endpoints
Send Message
POST /completion-messages
Send a request to the text generation application.
Request Body
-
inputs (object) Required
- Allows the entry of various variable values defined by the App
- Contains multiple key/value pairs, each key corresponding to a specific variable
- At least one key/value pair required
-
response_mode (string) Required
- Modes supported:
streaming
: Streaming mode (recommended), implements typewriter-like output through SSEblocking
: Blocking mode, returns result after execution completes- Note: Due to Cloudflare restrictions, requests will timeout after 100 seconds
- Modes supported:
-
user (string) Required
- User identifier for retrieval and statistics
- Should be uniquely defined within the application
-
files (array[object]) Optional
- File list for image input with text understanding
- Available only when model supports Vision capability
- Properties:
type
(string): Supported type: imagetransfer_method
(string): ‘remote_url’ or ‘local_file’url
(string): Image URL (for remote_url)upload_file_id
(string): Uploaded file ID (for local_file)
Response
Blocking Mode Response Returns a CompletionResponse object with Content-Type: application/json
Streaming Mode Response Returns ChunkCompletionResponse stream with Content-Type: text/event-stream
Events:
message
: LLM text chunk eventmessage_end
: Stream end eventmessage_replace
: Content replacement eventerror
: Exception eventping
: Keep-alive event (every 10s)
Example Requests
File Upload
POST /files/upload
Upload files (currently only images) for multimodal understanding.
Supported Formats
- png
- jpg
- jpeg
- webp
- gif
Request Body
Requires multipart/form-data:
file
(File) Requireduser
(string) Required
Response
Stop Generate
POST /completion-messages/:task_id/stop
Stop ongoing generation (streaming mode only).
Request Body
user
(string) Required
Response
Message Feedback
POST /messages/:message_id/feedbacks
Submit user feedback on messages.
Request Body
rating
(string) Required: “like” | “dislike” | nulluser
(string) Required
Response
Get Application Information
GET /parameters
Retrieve application configuration and parameters.
Query Parameters
user
(string) Required
Response
Types
Usage
Error Codes
Common error codes you may encounter:
- 400: invalid_param - Abnormal parameter input
- 400: app_unavailable - App configuration unavailable
- 400: provider_not_initialize - No available model credential configuration
- 400: provider_quota_exceeded - Model invocation quota insufficient
- 400: model_currently_not_support - Current model unavailable
- 400: completion_request_error - Text generation failed
- 500: Internal server error