Stream the consultation summary
/ai-doc/summaryStreams the consultation summary; the final result is in the done event.
Request URL
POST https://open-api.habitaxx.com/v1/ms-ai-fast/ai-doc/summaryRequest headers
Authorization: Bearer <ACCESS_TOKEN>
Content-Type: application/json
Accept: text/event-streamRequest body
{
"session_id": "<SESSION_ID>",
"pet_profile_id": 44,
"lang": "en-US"
}Request fields
| Field | Type | Required | Description |
|---|---|---|---|
session_id | string | Yes | The session_id returned when the session was created in step 2. |
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. |
lang | string | No | Omit it or send the same language as the session, for example zh-CN. |
Response headers
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.
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_DOC_SUMMARY_STREAM_FAILED","error_code":5401,"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; use it for incremental display only and never to decide completion | {"type":"content","content":"intermediate summary text"} |
done | Stream-end event; only this means success | {"type":"done","data":{"session_id":"<SESSION_ID>","data":{"content":"complete summary"},"raw_content":"raw model output","gateway_request_id":"<REQUEST_ID>"}} |
error | Error event; retry only when retryable is true, with a bounded retry budget | {"type":"error","code":"AI_DOC_SUMMARY_STREAM_FAILED","error_code":5401,"message":"流式生成问诊总结失败","retryable":true,"recommended_action":"retry_later"} |
The content inside the done event equals the concatenation of all content events; do not submit the report task unless the summary stream ended with done.
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 consultation summary text; render it in the summary card. |
raw_content | string | Raw model output; troubleshooting only. |
gateway_request_id | string | Gateway request ID. |
Next step
After a successful summary, call Create a consultation report task, then poll with Query an asynchronous task and read the result with Retrieve a complete report.