Mtu API-DOC
首页应用对话
首页应用对话
WeChat ID:F25F91
    • Mtu API简介
    • Model-Studio-Pricing模型列表价格
    • Model限时免费模型列表
    • 1206更新(接入纯搜索baidu接口)
    • 1204模型更新Mistral-Large-3(675B)
    • 1120模型更新Jina DeepSearch v1
    • 1119模型更新列表Gemini 3 API
    • 1116模型更新列表GPT-5.1系列
    • 1114模型更新列表
    • 1106模型更新列表
    • 1021模型更新列表
    • 1013模型更新列表
    • 1003模型更新列表
    • 0922模型更新列表
    • Migrate to the Responses API
    • GPT-5-codex API上线 0924更新
    • OpenAI Web search 网络搜索
    • Using tools OpenAI官方文档
    • Chat
      • Create chat completion
        POST
      • List chat completions
        GET
      • Get chat completion
        GET
      • Update chat completion metadata
        POST
      • Delete chat completion
        DELETE
      • Get chat messages
        GET
    • Images
      • Create image
        POST
      • Create image edit
        POST
      • Create image variation
        POST
    • Audio
      • Create speech
      • Create transcription
      • Create translation
    • Embeddings
      • Create embeddings
    • Moderations
      • Create moderation
    • Files
      • Upload file
      • List files
      • Retrieve file
      • Delete file
      • Retrieve file content
    • Models
      • List models
      • Retrieve model
      • Delete a fine-tuned model
    • MCP开发
      • MCP开始使用
        • 简介
        • 示例 Servers
        • 示例 Clients
        • 快速上手
          • 服务器开发
          • 客户端开发
          • Claude 桌面版开发
      • 教程
        • 使用 LLMs 构建 MCP
        • 调试 Debugging
        • 调试器 Inspector
      • 概念
        • 核心架构
        • 资源 Resources
        • 提示词 Prompts
        • 工具 Tools
        • 采样 Sampling
        • 根 Roots
        • 传输 Transports
      • 开发
        • 新计划
        • 规划
        • 贡献
    • OpenAI 项目
      • 介绍
      • 项目说明
      • 导言
      • 身份验证
      • 发出请求
      • 参数详情
      • 聊天(Chat)
        • Chat Completions 对象
        • Chat Completions 对象块
        • 创建 Chat Completions
      • 音频(Audio)
        • 创建语音
        • 创建转录
        • 创建翻译
      • 自动补全(Completions)
        • Completions 对象
        • 创建 Completions
      • 嵌入(Embeddings)
        • 嵌入对象
        • 创建嵌入
      • 微调(Fine-tuning)
        • 微调作业对象
        • 微调作业事件对象
        • 创建微调作业
        • 列出微调作业
        • 检索微调作业
        • 取消微调
        • 列出微调事件
      • 图像(Images)
        • README
        • 图像对象
        • 创建图像
        • 创建图片编辑
        • 创建图像变体
      • 模型(Models)
        • 模型对象
        • 列出模型
        • 检索模型
        • 删除微调模型
      • 文件(Files)
        • README
        • 文件对象
        • 列出文件
        • 上传文件
        • 删除文件
        • 检索文件
        • 检索文件内容
      • 审查(Moderations)
        • 调节对象
        • 创建内容审核
      • 助手测试版(AssistantsBeta)
        • 辅助对象
        • 辅助文件对象
        • 创建助手
        • 检索助手
        • 修改助手
        • 删除助手
        • 列出助手
        • 创建辅助文件
        • 检索助手文件
        • 删除辅助文件
        • 列出助手文件
      • 线程(Threads)
        • 线程对象
        • 创建线程
        • 检索线程
        • 修改线程
        • 删除话题
      • 留言(Messages)
        • 消息对象
        • 消息文件对象
        • 创建消息
        • 检索消息
        • 修改留言
        • 列出消息
        • 检索消息文件
        • 列出消息文件
      • 运行(Runs)
        • 运行对象
        • 运行步骤对象
        • 创建运行
        • 检索运行
        • 修改运行
        • 列表运行
        • 提交工具输出以运行
        • 取消运行
        • 创建线程并运行
        • 检索运行步骤
        • 列出运行步骤
      • 已弃用-音频(Audio)
        • 创建转录
        • 创建翻译
    • 通义千问 项目
      • 首次调用通义千问API
      • 文本生成
        • 深度思考(QwQ)
          • 深度思考(QwQ)概括
          • 快速开始
          • 多轮对话
        • 长上下文
          • 通过file-id传入文档信息
            • 简单示例
            • 传入多文档
            • 追加文档
          • 通过纯文本传入信息
            • 简单示例
            • 传入多文档
            • 追加文档
          • 通过JSON字符串传入文档信息
            • 简单示例
            • 传入多文档
            • 追加文档
        • 翻译能力
          • Qwen-MT模型
          • 支持的语言
          • 简单示例
          • 流式输出
          • 术语干预翻译
          • 使用翻译记忆
          • 领域提示
        • 数学能力
          • 模型概览
          • 示例代码
        • 代码能力
          • 模型概览
          • 简单示例
          • 代码补全
          • 根据前缀和后缀生成中间内容
        • 多轮对话
          • 开始使用
        • 流式输出(Stream)
          • 概述
          • 开始使用
        • 工具调用(Function Calling)
          • 概述
        • 结构化输出(Json Mode)
          • 支持的模型
          • 开始使用
        • 前缀续写(Partial Mode)
          • 支持的模型
          • 开始使用
        • 批量推理(Batch)
          • 概述
        • 上下文缓存(Context Cache)
          • 概述
      • 视觉理解
        • 全模态(Qwen-Omni )
          • 概述
          • 开始使用
          • 图片+文本输入
          • 音频+文本输入
          • 视频+文本输入
          • 多轮对话
    • Claude code 部署教程
      • Claude code 部署教程接入MTUAPI
      • Claude Code Router 配置指南
    • 数据模型
      • Schemas
        • ChatCompletionRequest
        • ChatCompletionObject
        • EmbeddingsRequest
        • ChatMessage
        • ImageCreateRequest
        • ModerationsRequest
        • FileObject

    Migrate to the Responses API

    Migrate to the Responses API#

    The Responses API is our new API primitive, an evolution of Chat Completions which brings added simplicity and powerful agentic primitives to your integrations.
    While Chat Completions remains supported, Responses is recommended for all new projects.

    About the Responses API#

    The Responses API is a unified interface for building powerful, agent-like applications. It contains:
    Built-in tools like web search, file search , computer use, code interpreter, and remote MCPs.
    Seamless multi-turn interactions that allow you to pass previous responses for higher accuracy reasoning results.
    Native multimodal support for text and images.

    Responses benefits#

    The Responses API contains several benefits over Chat Completions:
    Better performance: Using reasoning models, like GPT-5, with Responses will result in better model intelligence when compared to Chat Completions. Our internal evals reveal a 3% improvement in SWE-bench with same prompt and setup.
    Agentic by default: The Responses API is an agentic loop, allowing the model to call multiple tools, like web_search, image_generation, file_search, code_interpreter, remote MCP servers, as well as your own custom functions, within the span of one API request.
    Lower costs: Results in lower costs due to improved cache utilization (40% to 80% improvement when compared to Chat Completions in internal tests).
    Stateful context: Use store: true to maintain state from turn to turn, preserving reasoning and tool context from turn-to-turn.
    Flexible inputs: Pass a string with input or a list of messages; use instructions for system-level guidance.
    Encrypted reasoning: Opt-out of statefulness while still benefiting from advanced reasoning.
    Future-proof: Future-proofed for upcoming models.

    Comparison to Chat Completions#

    The Responses API is a superset of the Chat Completions API. It has a predictable, event-driven architecture, whereas the Chat Completions API continuously appends to the content field as tokens are generated—requiring you to manually track differences between each state. Multi-step conversational logic and reasoning are easier to implement with the Responses API.
    The Responses API clearly emits semantic events detailing precisely what changed (e.g., specific text additions), so you can write integrations targeted at specific emitted events (e.g., text changes), simplifying integration and improving type safety.
    CAPABILITIESCHAT COMPLETIONS APIRESPONSES API
    Text generation✓✓
    Audio✓Coming soon
    Vision✓✓
    Structured Outputs✓✓
    Function calling✓✓
    Web search✓✓
    File searchx✓
    Computer usex✓
    Code interpreterx✓
    MCPx✓
    Image generationx✓
    Reasoning summariesx✓

    Examples#

    See how the Responses API compares to the Chat Completions API in specific scenarios.

    Messages vs. Items#

    Both APIs make it easy to generate output from our models. The input to, and result of, a call to Chat completions is an array of Messages, while the Responses API uses Items. An Item is a union of many types, representing the range of possibilities of model actions. A message is a type of Item, as is a function_call or function_call_output. Unlike a Chat Completions Message, where many concerns are glued together into one object, Items are distinct from one another and better represent the basic unit of model context.
    Additionally, Chat Completions can return multiple parallel generations as choices, using the n param. In Responses, we've removed this param, leaving only one generation.
    Chat Completions API
    Responses API
    When you get a response back from the Responses API, the fields differ slightly. Instead of a message, you receive a typed response object with its own id. Responses are stored by default. Chat completions are stored by default for new accounts. To disable storage when using either API, set store: false.
    The objects you recieve back from these APIs will differ slightly. In Chat Completions, you receive an array of choices, each containing a message. In Responses, you receive an array of Items labled output.
    Chat Completions API
    {
      "id": "chatcmpl-C9EDpkjH60VPPIB86j2zIhiR8kWiC",
      "object": "chat.completion",
      "created": 1756315657,
      "model": "gpt-5-2025-08-07",
      "choices": [
        {
          "index": 0,
          "message": {
            "role": "assistant",
            "content": "Under a blanket of starlight, a sleepy unicorn tiptoed through moonlit meadows, gathering dreams like dew to tuck beneath its silver mane until morning.",
            "refusal": null,
            "annotations": []
          },
          "finish_reason": "stop"
        }
      ],
      ...
    }
    Responses API
    {
      "id": "resp_68af4030592c81938ec0a5fbab4a3e9f05438e46b5f69a3b",
      "object": "response",
      "created_at": 1756315696,
      "model": "gpt-5-2025-08-07",
      "output": [
        {
          "id": "rs_68af4030baa48193b0b43b4c2a176a1a05438e46b5f69a3b",
          "type": "reasoning",
          "content": [],
          "summary": []
        },
        {
          "id": "msg_68af40337e58819392e935fb404414d005438e46b5f69a3b",
          "type": "message",
          "status": "completed",
          "content": [
            {
              "type": "output_text",
              "annotations": [],
              "logprobs": [],
              "text": "Under a quilt of moonlight, a drowsy unicorn wandered through quiet meadows, brushing blossoms with her glowing horn so they sighed soft lullabies that carried every dreamer gently to sleep."
            }
          ],
          "role": "assistant"
        }
      ],
      ...
    }

    Additional differences#

    Responses are stored by default. Chat completions are stored by default for new accounts. To disable storage in either API, set store: false.
    Reasoning models have a richer experience in the Responses API with improved tool usage.
    Structured Outputs API shape is different. Instead of response_format, use text.format in Responses. Learn more in the Structured Outputs guide.
    The function-calling API shape is different, both for the function config on the request, and function calls sent back in the response. See the full difference in the function calling guide.
    The Responses SDK has an output_text helper, which the Chat Completions SDK does not have.
    In Chat Completions, conversation state must be managed manually. The Responses API has compatibility with the Conversations API for persistent conversations, or the ability to pass a previous_response_id to easily chain Responses together.

    Migrating from Chat Completions#

    1. Update generation endpoints#

    Start by updating your generation endpoints from post /v1/chat/completions to post /v1/responses.
    If you are not using functions or multimodal inputs, then you're done! Simple message inputs are compatible from one API to the other:
    Web search tool
    Chat Completions
    With Chat Completions, you need to create an array of messages that specify different roles and content for each role.
    Generate text from a model
    Responses
    With Responses, you can separate instructions and input at the top-level. The API shape is similar to Chat Completions but has cleaner semantics.
    Generate text from a model

    2. Update item definitions#

    Chat Completions
    With Chat Completions, you need to create an array of messages that specify different roles and content for each role.
    Generate text from a model
    Responses
    With Responses, you can separate instructions and input at the top-level. The API shape is similar to Chat Completions but has cleaner semantics.
    Generate text from a model

    3. Update multi-turn conversations#

    If you have multi-turn conversations in your application, update your context logic.
    Chat Completions
    In Chat Completions, you have to store and manage context yourself.
    Multi-turn conversation
    Responses
    With responses, the pattern is similar, you can pass outputs from one response to the input of another.
    Multi-turn conversation
    As a simplification, we've also built a way to simply reference inputs and outputs from a previous response by passing its id. You can use `previous_response_id` to form chains of responses that build upon one other or create forks in a history.
    Multi-turn conversation

    4. Decide when to use statefulness#

    Some organizations—such as those with Zero Data Retention (ZDR) requirements—cannot use the Responses API in a stateful way due to compliance or data retention policies. To support these cases, OpenAI offers encrypted reasoning items, allowing you to keep your workflow stateless while still benefiting from reasoning items.
    To disable statefulness, but still take advantage of reasoning:
    set store: false in the store field
    add ["reasoning.encrypted_content"] to the include field
    The API will then return an encrypted version of the reasoning tokens, which you can pass back in future requests just like regular reasoning items. For ZDR organizations, OpenAI enforces store=false automatically. When a request includes encrypted_content, it is decrypted in-memory (never written to disk), used for generating the next response, and then securely discarded. Any new reasoning tokens are immediately encrypted and returned to you, ensuring no intermediate state is ever persisted.

    5. Update function definitions#

    There are two minor, but notable, differences in how functions are defined between Chat Completions and Responses.
    1.
    In Chat Completions, functions are defined using externally tagged polymorphism, whereas in Responses, they are internally-tagged.
    2.
    In Chat Completions, functions are non-strict by default, whereas in the Responses API, functions are strict by default.
    The Responses API function example on the right is functionally equivalent to the Chat Completions example on the left.
    Chat Completions API
    Responses API

    Follow function-calling best practices#

    In Responses, tool calls and their outputs are two distinct types of Items that are correlated using a call_id. See the tool calling docs for more detail on how function calling works in Responses.

    6. Update Structured Outputs definition#

    In the Responses API, defining structured outputs have moved from response_format to text.format:
    Chat Completions
    Structured Outputs
    Responses
    Structured Outputs

    7. Upgrade to native tools#

    If your application has use cases that would benefit from OpenAI's native tools, you can update your tool calls to use OpenAI's tools out of the box.
    Chat Completions
    With Chat Completions, you cannot use OpenAI's tools natively and have to write your own.
    Web search tool
    Responses
    With Responses, you can simply specify the tools that you are interested in.
    Web search tool

    Incremental migration#

    The Responses API is a superset of the Chat Completions API. The Chat Completions API will also continue to be supported. As such, you can incrementally adopt the Responses API if desired. You can migrate user flows who would benefit from improved reasoning models to the Responses API while keeping other flows on the Chat Completions API until you're ready for a full migration.
    As a best practice, we encourage all users to migrate to the Responses API to take advantage of the latest features and improvements from OpenAI.

    Assistants API#

    Based on developer feedback from the Assistants API beta, we've incorporated key improvements into the Responses API to make it more flexible, faster, and easier to use. The Responses API represents the future direction for building agents on OpenAI.
    We now have Assistant-like and Thread-like objects in the Responses API. Learn more in the migration guide. As of August 26th, 2025, we're deprecating the Assistants API, with a sunset date of August 26, 2026.
    Was this page useful?

    扫码加入 Mtu api 微信交流群

    获得 Mtu api 使用上的任何帮助,效率得到大幅提升,技术客服WeChat:F25F91

    扫码关注公众号
    修改于 2025-09-24 08:23:11
    上一页
    0922模型更新列表
    下一页
    GPT-5-codex API上线 0924更新
    Built with