Skip to main content
Minimum-viable, end-to-end examples against the hosted API.

curl

BASE=https://test-mirobody-api.thetahealth.ai/v1
KEY="mb_live_..."

# 1) Basic chat
curl $BASE/chat/completions \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"model":"mirobody-flash","messages":[{"role":"user","content":"How is my fasting glucose trending?"}],"user":"alice"}'

# 2) Write a record, then ask again
curl $BASE/data \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"user":"alice","records":[{"indicator":"fasting_glucose","value":5.4,"unit":"mmol/L","time":"2026-06-16T07:30:00Z"}]}'

# 3) Upload a report (OCR/parse), then ask about it
curl $BASE/files -H "Authorization: Bearer $KEY" -F "user=alice" -F "file=@report.pdf"

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(api_key="mb_live_...", base_url="https://test-mirobody-api.thetahealth.ai/v1")

# Non-streaming
resp = client.chat.completions.create(
    model="mirobody-flash",
    messages=[{"role": "user", "content": "How is my fasting glucose trending?"}],
    user="alice",
)
print(resp.choices[0].message.content)

# Streaming
stream = client.chat.completions.create(
    model="mirobody-flash",
    messages=[{"role": "user", "content": "Summarize my last checkup."}],
    user="alice",
    stream=True,
)
for chunk in stream:
    delta = chunk.choices[0].delta
    if getattr(delta, "content", None):
        print(delta.content, end="", flush=True)
# File upload uses multipart, so call the REST endpoint directly
import requests

up = requests.post(
    "https://test-mirobody-api.thetahealth.ai/v1/files",
    headers={"Authorization": "Bearer mb_live_..."},
    data={"user": "alice"},
    files={"file": open("report.pdf", "rb")},
)
print(up.json())   # {file_key, filename, indicators, abstract, subject}

Node.js (OpenAI SDK)

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.MIROBODY_API_KEY,
  baseURL: "https://test-mirobody-api.thetahealth.ai/v1",
});

// Non-streaming
const resp = await client.chat.completions.create({
  model: "mirobody-flash",
  messages: [{ role: "user", content: "How is my fasting glucose trending?" }],
  user: "alice",
});
console.log(resp.choices[0].message.content);

// Streaming
const stream = await client.chat.completions.create({
  model: "mirobody-flash",
  messages: [{ role: "user", content: "Summarize my last checkup." }],
  user: "alice",
  stream: true,
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
More: Chat reference · Data · Files.