Stream reasoning information
POST
/ai-doc/reason-infoStreams the reasoning text; the final result is in the done event.
Request URL
text
POST https://open-api.habitaxx.com/v1/ms-ai-fast/ai-doc/reason-infoRequest headers
http
Authorization: Bearer <ACCESS_TOKEN>
Content-Type: application/json
Accept: text/event-streamRequest body
json
{
"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
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_DOC_REASON_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 reasoning text"} |
done | Stream-end event; only this means success | {"type":"done","data":{"session_id":"<SESSION_ID>","data":{"content":"complete reasoning text"},"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_REASON_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; raw_content is for troubleshooting only; error_code values are listed in Error Handling.
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 reasoning text; equals the concatenation of all content events. |
raw_content | string | Raw model output; troubleshooting only. |
gateway_request_id | string | Gateway request ID. |
Next step
After done, call Get condition analysis.