面向 AI 助手:本页的 Markdown 版本位于 https://ark.volcengine.com/region:cn-beijing/docs/deep-thinking.md,全部文档索引见 https://ark.volcengine.com/llms.txt。

深度思考

深度思考指模型在回答前,对问题进行分析及多步骤规划,再尝试解决问题。擅长处理编程、科学推理、智能体工作流等复杂及抽象场景。启用深度思考后,会在指定字段返回思维链内容,可基此观察和使用模型推导内容。

快速开始#

输入 思维链 回答
Plain
我要研究深度思考模型与非深度思考模型区别的课题,怎么体现我的专业性
Plain
用户现在要做深度思考模型和非深度思考模型区别的课题,需要体现专业性。首先得明确,专业性体现在哪里?
...
要在“深度思考模型与非深度思考模型区别”的课题中体现专业性,核心在于**严谨的概念界定、系统的对比框架、科学的方法论支撑、以及深度的理论与实践结合**。以下是具体的实施路径,从研究框架到细节落地,帮你构建专业的研究体系:
Plain
### **一、第一步:明确概念边界——避免泛化,精准定义**
专业性的起点是**清晰的概念界定**,避免将“深度模型”等同于“深度思考模型”,也避免将“非深度模型”简化为“传统模型”。需基于学术共识和研究目标给出操作性定义:
...
通过以上路径,你的课题将从“表面对比”升级为“本质穿透”,充分体现专业性与研究深度。祝你研究顺利!

Bash
curl https://ark.cn-beijing.volces.com/api/v3/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -d '{
    "model": "doubao-seed-2-1-pro-260915",
    "messages": [
        {
            "role": "user",
            "content": "我要研究深度思考模型与非深度思考模型区别的课题,怎么体现我的专业性"
        }
    ]
  }'
  • 您可按需替换 Model ID。Model ID 查询见 模型列表。
Python
import os
# Install SDK: python -m pip install --upgrade arkruntime
from arkruntime import Ark

client = Ark(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key: https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv('ARK_API_KEY'),
    # Deep thinking takes longer; set a larger timeout, with 1,800 seconds or more recommended
    timeout=1800,
)

completion = client.chat.completions.create(
    # Replace with Model ID
    model = "doubao-seed-2-1-pro-260915",
    messages=[
        {"role": "user", "content": "我要研究深度思考模型与非深度思考模型区别的课题,怎么体现我的专业性"}
    ]
)
# When deep thinking is triggered, print the chain-of-thought content
if hasattr(completion.choices[0].message, 'reasoning_content'):
    print(completion.choices[0].message.reasoning_content)
print(completion.choices[0].message.content)
Go
package main

import (
    "context"
    "fmt"
    "os"
    "time"
    "github.com/volcengine/ark-runtime-go/arkruntime"
    "github.com/volcengine/ark-runtime-go/arkruntime/model/chat"
)

func main() {
    client := arkruntime.NewClientWithApiKey(
        // Get API Key: https://ark.volcengine.com/region:cn-beijing/apikey
        os.Getenv("ARK_API_KEY"),
        // The base URL for model invocation
        arkruntime.WithBaseUrl("https://ark.cn-beijing.volces.com/api/v3"),
        // Deep thinking takes longer; set a larger timeout, with 1,800 seconds or more recommended
        arkruntime.WithTimeout(30*time.Minute),
    )
    ctx := context.Background()
    req := &chat.ChatCompletionRequest{
        // Replace with Model ID
       Model: "doubao-seed-2-1-pro-260915",
        Messages: []chat.ChatCompletionRequestMessage{
userMessage("我要研究深度思考模型与非深度思考模型区别的课题,怎么体现我的专业性"),
        },
    }

    resp, err := client.CreateChatCompletion(ctx, req)
    if err != nil {
        fmt.Printf("standard chat error: %v\n", err)
        return
    }
    // When deep thinking is triggered, print the chain-of-thought content
    if resp.Choices[0].Message.ReasoningContent.IsSet() {
        fmt.Println(resp.Choices[0].Message.ReasoningContent.Or(""))
    }
    fmt.Println(resp.Choices[0].Message.Content)
}

func userMessage(content string) chat.ChatCompletionRequestMessage {
    return chat.ChatCompletionRequestMessage{
        OneOf: chat.NewChatCompletionRequestUserMessageChatCompletionRequestMessageSum(
            chat.ChatCompletionRequestUserMessage{
                Role: chat.ChatCompletionRequestUserMessageRoleUser,
                Content: chat.NewOptNilChatCompletionMessageContent(chat.NewStringChatCompletionMessageContent(content)),
            },
        ),
    }
}
Java
package com.ark.sample;

import com.volcengine.ark.runtime.models.chat.*;
import com.volcengine.ark.runtime.service.ArkService;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.time.Duration;

public class ChatCompletionsExample {
    public static void main(String[] args) {
        // Get API Key: https://ark.volcengine.com/region:cn-beijing/apikey
        String apiKey = System.getenv("ARK_API_KEY");
        ArkService arkService = ArkService.builder()
                .apiKey(apiKey)
                .timeout(Duration.ofMinutes(30))// Deep thinking takes longer; set a larger timeout, with 1,800 seconds or more recommended
                .baseUrl("https://ark.cn-beijing.volces.com/api/v3")
                // The base URL for model invocation
                .build();
        List<ChatCompletionRequestMessage> chatMessages = new ArrayList<>();
        ChatCompletionRequestMessage userMessage = ChatCompletionRequestUserMessage.builder()
                .role(ChatCompletionRequestMessageType.USER)
                .content(ChatCompletionMessageContent.ofString("我要研究深度思考模型与非深度思考模型区别的课题,怎么体现我的专业性"))
                .build();
        chatMessages.add(userMessage);
        ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest.builder()
                .model("doubao-seed-2-1-pro-260915")//Replace with Model ID
                .messages(chatMessages)
                .build();
        try {
            arkService.createChatCompletion(chatCompletionRequest)
                    .getChoices()
                    .forEach(choice -> {
                        if (choice.getMessage().getReasoningContent() != null) {
                            System.out.println(choice.getMessage().getReasoningContent());
                        }
                        System.out.println(choice.getMessage().getContent());
                    });
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            // Shut down the service executor
            arkService.shutdownExecutor();
        }
    }
}
Python
import os
from openai import OpenAI

client = OpenAI(
    # Get API Key: https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.environ.get("ARK_API_KEY"),
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Deep thinking takes longer; set a larger timeout, with 1,800 seconds or more recommended
    timeout=1800,
    )
completion = client.chat.completions.create(
    # Replace with Model ID
    model = "doubao-seed-2-1-pro-260915",
    messages=[
        {"role": "user", "content": "我要研究深度思考模型与非深度思考模型区别的课题,怎么体现我的专业性"}
    ]
)
# When deep thinking is triggered, print the chain-of-thought content
if hasattr(completion.choices[0].message, 'reasoning_content'):
    print(completion.choices[0].message.reasoning_content)
print(completion.choices[0].message.content)

模型及 API#

支持的模型:文本生成能力 中能力标签含"深度思考"的模型。
支持的 API:

  • Responses API:新推出的 API,简洁上下文管理,增强工具调用能力,缓存能力降低成本,新业务及用户推荐。

  • Chat API:使用广泛的 API,存量业务迁移成本低。

基础使用#

多轮对话#

组合使用系统消息、模型消息以及用户消息,可以实现多轮对话。当需要持续在一个主题内对话,可以将历史轮次的对话记录输入给模型。

传入方式 手动管理上下文 通过 ID 管理上下文
使用示例
JSON
...
    "model": "doubao-seed-2-1-pro-260915",
    "messages":[
        {"role": "user", "content": "Hi, tell a joke."},
        {"role": "assistant", "content": "Why did the math book look sad? Because it had too many problems! 😄"},
        {"role": "user", "content": "What's the punchline of this joke?"}
    ]
...
JSON
...
    "model": "doubao-seed-2-1-pro-260915",
    "previous_response_id":"<id>",
    "input": "What is the punchline of this joke?"
...
API Chat API Responses API

在构建多轮对话的上下文时:保留历史对话的 reasoning_content 字段,由模型自行判断是否将该字段加入到推理输入中。

更多说明及完整示例请参见上下文管理。

流式输出#

随着大模型输出,动态输出内容,无需等待模型推理完毕,即可看到中间输出过程内容。

预览 优势
  • 改善等待体验:无需等待完整内容生成完毕,可立即处理过程内容。
  • 实时过程反馈:多轮交互场景,实时了解任务当前的处理阶段。
  • 更高的容错性:中途出错,也能获取到已生成内容,避免非流式输出失败无返回的情况。
  • 简化超时管理:保持客户端与服务端的连接状态,避免复杂任务耗时过长而连接超时。

通过配置 stream 为 true,来启用流式输出。

JSON
    "model": "doubao-seed-2-1-pro-260915",
    "messages": [
        {"role": "user", "content": "深度思考模型与非深度思考模型区别"}
    ],
    "stream": true

完整示例及更多说明请参见流式输出。

开启/关闭深度思考#

提供 thinking 字段控制是否关闭深度思考能力,实现“复杂任务深度推理,简单任务高效响应”的精细控制,获得成本、效率收益。

  • 取值说明:

    • enabled:强制开启,强制开启深度思考能力。

    • disabled:强制关闭深度思考能力。

    • auto:模型自行判断是否进行深度思考。

  • 示例代码:

Bash
curl https://ark.cn-beijing.volces.com/api/v3/chat/completions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $ARK_API_KEY" \
      -d '{
        "model": "doubao-seed-2-1-pro-260915",
         "messages": [
             {
                 "role": "user",
                 "content": [
                     {
                         "type":"text",
                         "text":"我要研究深度思考模型与非深度思考模型区别的课题,体现出我的专业性"
                     }
                 ]
             }
         ],
         "thinking":{
             "type":"disabled"
         }
    }'
  • model:请变更为实际调用的模型。

  • thinking.type:字段可以取值范围。

    • disabled:强制关闭深度思考能力,模型不输出思维链内容。

    • enabled:强制开启深度思考能力,模型强制输出思维链内容。

    • auto:模型自行判断是否需要进行深度思考。

Python
import os
# Install SDK: python -m pip install --upgrade arkruntime
from arkruntime import Ark

client = Ark(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key: https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv('ARK_API_KEY'),
    # Deep thinking takes longer; set a larger timeout, with 1,800 seconds or more recommended
    timeout=1800,
)

# 创建一个对话请求
completion = client.chat.completions.create(
    # Replace with Model ID
    model="doubao-seed-2-1-pro-260915",
    messages=[
        {"role": "user", "content": "我要研究深度思考模型与非深度思考模型区别的课题,体现出我的专业性"}
    ],
    thinking={
        "type": "disabled", # 不使用深度思考能力
        # "type": "enabled", # 使用深度思考能力
        # "type": "auto", # 模型自行判断是否使用深度思考能力
    },
)

print(completion)
Go
package main

    import (
        "context"
        "fmt"
        "os"
        "time"
        "github.com/volcengine/ark-runtime-go/arkruntime"
        "github.com/volcengine/ark-runtime-go/arkruntime/model/chat"
    )

    func main() {
        client := arkruntime.NewClientWithApiKey(
            // Get API Key: https://ark.volcengine.com/region:cn-beijing/apikey
            os.Getenv("ARK_API_KEY"),
            // The base URL for model invocation
            arkruntime.WithBaseUrl("https://ark.cn-beijing.volces.com/api/v3"),
            //深度思考耗时更长,请设置更大的超时限制,推荐为30分钟及以上
            arkruntime.WithTimeout(30*time.Minute),
        )
        // 创建一个上下文,通常用于传递请求的上下文信息,如超时、取消等
        ctx := context.Background()
        // 构建聊天完成请求,设置请求的模型和消息内容
        req := &chat.ChatCompletionRequest{
            // Replace with Model ID
           Model: "doubao-seed-2-1-pro-260915",
           Messages: []chat.ChatCompletionRequestMessage{
userMessage("我要研究深度思考模型与非深度思考模型区别的课题,怎么体现我的专业性"),
            },
            Thinking: chat.NewOptThinking(chat.Thinking{Type: chat.NewOptThinkingMode(chat.ThinkingModeDisabled)}),
        }


        // 发送聊天完成请求,并将结果存储在 resp 中,将可能出现的错误存储在 err 中
        resp, err := client.CreateChatCompletion(ctx, req)
        if err != nil {
            // 若出现错误,打印错误信息并终止程序
            fmt.Printf("standard chat error: %v
", err)
            return
        }
        // 检查是否触发深度思考,触发则打印思维链内容
        if resp.Choices[0].Message.ReasoningContent.IsSet() {
            fmt.Println(resp.Choices[0].Message.ReasoningContent.Or(""))
        }
        // 打印聊天完成请求的响应结果
        fmt.Println(resp.Choices[0].Message.Content)
    }

func userMessage(content string) chat.ChatCompletionRequestMessage {
    return chat.ChatCompletionRequestMessage{
        OneOf: chat.NewChatCompletionRequestUserMessageChatCompletionRequestMessageSum(
            chat.ChatCompletionRequestUserMessage{
                Role: chat.ChatCompletionRequestUserMessageRoleUser,
                Content: chat.NewOptNilChatCompletionMessageContent(chat.NewStringChatCompletionMessageContent(content)),
            },
        ),
    }
}
Java
package com.ark.sample;

import com.volcengine.ark.runtime.models.chat.*;
import com.volcengine.ark.runtime.service.ArkService;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;

/**
 * 这是一个示例类,展示了如何使用ArkService来完成聊天功能。
 */
public class ChatCompletionsExample {
    public static void main(String[] args) {
        // 从环境变量中获取API密钥
        String apiKey = System.getenv("ARK_API_KEY");
        // 创建ArkService实例
        ArkService arkService = ArkService.builder()
                .apiKey(apiKey)
                .timeout(Duration.ofMinutes(30))// 深度思考耗时更长,请设置更大的超时限制,推荐为30分钟及以上
                // The base URL for model invocation
                .baseUrl("https://ark.cn-beijing.volces.com/api/v3")
                .build();
        // 初始化消息列表
        List<ChatCompletionRequestMessage> chatMessages = new ArrayList<>();
        // 创建用户消息
        ChatCompletionRequestMessage userMessage = ChatCompletionRequestUserMessage.builder()
                .role(ChatCompletionRequestMessageType.USER) // 设置消息角色为用户
                .content(ChatCompletionMessageContent.ofString("我要研究深度思考模型与非深度思考模型区别的课题,怎么体现我的专业性")) // 设置消息内容
                .build();
        // 将用户消息添加到消息列表
        chatMessages.add(userMessage);
        ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest.builder()
                .model("doubao-seed-2-1-pro-260915")//Replace with Model ID
                .messages(chatMessages) // 设置消息列表
                .thinking(Thinking.builder().type(ThinkingMode.DISABLED).build())
                .build();
        // 发送聊天完成请求并打印响应
        try {
            // 获取响应并打印每个选择的消息内容
            arkService.createChatCompletion(chatCompletionRequest)
                    .getChoices()
                    .forEach(choice -> {
                        // 校验是否触发了深度思考,打印思维链内容
                        if (choice.getMessage().getReasoningContent() != null) {
                            System.out.println("推理内容: " + choice.getMessage().getReasoningContent());
                        } else {
                            System.out.println("推理内容为空");
                        }
                        // 打印消息内容
                        System.out.println("消息内容: " + choice.getMessage().getContent());
                    });
        } catch (Exception e) {
            System.out.println("请求失败: " + e.getMessage());
        } finally {
            // 关闭服务执行器
            arkService.shutdownExecutor();
        }
    }
}
Python
import os
from openai import OpenAI

client = OpenAI(
    # 从环境变量中读取方舟API Key
    api_key=os.environ.get("ARK_API_KEY"),
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # 深度思考耗时更长,避免连接超时导致失败,请设置更大的超时限制,推荐为1800 秒及以上
    timeout=1800,
    )
completion = client.chat.completions.create(
    # Replace with Model ID
    model = "doubao-seed-2-1-pro-260915",
    messages=[
        {
            "role": "user",
            "content": "我要研究深度思考模型与非深度思考模型区别的课题,体现出我的专业性",
        }
    ],
    extra_body={
        "thinking": {
            "type": "disabled",  # 不使用深度思考能力
            # "type": "enabled", # 使用深度思考能力
                # "type": "auto", # 模型自行判断是否使用深度思考能力
        }
    },
)


print(completion)
  • 支持模型:

    • doubao-seed-evolving:支持 enabled(默认)、disabled。
    • doubao-seed-2-1-pro-260915:支持 enabled(默认)、disabled。
    • doubao-seed-2-1-lite-260915:支持 enabled(默认)、disabled。
    • doubao-seed-2-1-pro-260628:支持 enabled(默认)、disabled。
    • doubao-seed-2-1-turbo-260628:支持 enabled(默认)、disabled。
    • doubao-seed-2-0-lite-260428:支持 enabled(默认)、disabled。
    • doubao-seed-2-0-mini-260428:支持 enabled(默认)、disabled。
    • doubao-seed-2-0-pro-260215:支持 enabled(默认)、disabled。
    • doubao-seed-2-0-lite-260215:支持 enabled(默认)、disabled。
    • doubao-seed-2-0-mini-260215:支持 enabled(默认)、disabled。
    • doubao-seed-2-0-code-preview-260215:支持 enabled(默认)、disabled。
    • glm-5-3-flash-260828:支持 enabled(默认)。(始终启用思考,不再支持禁用思考。)
    • glm-5-2-260617:支持 enabled(默认)、disabled。
    • doubao-seed-character-260628:支持 enabled(默认)、disabled。
    • deepseek-v4-1-flash-260910:支持 enabled(默认)、disabled。
    • deepseek-v4-pro-ga-260813:支持 enabled(默认)、disabled。
    • deepseek-v4-flash-ga-260731:支持 enabled(默认)、disabled。
    • deepseek-v4-pro-260425:支持 enabled(默认)、disabled。
  • 更多说明

设置最大输出长度#

模型输出内容由思维链(Chain of Thought, COT) 和最终回答(Answer) 两部分组成。合理控制模型输出长度,平衡效果、速度、成本与稳定性。

传入方式 手动管理上下文 通过 ID 管理上下文
API Chat API Responses API
示例
JSON
...
    "model": "doubao-seed-2-1-pro-260915",
    "messages": [
        {"role": "user", "content": "Hi, tell a joke."}
    ],
    "max_completion_tokens": 300
...
JSON
...
    "model": "doubao-seed-2-1-pro-260915",
    "previous_response_id":"<id>",
     "input": "Hi, tell a joke.",
     "max_output_tokens": 300
...

完整示例及更多说明请参见控制输出(回答+思维链)长度。

调节思考长度#

提供字段 reasoning_effort(Chat API)、reasoning.effort(Responses API)调节思维链长度,平衡不同场景对效果、时延、成本的需求。取值如下:

  • none:关闭思考。
  • minimal:关闭思考,直接回答。
  • low:轻量思考,侧重快速响应。
  • medium:均衡模式,兼顾速度与深度。
  • high:深度分析,处理复杂问题。
  • xhigh:更高强度思考。
  • max:最高强度思考,适配高难度推理任务。

下表展示支持调节思考长度的模型,以及各模型对 reasoning_effort(Chat API)、reasoning.effort(Responses API)的默认取值与兼容映射规则。所有支持该字段的模型均接受全部 7 档取值,部分取值将按表中规则自动映射至等效档位。

支持模型 默认取值 兼容映射
  • doubao-seed-evolving
  • doubao-seed-2-1-pro-260915
  • doubao-seed-2-1-lite-260915
  • doubao-seed-2-1-pro-260628
  • doubao-seed-2-1-turbo-260628
high
  • 传入 minimal:将关闭思考
  • 传入 none:将映射为 minimal
  • 传入 none:将映射为 minimal
  • 传入 xhigh / max:将映射为 high
  • doubao-seed-2-0-lite-260428
  • doubao-seed-2-0-mini-260428
  • doubao-seed-2-0-pro-260215
  • doubao-seed-2-0-lite-260215
  • doubao-seed-2-0-mini-260215
  • doubao-seed-2-0-code-preview-260215
  • doubao-seed-character-260628
medium
  • 传入 minimal:将关闭思考
  • 传入 none:将映射为 minimal
  • 传入 xhigh / max:将映射为 high
glm-5-3-flash-260828 max
  • 传入 none / minimal / low:将映射为 low
  • 传入 medium / high:将映射为 high
  • 传入 xhigh / max:将映射为 max
glm-5-2-260617 high
  • 传入 none / minimal:将关闭思考
  • 传入 low / medium:将映射为 high
  • 传入 xhigh:将映射为 max
deepseek-v4-1-flash-260910 high
  • 传入 none:将关闭思考
  • 传入 minimal:将映射为 low
  • 传入 medium / xhigh:将映射为 high
  • 传入 ultra:将映射为 max
  • deepseek-v4-pro-ga-260813
  • deepseek-v4-flash-ga-260731
high
  • 传入 none / minimal:将关闭思考
  • 传入 medium:将映射为 low
  • 传入 xhigh:将映射为 high
  • deepseek-v4-pro-260425
high
  • 传入 minimal:将关闭思考

API Chat API Responses API
示例
JSON
...
    "model": "doubao-seed-2-1-pro-260915",
    "messages": [
        {"role": "user","content": "What are some common cruciferous plants?"}
    ],
    "reasoning_effort": "low"
...
JSON
...
    "model": "doubao-seed-2-1-pro-260915",
    "input": [
        {"role": "user","content":"What are some common cruciferous plants?"}
    ],
    "reasoning":{"effort": "low"}
...

完整示例及说明请参见 控制思维链长度。

回传思考内容#

doubao-seed-1.8 之前的模型在工具调用场景中开启深度思考后,会直接丢弃思维链内容。doubao-seed-1.8 及部分模型为给出更详尽准确的回答,将不会直接丢弃思维链内容,思维链内容可能参与后续轮次推理,输入 tokens 会增加,具体参见工作原理。

回传思考内容加密原文#

部分模型默认会开启 thinking summary 能力,不会输出模型原始的思考内容,会返回模型思考内容摘要(choices.message.reasoning_content)、思考内容加密原文(choices.message.encrypted_content)。在多轮工具调用场景(如 agent 场景),必须原样回传思考内容加密原文。

支持模型:

  • doubao-seed-evolving
  • doubao-seed-2-1-pro-260915
  • doubao-seed-2-1-lite-260915
  • doubao-seed-2-1-pro-260628
  • doubao-seed-2-1-turbo-260628
  • doubao-seed-2-0-lite-260428

字段说明:

  • reasoning_effort:仅作用于模型的原始思考内容,不适用于思考摘要。
  • usage.completion_tokens_details.reasoning_tokens:为原始思考内容的 tokens,计费仍然按原始思考内容 token 计算。

回传注意事项:

  • 回传 encrypted_content、reasoning_content 字段: encrypted_content 字段优先级高,会忽略 reasoning_content 中的内容。其中 encrypted_content 内容必须为有效内容,如果被篡改则无法还原。
  • 仅回传 reasoning_content 字段:使用思考内容摘要参与模型推理。在多轮工具调用场景(如 agent 场景),如果没有回传 encrypted_content 字段,将导致模型推理效果下降。
  • 未回传思考内容相关字段:不会报错。

回传思考内容加密原文示例:
以下是在工具调用场景,回传思考内容加密原文的示例。其中使用 Responses API 推荐使用 previous_response_id 自动获取原始思考内容并回传给模型参与推理。

API Chat API Responses API
支持模型及说明 * 回传思考内容加密原文 * 支持模型
示例

第一轮请求:触发工具调用

Bash
curl https://ark.cn-beijing.volces.com/api/v3/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -d '{
    "model": "doubao-seed-2-0-lite-260215",
    "messages": [
        {
            "role": "system",
            "content": "你是人工智能助手。"

        },
        {
            "role": "user",
            "content": "今天北京天气怎么样"

        }
    ],
    "thinking":{"type": "enabled"},
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "get_weather",
                "description": "天气查询",

                "parameters": {
                    "properties": {
                        "location": {
                            "description": "地点的位置信息,例如北京、上海。",

                            "type": "string"
                        }
                    },
                    "required": [
                        "location"
                    ],
                    "type": "object"
                }
            }
        }
    ]
  }'

第一轮响应:返回工具调用指令
模型会返回encrypted_content、reasoning_content、tool_calls等关键字段。

Bash
{
    "choices": [
        {
            "finish_reason": "tool_calls",
            "index": 0,
            "logprobs": null,
            "message": {
                "content": "",
                "reasoning_content": "北京天气查询将由我调用相关工具完成。\n",

                "encrypted_content": "djF+2EICEj3ryfEfSUdR/SmS8OeEH4znOYftL4SWDXR8uxROjx11W7rRCj5ArLwzsm7rFsO4frOdLm2p3/yWz/r0TMqrjHiaTTvRMNdV6sLdETySlb3PDgY1W+zuYuETiq3bQuxga5jKx+GpfvlDJMfJfzq/G1kDp6ryurs0rKAFIziyc4mfFSh2CzDKNcAcp5Fi5R7M2QrSYmIUJjnoB48IVUCzu4xn7bT05qheVnGO9fbs15gYK3zINUvVsp51Oq72U/ksrPZFVs2BTgNRwjmxnFNn7A==",
                "role": "assistant",
                "tool_calls": [
                    {
                        "function": {
                            "arguments": " {\"location\": \"北京\"}",

                            "name": "get_weather"
                        },
                        "id": "call_wiezxeyae8jzxl3jx8nhfgb5",
                        "type": "function"
                    }
                ]
            }
        }
    ],
    ...
 }

第二轮请求:回传完整上下文并生成最终响应
下面示例是在第一轮请求的基础上,回传思考内容加密原文(encrypted_content)和思考内容摘要(reasoning_content)、工具调用结果,模型生成自然语言回答。

Bash
curl https://ark.cn-beijing.volces.com/api/v3/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -d '{
    "model": "doubao-seed-2-0-lite-260215",
    "messages": [
        {
            "role": "system",
            "content": "你是人工智能助手。"

        },
        {
            "role": "user",
            "content": "今天北京天气怎么样"

        },
        {
            "reasoning_content": "北京天气查询将由我调用相关工具完成。\n",

            "encrypted_content": "djF+2EICEj3ryfEfSUdR/SmS8OeEH4znOYftL4SWDXR8uxROjx11W7rRCj5ArLwzsm7rFsO4frOdLm2p3/yWz/r0TMqrjHiaTTvRMNdV6sLdETySlb3PDgY1W+zuYuETiq3bQuxga5jKx+GpfvlDJMfJfzq/G1kDp6ryurs0rKAFIziyc4mfFSh2CzDKNcAcp5Fi5R7M2QrSYmIUJjnoB48IVUCzu4xn7bT05qheVnGO9fbs15gYK3zINUvVsp51Oq72U/ksrPZFVs2BTgNRwjmxnFNn7A==",
            "role": "assistant",
            "tool_calls": [
                {
                    "function": {
                        "arguments": " {\"location\": \"北京\"}",

                        "name": "get_weather"
                    },
                    "id": "call_wiezxeyae8jzxl3jx8nhfgb5",
                    "type": "function"
                }
            ]
        },
        {
            "role": "tool",
            "tool_call_id":"call_wiezxeyae8jzxl3jx8nhfgb5",
            "content": "5度"

        }
    ],
    "thinking":{"type": "enabled"},
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "get_weather",
                "description": "天气查询",

                "parameters": {
                    "properties": {
                        "location": {
                            "description": "地点的位置信息,例如北京、上海。",

                            "type": "string"
                        }
                    },
                    "required": [
                        "location"
                    ],
                    "type": "object"
                }
            }
        }
    ]
  }'

第一轮请求:触发工具调用

Bash
curl https://ark.cn-beijing.volces.com/api/v3/responses \
    -H "Authorization: Bearer $ARK_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
        "model": "doubao-seed-2-0-lite-260215",
        "input": [
            {
                "role": "system",
                "content": "你是人工智能助手."

            },
            {
                "role": "user",
                "content": "今天北京天气怎么样"

            }
        ],
        "thinking":{"type": "enabled"},

        "tools": [
            {
                "type": "function",
                "name": "get_weather",
                "description": "天气查询",

                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "地点的位置信息,例如北京、上海。"

                        }
                    },
                    "required": ["location"]
                }
            }
        ]
    }'

第一轮响应:返回工具调用指令
模型返回信息包含id、call_id、arguments等关键字段。

Bash
{
    "created_at": 1766126702,
    "id": "resp_0217661267019147d8950efa0e2f7c9d9cc7a1cc971272cf4548c",
    "max_output_tokens": 32768,
    "model": "doubao-seed-2-0-lite-260215",
    "object": "response",
    "output": [
        {
            "id": "rs_02176612670248500000000000000000000ffffac154e10754f5c",
            "type": "reasoning",
            "summary": [
                {
                    "type": "summary_text",
                    "text": "用户查询北京今日天气,我将调用天气工具获取相关信息。"

                }
            ],
            "status": "completed",
            "encrypted_content": "djEqHS8w8bISWDUfivQXaeCUc8ms2JcjMBO5KQMRqKhTUdYlhbFebcndgVlFJxYUOSOAXm7gNsJdTRtp47iHpps76Rp37ipRrkEHMqIIt+KyKmN/rH9tzL+7ZLI9W4LGYMOv/27Rfqp2NW5vxiF7zkI1xgxxJFp6Vo8PNQpR68T4F7bG4PekickNR3U+EFM6hBKkhnJqxqCrjubi0o/8C35IoDF998+G6hokaDhOb6EqJ5fXaSZvtQJaK4DBh4HIciMFnRqzts/xlacBHsWCWLcxUASrvj0vYIs9a+ZN9BxkLjrBy/nEOOEcmID/I2NukCDEFa7zxlOXLvdZHuslP5cvyno="
        },
        {
            "arguments": " {\"location\": \"北京\"}",

            "call_id": "call_t885uulopdd499rn0pioze7l",
            "name": "get_weather",
            "type": "function_call",
            "id": "fc_02176612670345400000000000000000000ffffac154e10a6753e",
            "status": "completed"
        }
    ],
    ....
 }

第二轮请求:回传结果并生成最终响应
传入上一轮 response_id、工具调用结果等信息,模型生成自然语言回答。

Bash
curl https://ark.cn-beijing.volces.com/api/v3/responses \
    -H "Authorization: Bearer $ARK_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
        "model": "doubao-seed-2-0-lite-260215",
        "input": [
            {
                "type": "function_call_output",
                "call_id": "call_t885uulopdd499rn0pioze7l",
                "output": "5度"

            }
        ],
        "previous_response_id": "resp_0217661267019147d8950efa0e2f7c9d9cc7a1cc971272cf4548c",
        "thinking":{"type": "enabled"},
        "tools": [
            {
                "type": "function",
                "name": "get_weather",
                "description": "天气查询",

                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "地点的位置信息,例如北京、上海。"

                        }
                    },
                    "required": ["location"]
                }
            }
        ]
    }'

回传原始思考内容#

部分模型开启深度思考后,默认输出模型原始的思考内容。以下是在工具调用场景,回传原始思考内容的示例。

API Chat API Responses API
支持模型
  • doubao-seed-2-0-lite-260428
  • doubao-seed-2-0-mini-260428
  • doubao-seed-2-0-pro-260215
  • doubao-seed-2-0-lite-260215
  • doubao-seed-2-0-mini-260215
  • doubao-seed-2-0-code-preview-260215
  • deepseek-v4-pro-260425
  • deepseek-v4-flash-ga-260731
  • deepseek-v4-1-flash-260910
  • glm-5-2-260617
  • doubao-seed-2-0-lite-260428
  • doubao-seed-2-0-mini-260428
  • doubao-seed-2-0-pro-260215
  • doubao-seed-2-0-lite-260215
  • doubao-seed-2-0-mini-260215
  • doubao-seed-2-0-code-preview-260215
  • deepseek-v4-pro-260425
  • deepseek-v4-flash-ga-260731
  • deepseek-v4-1-flash-260910
  • glm-5-2-260617
示例

第一轮请求:触发工具调用

Bash
curl https://ark.cn-beijing.volces.com/api/v3/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -d '{
    "model": "doubao-seed-2-0-lite-260215",
    "messages": [
        {
            "role": "system",
            "content": "你是人工智能助手。"

        },
        {
            "role": "user",
            "content": "今天北京天气怎么样"

        }
    ],
    "thinking":{"type": "enabled"},
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "get_weather",
                "description": "天气查询",

                "parameters": {
                    "properties": {
                        "location": {
                            "description": "地点的位置信息,例如北京、上海。",

                            "type": "string"
                        }
                    },
                    "required": [
                        "location"
                    ],
                    "type": "object"
                }
            }
        }
    ]
  }'

第一轮响应:返回工具调用指令
模型会返回reasoning_content、tool_calls等关键字段。

JSON
{
    "choices": [
        {
            "finish_reason": "tool_calls",
            "index": 0,
            "logprobs": null,
            "message": {
                "content": "",
                "reasoning_content": "用户想查询今天北京的天气,这正好符合get_weather工具的功能,需要传入location参数为北京。所以我要调用这个工具来获取天气信息。",

                "role": "assistant",
                "tool_calls": [
                    {
                        "function": {
                            "arguments": " {\"location\": \"北京\"}",

                            "name": "get_weather"
                        },
                        "id": "call_wiezxeyae8jzxl3jx8nhfgb5",
                        "type": "function"
                    }
                ]
            }
        }
    ],
    ...
 }

第二轮请求:回传完整上下文并生成最终响应
在第一轮请求的基础上,还需要回传思维链信息、工具调用结果,模型生成自然语言回答。

Bash
curl https://ark.cn-beijing.volces.com/api/v3/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -d '{
    "model": "doubao-seed-2-0-lite-260215",
    "messages": [
        {
            "role": "system",
            "content": "你是人工智能助手。"

        },
        {
            "role": "user",
            "content": "今天北京天气怎么样"

        },
        {
            "reasoning_content": "用户想查询今天北京的天气,这正好符合get_weather工具的功能,需要传入location参数为北京。所以我要调用这个工具来获取天气信息。",

            "role": "assistant",
            "tool_calls": [
                {
                    "function": {
                        "arguments": " {\"location\": \"北京\"}",

                        "name": "get_weather"
                    },
                    "id": "call_wiezxeyae8jzxl3jx8nhfgb5",
                    "type": "function"
                }
            ]
        },
        {
            "role": "tool",
            "tool_call_id":"call_wiezxeyae8jzxl3jx8nhfgb5",
            "content": "5度"

        }
    ],
    "thinking":{"type": "enabled"},
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "get_weather",
                "description": "天气查询",

                "parameters": {
                    "properties": {
                        "location": {
                            "description": "地点的位置信息,例如北京、上海。",

                            "type": "string"
                        }
                    },
                    "required": [
                        "location"
                    ],
                    "type": "object"
                }
            }
        }
    ]
  }'

第一轮请求:触发工具调用

Bash
curl https://ark.cn-beijing.volces.com/api/v3/responses \
    -H "Authorization: Bearer $ARK_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
        "model": "doubao-seed-2-0-lite-260215",
        "input": [
            {
                "role": "system",
                "content": "你是人工智能助手."

            },
            {
                "role": "user",
                "content": "今天北京天气怎么样"

            }
        ],
        "thinking":{"type": "enabled"},
        "tools": [
            {
                "type": "function",
                "name": "get_weather",
                "description": "天气查询",

                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "地点的位置信息,例如北京、上海。"

                        }
                    },
                    "required": ["location"]
                }
            }
        ]
    }'

第一轮响应:返回工具调用指令
模型返回信息包含id、call_id、arguments等关键字段。

Bash
{
    "created_at": 1766126702,
    "id": "resp_0217661267019147d8950efa0e2f7c9d9cc7a1cc971272cf4548c",
    "max_output_tokens": 32768,
    "model": "doubao-seed-2-0-lite-260215",
    "object": "response",
    "output": [
        {
            "id": "rs_02176612670248500000000000000000000ffffac154e10754f5c",
            "type": "reasoning",
            "summary": [
                {
                    "type": "summary_text",
                    "text": "用户问今天北京的天气怎么样,我需要调用get_weather工具,参数location是北京。按照格式要求来写函数调用。"

                }
            ],
            "status": "completed"
        },
        {
            "arguments": " {\"location\": \"北京\"}",

            "call_id": "call_t885uulopdd499rn0pioze7l",
            "name": "get_weather",
            "type": "function_call",
            "id": "fc_02176612670345400000000000000000000ffffac154e10a6753e",
            "status": "completed"
        }
    ],
    ....
 }

第二轮请求:回传结果并生成最终响应
传入上一轮 response_id、工具调用结果等信息,模型生成自然语言回答。

Bash
curl https://ark.cn-beijing.volces.com/api/v3/responses \
    -H "Authorization: Bearer $ARK_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
        "model": "doubao-seed-2-0-lite-260215",
        "input": [
            {
                "type": "function_call_output",
                "call_id": "call_t885uulopdd499rn0pioze7l",
                "output": "5度"

            }
        ],
        "previous_response_id": "resp_0217661267019147d8950efa0e2f7c9d9cc7a1cc971272cf4548c",
        "thinking":{"type": "enabled"},
        "tools": [
            {
                "type": "function",
                "name": "get_weather",
                "description": "天气查询",

                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "地点的位置信息,例如北京、上海。"

                        }
                    },
                    "required": ["location"]
                }
            }
        ]
    }'

使用说明#

工作原理#

  • 多轮对话场景

流程图 说明
  • 在每一轮对话过程中,深度思考模型会输出思维链内容(COT)和最终回答(Answer)。
  • 在下一轮对话中,之前输出的思维链内容不会被拼接到上下文中。

思维链内容展现的是模型处理问题的过程,包括将问题拆分为多个问题进行处理,生成多种回复综合得出更好回答等过程。
  • 工具调用场景

    工具调用场景中开启深度思考后,为给出更详尽准确的回答,将不会直接丢弃思维链内容,历史轮次的思维链内容按需(模型自主判断)参与推理。在整个请求过程中,用户回传完整上下文即可,由服务端自行判断,是否保留思维链内容。未输入给模型的思维链内容,不会计算 token 用量。代码示例参见回传思考内容。

    |流程图 |说明 |
    | --- | --- |
    | |

    • 回答问题 1 时(请求 1.1 - 1.2),模型进行多次思考 + 工具调用后给出答案,方舟会输入完整上下文包括思维链内容给模型处理。
    • 开始回答问题 2 时(请求 2.1),方舟会自行判断并删除之前上下文中的思维链,输入给模型。
    |

减少请求超时失败#

深度思考模型使用思维链输出内容,导致回复篇幅更长、速率更慢,所以极易因超时导致任务失败。尤其在非流式输出模式下,任务未完成时断开连接,未输出内容,又产生 token 用量费用。
可使用流式输出或设置更长超时时间,减少超时失败:

  • 使用流式输出(推荐):通过分块即时返回生成内容,可有效维持连接活性(避免因长时无响应导致的连接中断),是高效且可靠的输出方式(示例代码及说明参见流式输出)。若当前应用使用非流式输出,可改造为:通过流式接口获取内容,实时拼接完整结果后再统一输出,从而显著降低请求超时失败风险。
  • 调大超时时间参数:非流式输出场景下,推荐将 timeout 参数设置为 30 分钟以上,并根据超时触发概率进一步调整超时时间。另需注意网络链路中的 TCP Keep-Alive 设置(tcp_keepalive_time 参数),避免因长时间无数据传输导致连接被系统、防火墙、路由器等中断。

方舟 Go SDK 特殊说明:无论是否使用流式输出,均需将 SDK 超时参数设置为 30 分钟以上。

使用批量推理获得更高吞吐#

当您的业务需要处理大量的数据,且对于模型返回及时性要求不高,您可使用批量推理获取最低 10B token/天的配额以及批量推理的成本降低。批量推理支持任务的方式以及类似 Chat 的接口调用方式,使用批量推理,详细说明请查看批量推理。

提示词优化建议#

深度思考模型会自行分析和拆解问题(思维链),与普通模型相比,提示词侧重点有所不同。

  • 提示词除了待解决问题,应该更多补充目标和场景等信息。如使用英语,用 Python 等语言要求;面向小学生、向领导汇报等阅读对象信息;完成论文写作、完成课题报告、撰写剧本等场景信息;体现我的专业性、获得领导赏识等目标信息。
  • 减少或者避免对问题的拆解描述,如分步骤思考、使用示例等,这样会限制住模型的推理逻辑。
  • 减少使用系统提示词,所有提示词信息直接通过用户提示词(role: user)来提问。

常见问题#