Skip to content
Get Started

Agent API

Structured Output

text.format — constrain the model to JSON (json_object) or a JSON Schema (json_schema) in backbone mode.

Use text.format on POST /v1/responses to request JSON output. It follows the OpenAI Responses text.format shape and is available only in backbone mode (mode:"model").

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", ... }

Requests output that follows a schema you supply. strict: true is forwarded to providers that support native JSON Schema:

Terminal window
curl https://api.mirobody.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://api.mirobody.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}

text.format passes through to the underlying model. If the provider rejects native json_schema, Mirobody retries once as json_object with the schema included in the system prompt. That fallback targets the requested shape but does not validate the returned object against your schema. Parse and validate output_text yourself before using it.

  • Backbone modemode:"model", the prerequisite for text.format.
  • Function calling — for tool-argument shaping, pair text.format with tool_choice:"required".