Skip to main content

Endpoint

The Answers API is a closed, grounded completion: one question in, one evidence-backed answer out. The platform’s agent gathers the Subject’s real health data with server-side tools (you can’t add or remove them here), then composes a single clean answer with a traceable tool trace. Set stream: true for SSE. It is deliberately closed — no client tools, no response formatting, no multi-turn state. That makes it trivial to embed: call it directly, or wrap it as one tool inside your own agent. If you need client-side tools, stored conversations, or previous_response_id chaining, use the Agent API (POST /v1/responses). All /v1 endpoints share one base URL — pick your contracted cluster:
China-region deployments use https://mirobody-api.thetahealth.cn/v1. See Regions for the full host matrix.

Quickstart

Request body

The user field is the tenant-isolation key. The backend maps (your account, user) to an internal Subject; each user you pass is fully isolated from the others. Pass each end-user’s stable id and their data never crosses over. Omit it and the call falls back to your account’s default Subject. Subjects are invisible to the Mirobody web app and to other developers. The user value is normalized (trimmed + lowercased) before mapping, so Alice and alice resolve to the SAME Subject — pass a stable, canonical id.

Unsupported parameters

This surface is a closed grounded completion — tools run server-side only, and the answer is free-form text. Parameters that contradict that are explicitly rejected with 400 (code: unsupported_parameter, param names the offender) rather than silently swallowed:
Sampling parameters are accepted but ignored (industry norm for agent-backed surfaces): max_tokens doesn’t cap output; temperature, top_p, stop, and seed have no effect. The response always contains a single choice.

Response

message.content carries one clean final answer. The gather phase (thinking + tool calls) is surfaced in separate channels, so the answer itself is never polluted by tool narration.
reasoning_content and tool_steps are additive channels — clients that only read message.content keep working.

Usage accounting

usage.prompt_tokens reports the input you actually sent (your messages); the platform’s own system prompt and tool schemas are broken out as prompt_tokens_details.system_tokens instead of being blamed on your prompt. completion_tokens_details.reasoning_tokens counts thinking tokens. Counts are summed across every model call of the agent turn.

Streaming

With stream: true, frames arrive in order. The first chunk carries delta.role: "assistant" (OpenAI parity — many clients key message init off it), then tool/thinking deltas, then a single uninterrupted answer stream:
Frames are chat.completion.chunk objects. Merge tool_steps by id (streamed steps carry {id, name, arguments}; full result payloads are available on the non-stream response). The final frame (before [DONE]) carries the top-level health_records / citations and usage. An upstream failure arrives as an SSE {"error": ...} frame before the stream ends. Clients that only read delta.content keep working.

System prompts

A system message sets the tone, persona, format, and language of the answer. Data gathering is platform-controlled — the agent always reads the Subject’s real data — so a system prompt shapes how the answer reads, never whether real data is used.

Built-in tools

Beyond plain tool-calling, the hosted agent can plan multi-step work, delegate subtasks, run sandboxed code for numeric analysis (trends, correlations), and read the Subject’s uploaded files. You don’t invoke any of this — the agent does, against the Subject’s data. The public tool catalog — what GET /api/health reports as tool_names:
  • query_health_data, summarize_health_data — search and aggregate the Subject’s records
  • list_clinical_records — list clinical documents / FHIR-backed records
  • list_family_members — resolve care-circle members the Subject is allowed to query
  • write_fhir_observation — write a structured FHIR observation
  • search_medical_literature, get_clinical_trials, get_article_by_pmcid — look up medical evidence (feeds citations)
  • fetch_url — read a web page
Planning / delegation / code-analysis tools are internal plumbing and not part of the API contract. ask_user appears in GET /api/health’s tool_names (it serves the web app) but is disabled on the /v1 surfaces — an API caller has no widget to answer it. The public set can vary by cluster; GET /api/health reports the live tool_names. Files you upload via /v1/files land in /uploads, and the agent reads them automatically. To add your own tools, use the Agent API’s function calling — this surface intentionally has no tool injection.

Charts (vis-chart)

When the answer involves a trend / comparison / distribution, it may embed a fenced ```vis-chart block of pure-data JSON ({type, title, axisXTitle, axisYTitle, data}). Rendering is the client’s job — the API only returns the data spec. Detect the fenced block and render it (line / area / bar / pie).