Skip to main content
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.

Minimal code

The one thing to know before you run it: deepseek-v4-flash cannot hold a format while it is reasoning, so a schema on that model travels with reasoning_effort: "none" in the same request. That is why every snippet below carries the field.
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

What each live model doesGET /v1/models is the live listModelStreamingTool callingJSON modeReasoning offdeepseek-v4-flashyesyesconditionalyesdeepseek-v4-proyesyesyesalready offqwen3-8-27byesyesyesyesqwen3-8-2-4t-a95byesyesyesnonemotron-3-5-lightning-30byesyesconditionalyesornith-1-5-35byesyesyesyesconditional means the model cannot hold a response format while it reasons: send reasoning_effort “none”in the same request as response_format. A feature a model does not offer is refused with 400, never ignored.
What each live model doesGET /v1/models is the live listModelStreamingTool callingJSON modeReasoning offdeepseek-v4-flashyesyesconditionalyesdeepseek-v4-proyesyesyesalready offqwen3-8-27byesyesyesyesqwen3-8-2-4t-a95byesyesyesnonemotron-3-5-lightning-30byesyesconditionalyesornith-1-5-35byesyesyesyesconditional means the model cannot hold a response format while it reasons: send reasoning_effort “none”in the same request as response_format. A feature a model does not offer is refused with 400, never ignored.
Send a schema without reasoning_effort: "none" on one of the two conditional models and the request is refused with 400, param: "response_format". The refusal is deliberate: the alternative is a 200 carrying a reply your parser rejects, billed in full.
"none" is a wire value. If your installed SDK’s type definitions predate it, widen the literal at the call site. The request that goes out is unchanged.

What to tune

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 additionalProperties open. Strict mode requires additionalProperties: false. The helpers set it, raw JSON Schema users must add it.
  • Nested anyOf without discriminators. Use enums or discriminated unions. An unbounded anyOf confuses a constrained decoder.
  • Expecting enums to be case-insensitive. Schema enums are exact match. "Paris" does not satisfy enum: ["paris", "berlin"].

Next steps

Tool calling

Structured arguments, then an action.

Streaming

Stream JSON that parses as it arrives.

Chat completions

The full response_format contract.