Skip to content

Stream the consultation summary ​

POST/ai-doc/summary

Streams the consultation summary; the final result is in the done event.

Request URL ​

text
POST https://open-api.habitaxx.com/v1/ms-ai-fast/ai-doc/summary

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,
  "lang": "en-US"
}

Request fields ​

FieldTypeRequiredDescription
session_idstringYesThe session_id returned when the session was created in step 2.
pet_profile_idintegerNoPet-profile ID; when omitted the profile bound to the session is used. If provided it must match the session.
langstringNoOmit it or send the same language as the session, for example zh-CN.

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_DOC_SUMMARY_STREAM_FAILED","error_code":5401,"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; use it for incremental display only and never to decide completion{"type":"content","content":"intermediate summary text"}
doneStream-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>"}}
errorError 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.

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 consultation summary text; render it in the summary card.
raw_contentstringRaw model output; troubleshooting only.
gateway_request_idstringGateway 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.

最近更新

Qijie Open Platform · API Documentation