---
title: "Structured Outputs API: Strict JSON Schema Guide | Straitly Docs"
description: "Return strict JSON Schema objects via response_format json_schema on /v1/chat/completions. Python examples, refusal handling and local validation."
url: https://straitly.ai/docs/structured-outputs
updated: 2026-11-26
publisher: Straitly (https://straitly.ai)
---

Docs

API guides

# Structured outputs

Copy docs

**On this page**

Pass response\_format with type "json\_schema" and strict: true on /v1/chat/completions to constrain replies to a predictable JSON Schema object across supported models. Check finish\_reason and message.refusal, and always validate parsed JSON locally.

### Choose the output mode

- Plain text is appropriate for a human-readable reply.
- JSON mode requests valid JSON but does not by itself enforce your field schema.
- JSON Schema output requests a particular structure on supported models. A refusal, length limit, or transport error can still prevent a usable result.

### Request a schema

Install openai and jsonschema for Python. The example uses the Chat Completions response\_format field and validates the final response locally. Verify schema support for the model before production use.

Terminal Python

Terminal

Copy Copied Failed

python -m pip install openai jsonschema

### Handle failures

- Validate the parsed object against your schema. Valid JSON is not necessarily a valid business object.
- Handle refusals, empty content, and length-limited replies separately. Do not interpret them as successful extraction.
- Use simple schemas first. Provider translations and supported keywords differ; a schema accepted by one model may not be accepted by another.
- For streaming, assemble the complete answer before parsing or validating JSON.

[Model capabilities](https://straitly.ai/models) [Tool calling](https://straitly.ai/docs/tool-calling) [Prompt caching](https://straitly.ai/docs/caching) [Production checklist](https://straitly.ai/docs/production) [Errors & limits](https://straitly.ai/docs/errors)

### Common questions

**How do I get strict JSON Schema output through Straitly?**

Pass response\_format with type: "json\_schema", a schema name, strict: true, and your JSON Schema object on /v1/chat/completions. Keep schemas simple, check finish\_reason and message.refusal, and validate the parsed JSON locally.

**What is the difference between JSON mode and JSON Schema output?**

JSON mode asks the model to return syntactically valid JSON without enforcing your exact keys or types. JSON Schema output requests a specific object structure on models that support schema constraints.

**Do all models support response\_format json\_schema?**

No. Structured output support and accepted JSON Schema keywords depend on the selected model and provider. Check capabilities on /models and test your exact schema on the target model before shipping to production.

[Tool calling](https://straitly.ai/docs/tool-calling) [Reasoning controls](https://straitly.ai/docs/reasoning)

---
Markdown version of https://straitly.ai/docs/structured-outputs.
