This interface is used to ask questions to AI and return the answers in real time via streaming, making it suitable for chat, intelligent customer service, or question-and-answer scenarios.
POST https://api.helplook.net/api/chats/stream
| Parameter name | type | Is this field required? | describe |
|---|---|---|---|
| x-api-key | string | yes | The user's API Key is used for authentication. |
| Parameter name | type | Is this field required? | describe |
|---|---|---|---|
| question | string | yes | User Question |
| session_id | string | no | Session ID, used to maintain context, can be an empty string to indicate a new session. |
| version_id | string | no | The site supports multiple versions; you can provide a version ID, otherwise ignore it. |
| web_search_switch | int | no | Enable online search function: 0 = disabled, 1 = enabled |
curl --location --request POST 'https://api.helplook.net/api/chats/stream' \
--header 'x-api-key: {api-key}' \
--data-raw '{
"question":"提问",
"session_id":"会话id",
"version_id":"",
"web_search_switch":0
}'
This interface is a streaming response, returning a text stream in Server-Sent Events (SSE) format or Chunked Transfer-Encoding format.
Each stream of data is typically a JSON string representing a portion of the generated response.
Single streaming response example
data: {"choices":[{"delta":{"content":"","reasoning_content":"我这是推理","role":"assistant"}}],"object":"chat.completion.chunk","data":[]}
data: {"choices":[{"delta":{"content":"你好","role":"assistant"}}],"object":"chat.completion.chunk","data":[]}
data: {"choices":[],"object":"source","data":{"source":[]}} // 该回答基于的文档来源
data: {"choices":[],"object":"error","data":{"code": "错误码", "message": "错误信息"}} // 该回答失败
data: [DONE]
| field name | type | describe |
|---|---|---|
| object | string | Used to differentiate this JSON data: chat.completion.chunk - the answer from the larger model, source - the data source for this answer, error - the error message indicating that the answer failed. |
| choices[0].delta.content | string | The content of the answer |
| choices[0].delta.reasoning_content | string | AI-inferred content |
| data | object | Used to store error messages or document source data |