You need to enable JavaScript to run this app.
AI 数据湖服务

AI 数据湖服务

复制全文
Responses API
创建模型响应
复制全文
创建模型响应

本文介绍 Responses API 创建模型请求时的输入输出参数,供您使用接口时查阅字段含义。

请求说明
  • Base URL:以华北 2 (北京)地域为例,Base URL为:https://operator.las.cn-beijing.volces.com,实际使用时,需使用您当前服务地域的Base URL,详情可参见调用方式
  • Path:/api/v1/responses
  • Method: POST
  • Content-type: application/json

请求参数

请求体参数说明如下。

参数
类型
必填
默认值
说明
model
string
您需要调用的模型的 ID (Model ID)。
input
string / array
输入的内容,模型需要处理的输入信息。支持以下类型:
  • 文本输入 (string):等同于使用 user 角色输入的文本信息。
  • 输入的元素列表 (array):包含不同类型的输入信息元素。
instructions
string
null
在模型上下文中插入系统消息或者开发者作为第一条指令。当与 previous_response_id 一起使用时,前一个回复中的指令不会被继承到下一个回复中。这样可以方便地在新的回复中替换系统(或开发者)消息。
不可与缓存能力一起使用。
previous_response_id
string
null
上一个模型回复的唯一标识符。使用该标识符可以实现多轮对话。工作原理可参见多轮对话场景
expire_at
integer
设置存储的过期时刻,需传入 UTC Unix 时间戳。默认保留 3 天,最多 7 天。
max_output_tokens
integer
null
模型输出最大 token 数,包含模型回答和思维链内容。
thinking
object
控制模型是否开启深度思考模式。
reasoning
object
{"effort": "medium"}
限制深度思考的工作量。
caching
object
{"type": "disabled"}
是否开启缓存。
store
boolean
true
是否储存生成的模型响应,以便后续通过 API 检索。
stream
boolean
false
响应内容是否流式返回。
temperature
float
1
采样温度,取值范围 [0, 2]。
top_p
float
0.7
核采样概率阈值,取值范围 [0, 1]。
text
object
模型文本输出的格式定义,可以是自然语言,也可以是结构化的 JSON 数据。详情请看结构化输出
tools
array
模型可以调用的工具列表。
tool_choice
string / object
auto
控制模型返回是否包含待调用的工具。
max_tool_calls
integer
最大工具调用轮次,取值范围 [1, 10]。
context_management
object
上下文管理策略。

响应参数

非流式调用返回

详情请参见The response object

流式调用返回

详情请参见流式响应

示例

单轮对话

  • request

    curl --location "https://operator.las.cn-beijing.volces.com/api/v1/responses" \
    --header "Authorization: Bearer $LAS_API_KEY" \
    --header "Content-Type: application/json" \
    --data '{
        "model": "doubao-seed-1-6-250615",
        "input": "你好呀。"
    }'
    
  • response

    {
      "id": "resp_0217****",
      "created_at": 1756280722.0,
      "error": null,
      "incomplete_details": null,
      "instructions": null,
      "model": "doubao-seed-1-6-250615",
      "object": "response",
      "output": [
        {
          "id": "rs_0217****404a",
          "summary": [
            {
              "text": "\n用户说“你好呀。”,这是一个很友好的问候,我需要用同样友好的方式回应。首先,应该回应用户的问候,然后可以表达一下愿意帮助的态度,让对话能够继续下去。用户可能接下来会有其他问题或者想聊聊天,所以回应要自然、亲切。\n\n首先,直接回“你好呀!”来呼应对方的问候,保持一致的语气。然后加上一句“很高兴见到你~ 有什么我可以帮你的吗?”这样既表达了友好,又主动提供帮助,让用户知道我在这里可以协助他们。这样的回应比较温暖,也符合日常交流的习惯,不会显得太生硬。\n\n需要注意的是,用户可能只是想打个招呼,所以回应不要太复杂,保持简洁和亲切就好。避免使用太正式的语言,保持口语化,让用户感觉舒适。总结一下,回应应该包含问候、表达高兴见到对方,以及提供帮助的意愿。",
              "type": "summary_text"
            }
          ],
          "type": "reasoning",
          "status": "completed"
        },
        {
          "id": "msg_0217****a93c",
          "content": [
            {
              "text": "你好呀!很高兴见到你~ 有什么我可以帮你的吗? 😊",
              "type": "output_text",
              "annotations": null
            }
          ],
          "role": "assistant",
          "status": "completed",
          "type": "message"
        }
      ],
      "parallel_tool_calls": null,
      "temperature": null,
      "tool_choice": null,
      "tools": null,
      "top_p": null,
      "max_output_tokens": 32768,
      "previous_response_id": null,
      "thinking": null,
      "service_tier": "default",
      "status": "completed",
      "text": null,
      "usage": {
        "input_tokens": 88,
        "input_tokens_details": {
          "cached_tokens": 0
        },
        "output_tokens": 230,
        "output_tokens_details": {
          "reasoning_tokens": 211
        },
        "total_tokens": 318
      },
      "caching": {
        "type": "disabled"
      },
      "store": true,
      "expire_at": 1756539922
    }
    

函数调用 Function Calling

  • request

    curl --location 'https://operator.las.cn-beijing.volces.com/api/v1/responses' \
    --header "Authorization: Bearer $LAS_API_KEY" \
    --header 'Content-Type: application/json' \
    --data '{
        "model": "doubao-seed-1-6-250615",
        "input": "查询北京今天的天气",
        "tools":[
            {
                "type": "function",
                "name": "获取天气信息",
                "description": "根据给出的位置获取天气信息",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "城市名称,例如:北京"
                        }
                    },
                    "required": [
                        "location"
                    ]
                }
            }
        ]
    }'
    
  • response

    {
      "id": "resp_0217****b63e",
      "created_at": 1756477803.0,
      "error": null,
      "incomplete_details": null,
      "instructions": null,
      "model": "doubao-seed-1-6-250615",
      "object": "response",
      "output": [
        {
          "id": "rs_0217****6b15",
          "summary": [
            {
              "text": "让我思考一下,我现在需要回答用户的问题:“北京的天气怎么样?”根据系统提示,我需要调用工具来获取天气信息。首先,我要确认用户的问题是否需要调用工具。用户询问的是当前北京的天气,这属于实时信息,无法通过常识直接回答,所以必须使用提供的工具。\n\n接下来,查看可用的工具列表,只有一个工具叫做“获取天气信息”,它的参数需要一个“location”,类型是字符串,必填项。用户的问题中明确提到了“北京”,所以location参数应该是“北京”。\n\n然后,我需要按照格式要求生成工具调用。系统提示说调用工具需要用包裹,里面是一个JSON数组。这里只需要调用一个工具,所以是单工具调用。参数部分应该是{\"location\": \"北京\"}。\n\n检查是否有其他需要注意的地方,比如参数是否正确,格式是否符合要求。确认无误后,生成调用语句。不需要并行调用,因为只有一个工具可用,且只需要一次调用就能获取所需信息。因此,最终的调用应该是:\n\n",
              "type": "summary_text"
            }
          ],
          "type": "reasoning",
          "status": "completed"
        },
        {
          "arguments": "{\"location\":\"北京\"}",
          "call_id": "call_****a6al",
          "name": "获取天气信息",
          "type": "function_call",
          "id": "fc_0217****c976b",
          "status": "completed"
        }
      ],
      "parallel_tool_calls": null,
      "temperature": null,
      "tool_choice": null,
      "tools": [
        {
          "name": "获取天气信息",
          "parameters": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "description": "城市名称,例如:北京"
              }
            },
            "required": ["location"]
          },
          "type": "function",
          "description": "根据给出的位置获取天气信息"
        }
      ],
      "top_p": null,
      "max_output_tokens": 32768,
      "previous_response_id": null,
      "thinking": null,
      "service_tier": "default",
      "status": "completed",
      "text": null,
      "usage": {
        "input_tokens": 454,
        "input_tokens_details": {
          "cached_tokens": 0
        },
        "output_tokens": 306,
        "output_tokens_details": {
          "reasoning_tokens": 279
        },
        "total_tokens": 760
      },
      "caching": {
        "type": "disabled"
      },
      "store": true,
      "expire_at": 1756737003
    }
    
最近更新时间:2026.03.10 12:03:40
这个页面对您有帮助吗?
有用
有用
无用
无用