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.
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
Send a schema withoutreasoning_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
additionalPropertiesopen. Strict mode requiresadditionalProperties: false. The helpers set it, raw JSON Schema users must add it. - Nested
anyOfwithout discriminators. Use enums or discriminated unions. An unboundedanyOfconfuses a constrained decoder. - Expecting enums to be case-insensitive. Schema enums are exact match.
"Paris"does not satisfyenum: ["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.