Pet Image Recognition
Pet Image Recognition uses module_type = 5. Select exactly one capability with sub_module_type, whose valid values are 1 through 8. A session is bound to one capability and one input image. Create a new session to inspect a different body part or use a different image.
https://open-api.habitaxx.com/v1/ms-ai-fastRecommended integration
The shortest report workflow is: create the recognition session, upload the image, stream the recognition and summary, submit the report task, then poll and retrieve the report. See the full workflow for SSE handling, language behavior, and session constraints.
Capability matrix
sub_module_type | Capability |
|---|---|
1 | Breed recognition |
2 | Expression recognition |
3 | Dental detection |
4 | Feces detection |
5 | Vomit detection |
6 | Skin detection |
7 | Ear-canal detection |
8 | Eye detection |
sub_module_type is an API parameter, not display text. It must stay consistent with session creation: a skin session always sends 6 and must not switch to 8 under the same session_id.
Recommended flow
Call
POST /oss/images; read url from the top-level data object in the complete success JSON, then send that exact string as the later img_url value.Call an immediate recognition endpoint. If
session_id is omitted, the service creates a pic_... session.Use a JSON or SSE summary for an existing session when the product needs a saved session summary.
Submit the report task, poll it to completion, then retrieve the complete medical record.
Image URL handoff
Image Recognition and Smart Consultation share POST /oss/images. Here, url means the field in the upload response JSON; it is not a field returned by an image-recognition endpoint. Image-recognition request bodies use the field img_url, whose value must be copied unchanged from the upload response's url.
| Step | Endpoint or field | Requirement |
|---|---|---|
| 1 | POST /oss/images | Upload with multipart/form-data; the form field name is file. |
| 2 | Top-level url in the upload response | Read and persist the platform-registered image URL. |
| 3 | img_url in POST /ai-pic/summary/stream | Send the exact same URL from step 2 without rewriting it. |
| 4 | img_url in other image-recognition requests | Reuse the same URL for POST /ai-pic/sessions/report-tasks. |
Complete upload success response:
{
"code": 200,
"message": "success",
"data": {
"media_type": "image",
"file_name": "server-generated-name.jpg",
"object_key": "test/ai-pic/server-generated-name.jpg",
"content_type": "image/jpeg",
"size_bytes": 245810,
"etag": "<ETAG>",
"url": "<UPLOAD_RESPONSE_DATA_URL>"
}
}Corresponding image-recognition request body:
{
"pet_profile_id": 44,
"img_url": "<UPLOAD_RESPONSE_DATA_URL>",
"sub_module_type": 6,
"lang": "en-US"
}Do not replace url with an image webpage URL, a hand-built OSS URL, a third-party URL, a URL with a query string or fragment, or an asset uploaded by another user.
Choose an endpoint
This table explains which endpoint to call and what to do after success. Use the complete examples in the API overview and the individual endpoint pages to locate fields; isolated field paths no longer stand in for complete responses.
| Use case | Endpoint | Response type | What to do after success |
|---|---|---|---|
| Create the recognition session | POST /session-records/sessions | Regular JSON | Send module_type fixed to 5, plus sub_module_type (1-8) and a numeric pet_profile_id; read session_id from the data object of the complete response. |
| Upload the image | POST /oss/images | Regular JSON | Read url from the top-level data object of the complete response and use it unchanged as img_url later. |
| Run recognition and generate the summary | POST /ai-pic/summary/stream | SSE stream | Render events whose type is content progressively. Recognition succeeds only after the complete terminal event whose type is done; the final result is inside that done event. |
| Generate a complete report | POST /ai-pic/sessions/report-tasks | Regular JSON containing a background task | Read task_id from the task object in the complete success response. Then call GET /ai-tasks/{task_id} until the task status becomes succeeded, failed, or canceled. This call may be published in parallel with the recognition stream. |
| Read the report | GET /medical-records/{record_id} | Regular JSON | After the report task succeeds, read the record details and report fragments; list past recognition records with GET /medical-records?module_type=5. |
Only complete-report generation creates a background task that must be polled; its task type is ai_pic_report_generate. Recognition itself is performed by summary/stream, so there is no recognition task to poll.
Image and session prerequisites
- Image uploads support
jpg,jpeg,png,webp, andgif, up to 10 MiB. See Common APIs. pet_profile_idis the numeric ID obtained from the Pet Profiles endpoints (for example44); it must match the session.- Image-recognition language is the request body field
lang, defaulting tozh-CN. It is not the same as a profile API query parameter such as?locale=.... When a session exists, omitlangor send the exact same value used to create that session. - In the successful JSON response from
POST /oss/images, read theurlfield inside the top-leveldataobject. Send that exact string asimg_url; third-party URLs, hand-built OSS URLs, URLs with a query string, and another user's asset are rejected. Typical errors includeMEDIA_URL_NOT_ALLOWED,MEDIA_ASSET_NOT_FOUND, andMEDIA_URL_INVALID. - The first image asset used by a session is bound to that session. Replacing it in a later summary or report request returns
TASK_IDEMPOTENCY_CONFLICT; create a new session instead.
Logging and compliance
- After each upload, record the response
urltogether withsession_idandsub_module_typeas the minimum audit trail. - Images and recognition results contain pet and user data; handle them according to your own data-authorisation and retention rules.
- Recognition results support health screening only and are not a veterinary diagnosis, prescription, or emergency advice.