Structured output
JSON-schema constrained decoding. OpenAI strict-mode subset.Malibu supports OpenAI’s
response_format for structured output — both json_schema (schema-constrained) and json_object (top-level JSON enforced). Locked surface.
JSON Schema (strict)
strict: true guarantees schema conformance via constrained decoding — the model can only emit tokens that keep the output valid against the schema. Combined with a post-hoc validate-and-fault, this is a hard guarantee, not a best-effort heuristic.
Supported schema subset
Malibu implements the OpenAI strict-mode JSON Schema subset:type: "object"withpropertiesandrequiredtype: "string" | "number" | "integer" | "boolean" | "array"enumadditionalProperties: false(recommended)- Nested objects and arrays
$refto definitions within the same schema
oneOf,anyOfat the top level (some nested uses OK)pattern,format(validated post-hoc as best-effort but not constrained)- Unbounded recursion
if/then/elseconditionals
json_object — top-level JSON without a schema
json_object actually enforce top-level JSON on the wire — you get a parseable object even when the model would otherwise wrap it in prose.
Streaming + structured output
Bothjson_schema and json_object work with stream: true. The emitted delta.content chunks are still constrained; concatenating them yields valid JSON.
Failure modes
- Schema outside the subset → 400 with the offending field.
- Model can’t satisfy the schema in the token budget → response truncated; parse fails. Increase
max_tokensor simplify the schema. - Fallback model (non-supported chat template) → structured output falls back to prompted JSON with post-hoc validation.
strict: truewill still fault the response if the output doesn’t parse.