Overview
By default, a text generation model responds to your requests with a text in natural language. You can also force the model to respond with JSON instead, which makes it easier to work with outputs programmatically in your application. For example, you can tell a model the name of an actor or actress and get a response with details of a film they have starred in, in a format like this:response_formatparameter to get JSON output. Depending on the settings in your request, the response can be:
- JSON schema following. Follows the specific schema you provide -
{"type": "json_schema"}inresponse_formatparameter. - Arbitrary JSON object. Forces arbitrary JSON output, the model will decide on the schema by itself
{"type": "json_object"}inresponse_formatparameter.
Supported models
Some models are better in providing JSON due to their training data or our inference engine limitations. Use
Some models are better in providing JSON due to their training data or our inference engine limitations. Use
JSON mode tag in on a model card to find a model with structured output supported.1
Choose response format type
Select between strict
"json_schema" and arbitrary "json_object"2
Optionally: provide JSON schema
Provide the schema in a JSON Schema Specification compliant format.
3
Add instructions to the system or user prompt
It’s always better to provide the instruction to follow JSON output and the schema to your model’s system or user prompt to increase output quality and consistency
4
Test several models
Different models has different structured output capabilities. Always test and compare a few to obtain the best result
JSON Schema following
JSON that follows a schema provided in your request. Make a request to the Nebius Token Factory API with{"type": "json_schema"} in response_format and provide desirable schema in a JSON Schema Specification compliant format.
Arbitrary JSON object
The model will produce a valid JSON object without following any specific schema.Make a request to the Nebius Token Factory API with
{"type": "json_object"} in response_format:
Try it in our Cookbook
Strucrured output - Cookbook
Structured output in Playground
You can explore the structured output capabilities of models directly in the Playground:- Go to the “Model Parameters” section.
In the "Response format" dropdown, select JSON object/schema.- (Optional) Provide a strict JSON schema if you want the model to follow a specific structure.
- Enter your prompt and run it to test whether the model returns the expected JSON output for your use case.