shipfeedAI news, curated daily

00:32:21 CET
21 MAY00:32:21shipfeed
pull to refreshlast sync
Just in — 30 new
§ feed · storyline

JSON Output

DeepSeek releases a JSON Output feature for its API that enforces structured JSON responses via a response_format parameter, with noted requirements for prompt formatting and max_tokens configuration.

May 7 · · primary fetch1 sourceupdated May 7 ·

In many scenarios, users need models to output strictly in JSON format to achieve structured output, making it easier for subsequent logic to parse. DeepSeek provides a JSON Output feature to ensure the model outputs a valid JSON string. Notes Set the response_format parameter to {'type': 'json_object'}. The system or user prompt provided by the user must contain the word "json" and provide examples of the JSON format the model is expected to output to guide the model in generating valid JSON. Set the max_tokens parameter appropriately to prevent the JSON string from being truncated midway. When using the JSON Output feature, the API may occasionally return empty content.

We are actively optimizing this issue. You can try modifying your prompt to mitigate such problems. Sample Code Here is a complete Python code example using the JSON Output feature: import json from openai import OpenAI client = OpenAI( api_key="", base_url="https://api.deepseek.com", ) system_prompt = """ The user will provide some exam text. Please parse the "question" and "answer" and output them in JSON format. EXAMPLE INPUT: Which is the highest mountain in the world? Mount Everest. EXAMPLE JSON OUTPUT: {…

read full article on api-docs.deepseek.com
§ sources1 publication · timeline below
  1. api-docs.deepseek.comJSON Outputprimary