Skip to main content
response_format constrains the shape of the reply. warpllm forwards it and returns what the provider produces.

JSON mode

The loosest form: valid JSON, shape unconstrained.
Providers generally require the word “JSON” to appear somewhere in the messages when json_object is set, and reject the request otherwise. That rejection reaches you as a BadRequestError from the provider.

JSON Schema

The strict form: the reply conforms to a schema you supply.

The json_schema object

string
required
A name for the schema. Providers use it in their own error messages.
object
The JSON Schema itself.
boolean
Ask the provider to guarantee conformance rather than merely attempt it. Providers that support it usually also constrain what the schema may contain — commonly requiring additionalProperties: false and listing every property in required.
string
Optional guidance for the model about what the schema is for.

Always parse defensively

content is a string. Even with strict: true, treat parsing as fallible:
  • The model may hit max_tokens mid-object. Check finish_reason — a length finish means the JSON is cut off.
  • A refusal populates message.refusal and leaves content null.
  • Not every provider on the roster enforces strict the same way.

Provider support varies

response_format is forwarded, not emulated. A provider that does not implement json_schema rejects the request rather than degrading to plain text, and that rejection reaches you as a BadRequestError with the provider’s own message.
For a portable alternative, define the shape as a tool and force it with tool_choice. Function parameters are JSON Schema too, and tool support is more widely implemented than response_format.

Next

Tool calling

The portable route to a shaped answer.