Stream recognition and summary (SSE)
POST
/ai-pic/summary/streamOne call performs recognition and summarisation: the text streams through content events and the structured result arrives in the done event.
Request URL
text
POST https://open-api.habitaxx.com/v1/ms-ai-fast/ai-pic/summary/streamRequest headers
http
Authorization: Bearer <ACCESS_TOKEN>
Content-Type: application/json
Accept: text/event-streamRequest body
json
{
"session_id": "<SESSION_ID>",
"pet_profile_id": 44,
"img_url": "<UPLOAD_RESPONSE_DATA_URL>",
"sub_module_type": 6,
"lang": "en-US"
}Request fields
| Field | Type | Required | Description |
|---|---|---|---|
session_id | string | Yes | ID of the image-recognition session you created. |
pet_profile_id | integer | No | Pet-profile ID; when omitted the profile bound to the session is used. If provided it must match the session. |
img_url | string | Yes | The exact url value inside the top-level data object of the upload response. It must be an asset uploaded by the current user with status ready; the server re-validates it by direct connection, rejecting private addresses and Unix sockets, allows up to 3 redirects, caps the size at 20 MiB, and applies a fetch timeout. Recognition failures are retried automatically. |
sub_module_type | integer | Yes | 1 through 8; it must match the value used when the session was created. |
lang | string | No | Omit it or send the same language as the session, for example zh-CN or en-US. |
Response headers
http
Content-Type: text/event-stream; charset=utf-8
Cache-Control: no-cache
Transfer-Encoding: chunkedNo Content-Length; read it as a stream. See Streaming responses for the frame format, event types and proxy buffering.
Response type and example
Content-Type: text/event-stream. Every event is a single data: {...} line and event blocks are separated by a blank line; the event type lives in the JSON type field, and no event: line is used.
text
data: {"type":"metadata","gateway_request_id":"<REQUEST_ID>"}
data: {"type":"content","content":"正在整理图片识别结果。"}
data: {"type":"done","data":{"session_id":"<SESSION_ID>","data":{"content":"- 🐱 穿着红色衣服的小动物"},"raw_content":"模型原始输出","gateway_request_id":"<REQUEST_ID>"}}
data: {"type":"error","code":"AI_PIC_SUMMARY_STREAM_FAILED","error_code":5106,"message":"流式生成图片识别总结失败","retryable":true,"recommended_action":"retry_later"}Event format
| Event type | Description | Data format |
|---|---|---|
metadata | Stream-start event; occurs exactly once per stream | {"type":"metadata","gateway_request_id":"<REQUEST_ID>"} |
content | Data-stream event, may repeat; for incremental display only | {"type":"content","content":"intermediate recognition text"} |
done | Stream-end event; only this means success, and data carries the structured recognition result | {"type":"done","data":{"session_id":"<SESSION_ID>","data":{"content":"- 🐱 穿着红色衣服的小动物"},"raw_content":"模型原始输出","gateway_request_id":"<REQUEST_ID>"}} |
error | Error event; retry only when retryable is true, with a bounded retry budget | {"type":"error","code":"AI_PIC_SUMMARY_STREAM_FAILED","error_code":5106,"message":"流式生成图片识别总结失败","retryable":true,"recommended_action":"retry_later"} |
The inner fields of data depend on the recognition capability of sub_module_type; raw_content is for troubleshooting only and must not drive business display.
Done payload fields
Paths below are relative to the response data; data.xxx refers to a field of the nested inner data object.
| Field | Type | Description |
|---|---|---|
type | string | Event type: metadata (start), content (increment), done (terminal success) or error (failure). |
content | string | Incremental text carried by a content event. |
data | object | Payload object carried by the done event (it nests another data object). |
session_id | string | Current session ID. |
data.content | string | Complete recognition summary text of all stages. |
raw_content | string | Raw model output; troubleshooting only. |
gateway_request_id | string | Gateway request ID. |
Next step
- Call Create an image-recognition report task with the session
session_idand the uploaded image URL. - Poll with Query an asynchronous task, then read the result with Retrieve a complete report.