最近更新时间:2025-11-28 13:24:53
您在需要模型进行结构化输出时,需要在请求时配置response_format参数,来指定模型输出JSON格式内容。设置参数后,需要在提示词或系统提示词中做出明确要求,以JSON格式进行输出。已支持的输出形式为json_object。
request
curl --location 'https://kspmas.ksyun.com/v1/chat/completions' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer $KSC_API_KEY' \
-d '{
"model": "deepseek-v3.2-exp",
"messages": [
{"role": "user", "content": "以JSON形式输出今天是星期几以及日期、月份、年份。"}
],
"response_format":{
"type": "json_object"
},
"web_search_options": {
"search_context_size": "low"
}
}'response
{
"id": "86699352cf3b4315a9578afbb9bcdc4e",
"object": "chat.completion",
"created": 1763981118,
"model": "deepseek-v3.2-exp",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "**References:**\n[1] [现代JavaScript_国际化API详解-js教程-PHP中文网](https://www.php.cn/faq/1767738.html)\n\n[2] [PHP中获取指定月份每周的开始和结束日期:使用Carbon库的专业指南-php教程-PHP中文网](https://www.php.cn/faq/1769113.html)\n\n[3] [日历纯净版下载-日历纯净版软件下载安卓版6.2.1-游侠软件下载](https://app.ali213.net/android/484545.html)\n\n[4] [铁东区 分钟降水预报,提前预知未来2小时是否下雨或下雪 | 和风天气](https://www.qweather.com/pcpn/tiedong-101060407.html)\n\n[5] [博野县 历史天气 历史空气质量AQI | 和风天气](https://www.qweather.com/historical/boye-101090225.html)\n\n{\n \"weekday\": \"星期一\",\n \"date\": \"2025-11-24\",\n \"year\": \"2025\",\n \"month\": \"11\"\n}",
"reasoning_content": null,
"tool_calls": null
},
"logprobs": null,
"finish_reason": "stop",
"matched_stop": 1
}
],
"usage": {
"prompt_tokens": 1631,
"total_tokens": 1670,
"completion_tokens": 39,
"prompt_tokens_details": null,
"reasoning_tokens": 0,
"web_search_queries": 1
},
"metadata": {
"weight_version": "default"
}
}
纯净模式
