01 / Define the output contract

Specify fields, types, allowed values, and handling for unknown data. Explain whether extra fields are allowed and how the application handles invalid responses. Requesting JSON alone does not establish a complete contract.

02 / Make explanations optional

If your application only uses a category, it may not need a long explanation every time. Add a short evidence field when it helps the user. Preserve useful information rather than optimizing only for brevity.

Return only JSON, without Markdown.
Fields: category (string), tags (at most 3 strings).
If unknown, set category to "unknown".

03 / Set a limit and handle truncation

Set an output budget appropriate to the task and check why generation stopped. An overly small limit can truncate JSON, trigger retries, and increase costs. Supported settings vary across models.

04 / Validate in your application

Validate responses against a schema. Record success, format errors, and truncation separately. Confirm quality on representative examples before comparing token use and costs.

Sources and further reading

DS-V4-HUUB · DeepSeek JSON Output Guide ↗api-docs.deepseek.com · Official documentation ↗

Adapted from the source guide, last updated 2026-06-27. Savings depend on your workload and must be measured.