Learn how to use JSON mode to get structured outputs from LLMs like DeepSeek V3 & Llama 3.3.
response_format
key of the Chat Completions API.
moonshotai/Kimi-K2-Instruct
meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo
meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo
meta-llama/Llama-3.2-3B-Instruct-Turbo
meta-llama/Llama-3.3-70B-Instruct-Turbo
meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8
meta-llama/Llama-4-Scout-17B-16E-Instruct
deepseek-ai/DeepSeek-V3
deepseek-ai/DeepSeek-R1
Qwen/Qwen3-235B-A22B-fp8-tput
Qwen/Qwen2.5-VL-72B-Instruct
arcee_ai/arcee-spotlight
arcee-ai/arcee-blitz
response_format
key.
Finally – and this is important – we need to make sure to instruct our model to only respond in JSON format, and include details of the schema we want to use. This ensures it will actually use the schema we provide when generating its response. Any instructions in the schema itself will not be followed by the LLM.
Important: You must always instruct your model to only respond in JSON format, either in the system prompt or a user message, in addition to passing your schema to the response_format
key.
Let’s see what this looks like:
DeepSeek-R1-0528
.
Below we ask the model to solve a math problem step-by-step showing it’s work: