<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <title>bigfish的网络博客 - API</title>
      <link>https://blog.laofu.online</link>
      <description>记录技术和生活</description>
      <generator>Zola</generator>
      <language>zh</language>
      <atom:link href="https://blog.laofu.online/tags/api/rss.xml" rel="self" type="application/rss+xml"/>
      <lastBuildDate>Sun, 11 Oct 2026 18:26:29 +0800</lastBuildDate>
      <item>
          <title>OpenAI 协议和 Anthropic 协议到底差在哪里？从一条请求走到工具调用</title>
          <pubDate>Sun, 11 Oct 2026 18:26:29 +0800</pubDate>
          <author>bigfish</author>
          <link>https://blog.laofu.online/blog/20261011-1826-openaixie-yi-he-anthropicxie-yi-dao-di-chai-zai-na-li-cong-yi-tiao-qing-qiu-zou-dao-gong-ju-diao-yong/</link>
          <guid>https://blog.laofu.online/blog/20261011-1826-openaixie-yi-he-anthropicxie-yi-dao-di-chai-zai-na-li-cong-yi-tiao-qing-qiu-zou-dao-gong-ju-diao-yong/</guid>
          <description xml:base="https://blog.laofu.online/blog/20261011-1826-openaixie-yi-he-anthropicxie-yi-dao-di-chai-zai-na-li-cong-yi-tiao-qing-qiu-zou-dao-gong-ju-diao-yong/">&lt;p&gt;你把模型供应商从 OpenAI 换成 Anthropic，最初通常只改一个 &lt;code&gt;base_url&lt;/code&gt; 和一个 &lt;code&gt;model&lt;/code&gt;。真正接入工具调用、流式输出和多模态之后，问题就出现了：同样叫 &lt;code&gt;messages&lt;/code&gt; 的字段，为什么内容结构不一样？OpenAI 返回 &lt;code&gt;tool_calls&lt;/code&gt;，Anthropic 返回 &lt;code&gt;tool_use&lt;/code&gt;，它们能不能直接互换？&lt;/p&gt;
&lt;p&gt;答案是：&lt;strong&gt;它们解决的是同一个问题，但不是同一个协议。&lt;/strong&gt; 本文真正比较的主线，是 OpenAI Responses API、OpenAI Chat Completions 和 Anthropic Messages API；这里的“OpenAI 协议”不是一套统一标准。Embeddings 只在后文作为向量接口边界说明，不参与工具调用闭环。&lt;/p&gt;
&lt;p&gt;更准确地说，OpenAI 和 Anthropic 都提供了基于 HTTP、JSON 和流式事件的模型 API；社区常说的“OpenAI 协议”“Anthropic 协议”，通常是对各自 API 请求、响应和事件约定的简称，而不是一个由双方共同维护的网络标准。&lt;/p&gt;
&lt;p&gt;本文用一条任务贯穿对比：&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;用户问：“帮我查询北京今天的天气，如果需要调用天气工具就调用它，然后给我一句简短建议。”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;文章不只比较 OpenAI &lt;strong&gt;Responses API&lt;/strong&gt; 和 Anthropic &lt;strong&gt;Messages API&lt;/strong&gt;。OpenAI 至少要分清三类接口：Responses、Chat Completions 和 Embeddings。本文按新项目优先使用 Responses 来组织示例；Chat Completions 主要用于维护已有代码、兼容现有网关，或明确依赖其 &lt;code&gt;messages&lt;/code&gt; / &lt;code&gt;choices&lt;/code&gt; 结构的场景。Embeddings 则负责把文本转换成向量，不能因为它们都使用 JSON 就把它们当成同一种“聊天协议”。&lt;/p&gt;
&lt;p&gt;本文的主线仍然是一次工具调用，但会以 OpenAI Responses 与 Anthropic Messages 为主对照，再解释 Chat Completions 的兼容差异和 Embeddings 的独立边界。OpenAI Responses API 使用自己的 input、output item、response event 和工具模型，不能把 Chat Completions 的字段机械套过去。官方入口：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;OpenAI Responses：&lt;a rel=&quot;noopener noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https://platform.openai.com/docs/api-reference/responses&quot;&gt;https://platform.openai.com/docs/api-reference/responses&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;OpenAI Chat Completions：&lt;a rel=&quot;noopener noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https://platform.openai.com/docs/api-reference/chat&quot;&gt;https://platform.openai.com/docs/api-reference/chat&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;OpenAI Embeddings：&lt;a rel=&quot;noopener noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https://platform.openai.com/docs/api-reference/embeddings&quot;&gt;https://platform.openai.com/docs/api-reference/embeddings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Anthropic Messages：&lt;a rel=&quot;noopener noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https://docs.anthropic.com/en/api/messages&quot;&gt;https://docs.anthropic.com/en/api/messages&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
      </item>
    </channel>
</rss>
