Skip to main content

Last Update: 7/13/2025

SenseFlow Text Completion API

The SenseFlow Text Completion API allows you to generate text content without maintaining conversation context. This is suitable for tasks like translation, article writing, and AI summarization.

Endpoints

Generate Completion

POST https://platform.llmprovider.ai/v1/agent/completion-messages

Request Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Request Body

ParameterTypeDescription
agentstringmodel name.
inputsobject(Optional) Key-value pairs of variables defined in the app.
response_modestringResponse mode: streaming (recommended) or blocking
userstringUnique identifier for the end user
filesarray(Optional) Array of file objects for upload
Files Object Structure
FieldTypeDescription
typestringFile type (currently only supports 'image')
transfer_methodstringremote_url or local_file
urlstringImage URL (when transfer_method is remote_url)
upload_file_idstringFile ID (when transfer_method is local_file)

Example Request

{
"model": "",
"inputs": {
"query": "Hello, world!"
},
"response_mode": "streaming",
"user": "abc-123"
}

Response

The response varies based on the response_mode:

  • For blocking mode: Returns a ChatCompletionResponse object
  • For streaming mode: Returns a stream of ChunkChatCompletionResponse objects
ChatCompletionResponse Structure
FieldTypeDescription
message_idstringUnique message identifier
modestringFixed as "chat"
answerstringComplete response content
metadataobjectMetadata information
usageobjectModel usage information
created_atintegerMessage creation timestamp

Streaming Response Events

Each streaming chunk starts with data: and chunks are separated by \n\n. Example:

data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "message_id": "663c5084", "answer": "Hi", "created_at": 1705398420}\n\n

Different event types in the stream:

Event TypeDescriptionFields
messageText chunk from LLMtask_id, message_id, answer, created_at
message_endMessage completiontask_id, message_id, metadata, usage, retriever_resources
tts_messageSpeech synthesis chunktask_id, message_id, audio (base64), created_at
tts_message_endSpeech synthesis completiontask_id, message_id, audio (empty), created_at
message_replaceContent moderation replacementtask_id, message_id, answer, created_at
errorStream error eventtask_id, message_id, status, code, message
pingKeep-alive ping (every 10s)-

Example Responses

For blocking mode:

{
"id": "0b089b9a-24d9-48cc-94f8-762677276261",
"answer": "Hello! How can I help you today?",
"created_at": 1679586667
}

For streaming mode:

data: {"event": "message", "task_id": "5ad4cb98", "message_id": "a8bdc41c", "answer": "Hello!", "created_at": 1721205487}
data: {"event": "tts_message", "task_id": "3bf8a0bb", "message_id": "a8bdc41c", "audio": "base64_audio_data", "created_at": 1721205487}
data: {"event": "message_end", "task_id": "5ad4cb98", "message_id": "a8bdc41c", "metadata": {}, "usage": {"total_tokens": 10}}
data: {"event": "tts_message_end", "task_id": "3bf8a0bb", "message_id": "a8bdc41c", "audio": "", "created_at": 1721205487}

Example Request

curl -X POST 'https://platform.llmprovider.ai/v1/agent/completion-messages' \
--header 'Authorization: Bearer $YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "",
"inputs": {"query": "Hello, world!"},
"response_mode": "streaming",
"user": "abc-123"
}'

Stop Response

POST https://platform.llmprovider.ai/v1/agent/completion-messages/:task_id/stop

Stop a streaming response. Only available for streaming mode.

Request Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Path Parameters

ParameterTypeDescription
task_idstringTask ID obtained from the streaming response

Request Body Parameters

ParameterTypeRequiredDescription
modelstringYesagent name
userstringYesUser identifier (must match the message API user ID)

Response

FieldTypeDescription
resultstringupload result
Example Response
{
"result": "success"
}

Example Request

curl -X POST 'https://platform.llmprovider.ai/v1/agent/completion-messages/task_123/stop' \
--header 'Authorization: Bearer $YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "",
"user": "abc-123"
}'

Message Feedback

POST https://platform.llmprovider.ai/v1/agent/messages/:message_id/feedbacks

Submit user feedback (likes/dislikes) for messages to help developers optimize output.

Path Parameters

ParameterTypeDescription
message_idstringMessage ID

Request Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Request Body Parameters

ParameterTypeDescription
modelstringagent name
ratingstringFeedback type: "like", "dislike", or null
userstringUser identifier
contentstringOptional feedback details

Response

FieldTypeDescription
resultstringresult
Example Response
{
"result": "success"
}

Example Request

curl -X POST 'https://platform.llmprovider.ai/v1/agent/messages/msg_123/feedbacks' \
--header 'Authorization: Bearer $YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "",
"rating": "like",
"user": "abc-123",
"content": "This response was helpful"
}'