Skip to content

Stream recognition and summary (SSE) ​

POST/ai-pic/summary/stream

One 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/stream

Request headers ​

http
Authorization: Bearer <ACCESS_TOKEN>
Content-Type: application/json
Accept: text/event-stream

Request 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 ​

FieldTypeRequiredDescription
session_idstringYesID of the image-recognition session you created.
pet_profile_idintegerNoPet-profile ID; when omitted the profile bound to the session is used. If provided it must match the session.
img_urlstringYesThe 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_typeintegerYes1 through 8; it must match the value used when the session was created.
langstringNoOmit 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: chunked

No 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 typeDescriptionData format
metadataStream-start event; occurs exactly once per stream{"type":"metadata","gateway_request_id":"<REQUEST_ID>"}
contentData-stream event, may repeat; for incremental display only{"type":"content","content":"intermediate recognition text"}
doneStream-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>"}}
errorError 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.

FieldTypeDescription
typestringEvent type: metadata (start), content (increment), done (terminal success) or error (failure).
contentstringIncremental text carried by a content event.
dataobjectPayload object carried by the done event (it nests another data object).
session_idstringCurrent session ID.
data.contentstringComplete recognition summary text of all stages.
raw_contentstringRaw model output; troubleshooting only.
gateway_request_idstringGateway request ID.

Next step ​

最近更新

Qijie Open Platform · API Documentation