MaaS_DB Response
请求url
请求Header
| 参数名 | 值 |
|---|---|
| Authorization | Bearer |
| Content-Type | multipart/form-data |
请求Body
请求参数
model string 必选
您需要调用的模型的 ID(Model ID)。
input string / array 必选
输入的内容,模型需要处理的输入信息。
instructions string / null
在模型上下文中插入系统消息或者开发者作为第一条指令。当与 previous_response_id 一起使用时,前一个回复中的指令不会被继承到下一个回复中。这样可以方便地在新的回复中替换系统(或开发者)消息。
不可与缓存能力一起使用。配置了 instructions 字段后,本轮请求无法写入缓存和使用缓存,表现为:
- caching 字段配置为
{"type":"enabled"}时报错。 - 传入带缓存的 previous_response_id 时,缓存输入(cached_tokens)为 0。
previous_response_id string / null
上一个模型回复的唯一标识符。使用该标识符可以实现多轮对话。
说明
- 在请求中传入
previous_response_id,会引入上一轮请求的输入和回答内容,本次请求的输入 tokens 会相应增加。 - 在多轮连续对话中,建议在每次请求之间加入约 100 毫秒的延迟,否则可能会导致调用失败。
expire_at integer 默认值:创建时刻+259200
取值范围:(创建时刻, 创建时刻+604800],即最多保留 7 天。
设置存储的过期时刻,需传入 UTC Unix 时间戳(单位:秒),对 store(上下文存储)和 caching(上下文缓存)都生效。
注意:缓存存储时间计费,
过期时刻 - 创建时刻,不满 1 小时按 1 小时计算。
max_output_tokens integer / null
模型输出最大 token 数,包含模型回答和思维链内容。
thinking object 默认值:取决于调用的模型
控制模型是否开启深度思考模式。默认开启深度思考模式,可以手动关闭。
属性
thinking.type string 必选
取值范围:enabled,disabled,auto。
enabled:开启思考模式,模型一定先思考后回答。disabled:关闭思考模式,模型直接回答问题,不会进行思考。auto:自动思考模式,模型根据问题自主判断是否需要思考,简单题目直接回答。
reasoning object
限制深度思考的工作量。减少深度思考工作量可使响应速度更快,并且深度思考的 token 用量更小。
属性
reasoning.effort string
取值范围:minimal,low,medium,high,xhigh(仅部分模型支持),max(仅部分模型支持)。
minimal:关闭思考,直接回答。low:轻量思考,侧重快速响应。medium:均衡模式,兼顾速度与深度。high:深度分析,处理复杂问题。xhigh:更高程度思考。该参数仅对指定模型生效,非适配模型传入将不生效。支持模型:glm-5-2-2606max:最高程度思考,适配高难度推理任务。该参数仅对指定模型生效,非适配模型传入将不生效。支持模型:glm-5-2-260617
include array
指定要在模型响应中返回的其他输出数据,当前支持的取值如下:
reasoning.encrypted_content:经加密及压缩处理后的思考内容原文,支持手动回传该字段,实现思考内容原文的多轮复用。
caching object 默认值 {"type": "disabled"}
是否开启缓存。
不可与 instructions 字段、tools(除自定义函数 Function Calling 外)字段一起使用。
属性
caching.type string 必选
取值范围:enabled,disabled。
enabled:开启缓存。disabled:关闭缓存。
caching.prefix boolean 默认值 false
true:仅创建公共前缀缓存,模型不回复。false:不创建公共前缀缓存。
store boolean / null 默认值 true
是否储存生成的模型响应,以便后续通过 API 检索。
- false:不储存,对话内容不能被后续的 API 检索到。
- true:储存当前模型响应,对话内容能被后续的 API 检索到。
stream boolean / null 默认值 false
响应内容是否流式返回。
false:模型生成完所有内容后一次性返回结果。true:按 SSE 协议逐块返回模型生成内容,并以一条data: [DONE]消息结束。
temperature float / null 默认值 1
取值范围:[0, 2]。
采样温度。控制了生成文本时对每个候选词的概率分布进行平滑的程度。当取值为 0 时模型仅考虑对数概率最大的一个 token。
较高的值(如 0.8)会使输出更加随机,而较低的值(如 0.2)会使输出更加集中确定。
通常建议仅调整 temperature 或 top_p 其中之一,不建议两者都修改。
注意
当调用下列模型,字段取值固定为 1,手动指定的参数值将被忽略:
doubao-seed-2-0-code-preview-260215doubao-seed-2-0-pro-260215doubao-seed-2-0-lite-260215
top_p float / null 默认值 0.7
取值范围:[0, 1]。
核采样概率阈值。模型会考虑概率质量在 top_p 内的 token 结果。当取值为 0 时模型仅考虑对数概率最大的一个 token。
0.1 意味着只考虑概率质量最高的前 10% 的 token,取值越大生成的随机性越高,取值越低生成的确定性越高。通常建议仅调整 temperature 或 top_p 其中之一,不建议两者都修改。
注意
当调用下列模型,字段取值固定为 0.95,手动指定的参数值将被忽略:
doubao-seed-2-0-code-preview-260215doubao-seed-2-0-pro-260215doubao-seed-2-0-lite-260215doubao-seed-1-8-251228
text object
模型文本输出的格式定义,可以是自然语言,也可以是结构化的 JSON 数据(请参见结构化输出)。
属性
text.format object 默认值 { "type": "text" }
指定模型文本输出的格式。
自然语言
响应格式为自然语言。
text.format.type string 必选
回复格式的类型,此处应为 text。
JSON Object
响应格式为 JSON 对象。
该能力尚在 beta 阶段,请谨慎在生产环境使用。
text.format.type string 必选
回复格式的类型,此处应为 json_object。
JSON Schema
响应格式为 JSON 对象,遵循 schema 字段定义的 JSON 结构。
该能力尚在 beta 阶段,请谨慎在生产环境使用。
text.format.type string 必选
回复格式的类型,此处应为 json_schema。
text.format.name string 必选
用户自定义的 JSON 结构的名称。
text.format.schema object 必选
回复格式的 JSON 格式定义,以 JSON Schema 对象的形式描述。
text.format.description string / null
回复用途描述,模型将根据此描述决定如何以该格式回复。
text.format.strict boolean / null 默认值 false
是否在生成输出时,启用严格遵循模式。
true:模型将始终遵循 schema 字段中定义的格式。false:模型将尽可能遵循 schema 字段中定义的结构。
tools array
模型可以调用的工具,当您需要让模型调用工具时,需要配置该结构体。
函数调用 (Function Calling)
tools.type string 必选
工具类型,此处应为 function。
tools.name string 必选
调用的函数的名称。
tools.description string
调用函数的描述,大模型会用它来判断是否调用这个函数。
tools.parameters object 必选
函数请求参数,以 JSON Schema 格式描述,格式如下:
```json { "type": "object", "properties": { "参数名": { "type": "string | number | boolean | object | array", "description": "参数说明" } }, "required": ["必填参数"] }
tool_choice string / object
仅 Doubao Seed 1.8 和 Doubao Seed 2.0 系列模型支持此字段。
本次请求,模型返回信息中是否有待调用的工具。
当没有指定工具时,none 是默认值。如果存在工具,则 auto 是默认值。
可选类型
工具选择模式 (string)
控制模型返回是否包含待调用的工具。
tool_choice string
none:模型返回信息中不可含有待调用的工具。required:模型返回信息中必须含待调用的工具。选择此项时请确认存在适合的工具,以减少模型产生幻觉的情况。auto:模型自行判断返回信息是否有待调用的工具。
工具调用 (object)
指定待调用工具的范围。模型返回信息中,只允许包含以下模型信息。选择此项时请确认该工具适合用户需求,以减少模型产生幻觉的情况。
tool_choice.type string 必选
调用的类型。
- 如果为自定义 Function,此处应为
function,此时 tool_choice.name 字段为必选。 - 如果为内置工具,此处填写工具名称,请参考 Responses API 内置工具。
tool_choice.name string
待调用工具的名称。
如果 tool_choice.type 为 function,此项为必选。
max_tool_calls integer
取值范围:[1, 10]。
最大工具调用轮次(一轮里不限制次数)。在工具调用达到此限制次数后,提示模型停止更多工具调用并进行回答。
注意:该参数为尽力而为(best effort)机制,不保证成功,最终调用次数会受模型推理效果、工具返回结果有效性等因素影响。
- Web Search 基础联网搜索工具的默认值为
3。 - Image Process 图像处理工具的默认值为
10,不支持修改。 - Knowledge Search 私域知识库搜索工具的默认值为
3。
context_management object
上下文管理策略,帮助模型有效利用上下文窗口。
属性
context_management.edits array
支持的上下文编辑策略,用于管理上下文中思考块和工具调用内容。
思考块清除
在开启思考时管理思维链内容。
context_management.edits.type string
上下文编辑策略类型,此处应为 clear_thinking。
context_management.edits.keep object/string
思维链保留策略。
保留最近 N 轮思维链
context_management.edits.keep.type string
思维链保留策略类型,此处应为 thinking_turns。
context_management.edits.keep.value integer 默认值 1
保留最近 N 轮的思维链。
保留所有思维链
context_management.edits.keep string
保留所有思维链,此处应为 all。
工具调用内容清除
在对话上下文增长超过配置的阈值时清除工具调用内容。
context_management.edits.type string
上下文编辑策略类型,此处应为 clear_tool_uses。
context_management.edits.keep object
工具调用内容保留策略。
属性
context_management.edits.keep.type string
工具调用内容保留策略类型,此处应为 tool_uses。
context_management.edits.keep.value integer 默认值 3
保留最近 N 轮工具调用内容。
context_management.edits.exclude_tools array
不会被清除的工具名称列表,用于保留重要上下文。
context_management.edits.clear_tool_input boolean 默认值 false
是否清除工具调用参数。
context_management.edits.trigger object
触发工具调用内容清除策略的阈值。
属性
context_management.edits.trigger.type string
触发工具调用内容清除策略类型,此处应为 tool_uses。
context_management.edits.trigger.value integer
工具调用达到 N 轮时触发清除策略。
请求示例
流式
curl --request POST \
--url https://genaiapi.cloudsway.net/v1/ai/{endpoint}/responses \
--header 'Authorization: Bearer ${your_ak}' \
--header 'Content-Type: application/json' \
--data '{
"model": "MaaS_DB_seed_2.0_pro_20260215",
"input": "Hello",
"stream": true
}
多轮对话
第一轮
curl --request POST \
--url https://genaiapi.cloudsway.net/v1/ai/{endpoint}/responses \
--header 'Authorization: Bearer ${your_ak}' \
--header 'Content-Type: application/json' \
--data '{
"model": "MaaS_DB_seed_2.0_pro_20260215",
"input": "Hi,talk a joke"
}
第二轮
curl --request POST \
--url https://genaiapi.cloudsway.net/v1/ai/{endpoint}/responses \
--header 'Authorization: Bearer ${your_ak}' \
--header 'Content-Type: application/json' \
--data '{
"model": "MaaS_DB_seed_2.0_pro_20260215",
"previous_response_id":"<resp_id>",
"input": "What is the punchline of this joke?"
}
tools_call
第一次
curl --request POST \
- --url https://genaiapi.cloudsway.net/v1/ai/{endpoint}/responses \
--header 'Authorization: Bearer ${your_ak}' \
--header 'Content-Type: application/json' \
--data '{
"model": "MaaS_DB_seed_2.0_pro_20260215",
"store": true,
"input": [
{
"type": "message",
"role": "user",
"content": "Check today's weather in Beijing."
}
],
"tools": [
{
"type": "function",
"name": "get_weather",
"description": "Look up the weather for a city on the current day (including temperature and weather conditions) based on the city name.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City name, such as Beijing or Shanghai (only domestic prefecture-level cities are supported)"
}
},
"required": ["location"]
}
}
]
}
第二次
curl --request POST \
--url https://genaiapi.cloudsway.net/v1/ai/{endpoint}/responses \
--header 'Authorization: Bearer ${your_ak}' \
--header 'Content-Type: application/json' \
--data '{
"model": "MaaS_DB_seed_2.0_pro_20260215",
"previous_response_id": "<resp_id>",
"input": [
{
"arguments": "{\"location\":\"beijing\"}",
"call_id": "<call_id>",
"name": "get_weather",
"type": "function_call"
},
{
"type": "function_call_output",
"call_id": "<call_id>",
"output": "{\"city\":\"beijing\",\"date\":\"2024-05-20\",\"temperature\":\"18~28℃\",\"condition\":\"晴转多云\",\"wind\":\"东北风2级\"}"
}
]
}
图片理解
url --request POST \
--url https://genaiapi.cloudsway.net/v1/ai/{endpoint}/responses \
--header 'Authorization: Bearer ${your_ak}' \
--header 'Content-Type: application/json' \
--data '{
"model": "MaaS_DB_seed_2.0_pro_20260215",
"input": [
{
"role": "user",
"content": [
{
"type": "input_image",
"image_url": "<demo_img.png>"
},
{
"type": "input_text",
"text": "waht do you see?"
}
]
}
]
}
视频理解
curl --request POST \
--url https://genaiapi.cloudsway.net/v1/ai/{endpoint}/responses \
--header 'Authorization: Bearer ${your_ak}' \
--header 'Content-Type: application/json' \
--data '{
"model": "MaaS_DB_seed_2.0_pro_20260215",
"input": [
{
"role": "user",
"content": [
{
"type": "input_video",
"video_url": "<demo_video_input.mp4>",
"fps":1
}
]
}
]
}
获取状态
curl --request GET \
--url https://genaiapi.cloudsway.net/v1/ai/{endpoint}/responses/{responsesId}\
--header 'Authorization: Bearer ${your_ak}' \
--header 'Content-Type: application/json' \
获取上下文对话
curl --request GET \
--url https://genaiapi.cloudsway.net/v1/ai/{endpoint}/responses/{responsesId}/input_items \
--header 'Authorization: Bearer ${your_ak}' \
--header 'Content-Type: application/json' \
删除对话
curl --request DELETE \
--url https://genaiapi.cloudsway.net/v1/ai/{endpoint}/responses/{responsesId}\
--header 'Authorization: Bearer ${your_ak}' \
--header 'Content-Type: application/json' \
响应示例
Response API 响应示例
{
"id": "resp_0217835831274756be565a09cf39c914f18dfcb4ec7b34f3423f1",
"model": "MaaS_DB_Seed_2.1_pro_20260628",
"output": [
{
"arguments": "{\"title\": \"The Gift of the Magi\"}",
"call_id": "call_2u438xkxjg9c2iocw4g2uk6u",
"name": "get_story_info",
"type": "function_call",
"id": "fc_02178358312856400000000000000000000ffffac156031561709",
"status": "completed"
}
],
"tools": [
{
"name": "get_story_info",
"type": "function",
"description": "Retrieve basic novel information",
"parameters": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "name"
}
},
"required": [
"title"
]
}
},
{
"name": "get_character_info",
"type": "function",
"description": "Retrieve basic novel information",
"parameters": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "name"
}
},
"required": [
"name"
]
}
}
],
"status": "completed",
"usage": {
"input_tokens": 495,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 37,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 532
},
"caching": {
"type": "enabled",
"prefix": null
},
"thinking": {
"type": "disabled"
},
"store": true,
"created_at": 1783583128,
"object": "response",
"tool_choice": "required",
"max_output_tokens": 32768,
"service_tier": "default",
"expire_at": 1783842327
}