Use text.format on POST /v1/responses to force the model’s output into JSON. It follows the OpenAI Responses text.format spec and is available only in backbone mode (mode:"model").
text.format requires mode:"model". On the default agent mode it returns 400 unsupported_parameter (param: "text") — free-text that explodes downstream is more expensive than an interface error. The Answers API (/v1/chat/completions) likewise rejects response_format with 400.
json_object
Constrains the output to a syntactically valid JSON object (no schema):
{
"model": "mirobody-flash",
"mode": "model",
"input": "Reply with a JSON object having keys a and b.",
"text": { "format": { "type": "json_object" } }
}
The message text is a JSON string you parse yourself:
{ "output_text": "{\"a\":1,\"b\":2}", "status": "completed", ... }
json_schema
Constrains the output to a schema you supply. Set strict: true for exact schema adherence:
curl https://mirobody-api.thetahealth.ai/v1/responses \
-H "Authorization: Bearer $MIROBODY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "mirobody-flash",
"mode": "model",
"input": "Give me a manifest for apples with count 3.",
"text": {
"format": {
"type": "json_schema",
"name": "manifest",
"strict": true,
"schema": {
"type": "object",
"properties": {
"item": { "type": "string" },
"count": { "type": "integer" }
},
"required": ["item", "count"],
"additionalProperties": false
}
}
}
}'
from openai import OpenAI
client = OpenAI(api_key="mb_live_...", base_url="https://mirobody-api.thetahealth.ai/v1")
resp = client.responses.create(
model="mirobody-flash",
extra_body={"mode": "model"},
input="Give me a manifest for apples with count 3.",
text={
"format": {
"type": "json_schema",
"name": "manifest",
"strict": True,
"schema": {
"type": "object",
"properties": {"item": {"type": "string"}, "count": {"type": "integer"}},
"required": ["item", "count"],
"additionalProperties": False,
},
}
},
)
print(resp.output_text) # {"item":"apples","count":3}
Provider fallback
text.format passes through to the underlying model. When the backing provider has no native json_schema support, Mirobody automatically retries once as json_object with the schema injected into the system prompt. The retry is transparent — you still get schema-shaped JSON back — so treat structured output as reliable without knowing which provider backs a tier.
See also
- Backbone mode —
mode:"model", the prerequisite for text.format.
- Function calling — for tool-argument shaping, pair
text.format with tool_choice:"required".