DeepSeek V4.1 Flash
本页由 ModelFold 文档站根据上游官方 OpenAPI 文档同步生成。接口路径、参数、示例与官方保持一致;品牌与 API 域名已替换为 ModelFold。
接口
POST /openai/v1/responses
完整 URL: https://ai.modelfold.online/openai/v1/responses
鉴权:所有请求都需要
Authorization: Bearer <API_KEY>请求头。
WARNING
⚠️ 仅支持对话调用
该模型目前仅支持对话调用,暂未适配 Agent 场景。若将其接入 Agent 使用,可能会出现请求报错或结果异常。
DeepSeek V4.1 Flash 是兼容 OpenAI Responses 协议的端点,接受纯文本字符串或结构化输入数组,默认开启深度思考,支持函数调用、图像理解与结构化 JSON 输出。
思考控制 — 默认开启深度思考,提供七档思考强度可调。
多模态输入 — 支持在单条消息中混合文本和图像输入。
工具与结构化输出 — 支持自定义函数调用,并可将回答约束为 JSON。
统一端点 — 使用统一的 /openai/v1/responses 端点, model 参数设置为 deepseek-v4-1-flash 。
思考
模型默认开启思考。关掉它可以让回答更快、更省 —— reasoning.effort 与 thinking.type 作用相同,二选一即可。
WARNING
本模型不支持 max_output_tokens、temperature 与 top_p,传入也不会生效。
关闭思考
下面两种写法等价:
{ "reasoning": { "effort": "none" } }{ "thinking": { "type": "disabled" } }thinking.type:enabled(默认)或 disabled。
思考强度
reasoning.effort 可取 none、minimal、low、medium、high、xhigh 与 max。
none 关闭思考(等同 thinking.type: "disabled");minimal 进行少量思考。再往上,档位越高思考越充分、消耗的 token 越多。
工具与输入
函数调用
声明模型可调用的函数,仅支持 function 类型:
{
"tools": [
{
"type": "function",
"name": "get_current_weather",
"description": "获取指定地点的当前天气",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "城市和州名,例如 San Francisco, CA"
}
},
"required": ["location"]
}
}
],
"tool_choice": "auto"
}传入 tools 后 tool_choice 默认为 auto。用 required 可强制调用工具,或用 {"type": "function", "name": "..."} 指定某一个函数。
回传执行结果
模型会返回一个 function_call。执行完函数后,把它和你的 function_call_output 一并追加到 input,两者通过 call_id 配对:
{
"input": [
{ "role": "user", "content": "北京今天天气怎么样?" },
{
"type": "function_call",
"call_id": "call_00_xxx",
"name": "get_current_weather",
"arguments": "{\"location\":\"北京\"}"
},
{
"type": "function_call_output",
"call_id": "call_00_xxx",
"output": "晴,25 度"
}
]
}图像理解
在同一条消息里混合 input_image 与 input_text 片段。image_url 可以是公网可访问的图片 URL,也可以是 data:image/{格式};base64,{编码}:
{
"input": [
{
"role": "user",
"content": [
{ "type": "input_image", "image_url": "https://example.com/demo.png" },
{ "type": "input_text", "text": "图里有什么?" }
]
}
]
}JSON 输出
设置 text.format 可将回答约束为 JSON:
{ "text": { "format": { "type": "json_object" } } }改用 json_schema 则可按你自定义的 schema 校验回答。
错误处理
请检查响应体,不要只看 HTTP 状态码。错误有两种形态:{"code": ..., "msg": "..."}(如 401 API key 无效、402 积分不足、429 频率超限;HTTP 状态可能仍为 200),或 {"error": {"type": "...", "message": "..."}}。
请求参数
请求体 (application/json)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 目标模型名称。可选值:deepseek-v4-1-flash。 可选值:deepseek-v4-1-flash。 示例:deepseek-v4-1-flash。 |
input | `string | array<object | object |
instructions | string | 否 | 给模型的系统指令,作为 system 消息插入在 input 之前。 |
stream | boolean | 否 | 当为真时,响应会以服务器发送事件的形式实时流式传输。当为假时,完成之后会一次性返回完整的响应。默认值为真。 默认值:true。 示例:true。 |
reasoning | object | 否 | 模型推理配置。 |
reasoning.effort | string | 否 | 推理力度级别。更高的取值会带来更充分的推理,但可能增加延迟。none 关闭思考(等同 thinking.type: "disabled");minimal 进行少量思考。默认开启推理。 可选值:none / minimal / low / medium / high / xhigh / max。 示例:none。 |
thinking | object | 否 | 思考配置。与 reasoning.effort 二选一,请勿同时配置。 |
thinking.type | string | 否 | 思考行为:enabled(默认)或 disabled。 默认值:"enabled"。 可选值:enabled / disabled。 示例:enabled。 |
tools | array<object> | 否 | 可选,模型可以调用的工具数组。仅支持 function 类型。 |
tools[].type | string | 是 | 工具类型。固定为 function。 可选值:function。 示例:function。 |
tools[].name | string | 是 | 函数名称。模型发起调用时会原样返回。 |
tools[].description | string | 否 | 函数的用途说明。帮助模型判断何时调用该函数。 |
tools[].parameters | object | 是 | 函数参数定义,JSON Schema 对象形式。 |
tool_choice | `string | object` | 否 |
text | object | 否 | 输出格式配置。 |
text.format | object | 是 | 回答需要遵循的格式。 |
text.format.type | string | 是 | 格式类型。text 返回纯文本,json_object 将回答约束为 JSON,json_schema 则按你自定义的 schema 校验回答。 可选值:text / json_object / json_schema。 示例:text。 |
text.format.name | string | 否 | schema 名称。type 为 json_schema 时必填。 |
text.format.description | string | 否 | schema 的可选说明,帮助模型产出预期的输出。 |
text.format.schema | object | 否 | 回答需要遵循的 JSON Schema。type 为 json_schema 时必填。 |
text.format.strict | boolean | 否 | 是否严格按 schema 校验回答。仅在 json_schema 下生效。 |
请求示例
curl -X POST "https://ai.modelfold.online/openai/v1/responses" \
-H "Authorization: Bearer $MODELFOLD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-1-flash",
"stream": false,
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "图里有什么?"
},
{
"type": "input_image",
"image_url": "https://example.com/demo.png"
}
]
}
]
}'{
"model": "deepseek-v4-1-flash",
"stream": false,
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "图里有什么?"
},
{
"type": "input_image",
"image_url": "https://example.com/demo.png"
}
]
}
]
}响应
200 — 请求成功。
"{\n \"id\": \"resp_xxx\",\n \"object\": \"response\",\n \"created_at\": 1790128600,\n \"model\": \"deepseek-v4-1-flash\",\n \"status\": \"completed\",\n \"output\": [\n {\n \"type\": \"reasoning\",\n \"id\": \"rs_xxx\",\n \"status\": \"completed\",\n \"summary\": [\n {\n \"type\": \"summary_text\",\n \"text\": \"用户在问图里有什么。图中是一只坐在窗台上的猫。\"\n }\n ]\n },\n {\n \"type\": \"message\",\n \"id\": \"msg_xxx\",\n \"role\": \"assistant\",\n \"status\": \"completed\",\n \"content\": [\n {\n \"type\": \"output_text\",\n \"text\": \"图中是一只坐在窗台上的猫。\",\n \"annotations\": []\n }\n ]\n }\n ],\n \"usage\": {\n \"input_tokens\": 38,\n \"input_tokens_details\": {\n \"cached_tokens\": 0\n },\n \"output_tokens\": 36,\n \"output_tokens_details\": {\n \"reasoning_tokens\": 35\n },\n \"total_tokens\": 74\n },\n \"credits_consumed\": 0.01\n}"400 — 错误请求 - 无效的请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | 否 | — |
error.message | string | 否 | 示例:无效的请求参数。 |
error.type | string | 否 | 示例:invalid_request_error。 |
error.param | string | 否 | — |
error.code | string | 否 | — |
{
"error": {
"message": "无效的请求参数",
"type": "invalid_request_error",
"param": "",
"code": ""
}
}401 — 未授权 - 无效或缺少 API key
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | 否 | — |
error.message | string | 否 | 示例:无效或缺少 API key。 |
error.type | string | 否 | 示例:authentication_error。 |
error.param | string | 否 | — |
error.code | string | 否 | — |
{
"error": {
"message": "无效或缺少 API key",
"type": "authentication_error",
"param": "",
"code": ""
}
}429 — 速率限制 - 请求过多
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | 否 | — |
error.message | string | 否 | 示例:请求过多。 |
error.type | string | 否 | 示例:rate_limit_error。 |
error.param | string | 否 | — |
error.code | string | 否 | — |
{
"error": {
"message": "请求过多",
"type": "rate_limit_error",
"param": "",
"code": ""
}
}