Structured output
Updated
Pass a response_format and the model is constrained toward your JSON Schema during generation. Use it for anything downstream that needs a known shape: database inserts, form filling, data extraction, classification with fixed enums.
| Connection | Value |
|---|---|
| API base | https://api.runinfra.ai/v1 |
| Workspace key | rp_... |
| Process variable | RUNINFRA_GATEWAY_KEY |
| Billing | The existing funding rules of your open-model account. |
Replace MODEL_ID with an available id from Open models; read current capabilities, limits and prices from GET /v1/models.
Minimal code
These examples use reasoning_effort: "none" so the selected model can enforce the schema without generating reasoning first. Choose a model that supports JSON output and disabling reasoning. A model that is temporarily paused is reported in GET /v1/models and on its model page.
The SDK parse() helpers validate the reply against your Pydantic or Zod model. The curl tab shows the raw response_format request underneath them, which is the portable form for any client.
Which model, and what it needs
On some models, the gateway applies reasoning_effort: "none" when you omit it beside a schema. The model-specific source reference identifies the affected models; this exception is not a discovery field. The response header X- reports the effort applied when the request did not name one.
If you explicitly send an incompatible effort, the request is refused with 400, param: "response_format". Read Chat completions for model-specific behavior.
What to tune
| Parameter | Effect |
|---|---|
response_format: { type: "json_object" } | Looser. Any valid JSON, no schema enforcement. |
response_format. | Accepted for Compatible clients. The Pydantic and Zod helpers set it for you. |
temperature: 0 | Best for deterministic extraction. Non-zero works too. |
reasoning_effort: "none" | Lets a model that supports disabling reasoning enforce a schema without reasoning tokens. |
Common mistakes
- Asking for JSON in the prompt instead of in
response_format. The model can still add commentary or markdown fences. Pass the field. - Leaving
additionalPropertiesopen. WithoutadditionalProperties: false, the reply may carry keys you did not declare. The helpers set it. Raw JSON Schema users must add it. - Nested
anyOfwithout discriminators. Use enums or discriminated unions. An unboundedanyOfgives the schema too little shape to enforce. - Expecting enums to be case-insensitive. Schema enums are exact match.
"Paris"does not satisfyenum: ["paris", "berlin"].