结构化输出
DeepSeek 结构化输出可以通过 JSON 模式、清晰提示词、工具调用 schema 和服务端校验提升稳定性。
JSON 输出
json
{
"model": "deepseek-v4.5-chat",
"temperature": 0,
"messages": [
{
"role": "user",
"content": "Output JSON only. Extract the name and email from this text: Jane Doe, jane.doe@example.com"
}
],
"response_format": {
"type": "json_object"
}
}字段约束
text
Output JSON only:
{
"name": "string | null",
"email": "string | null",
"intent": "complaint | question | praise | other"
}
Do not add extra fields.服务端校验
- JSON parse 校验
- 必填字段校验
- 枚举值校验
- 金额、日期、手机号格式校验
- 解析失败时有限重试或人工复核