# 文档变更分析
## 1. 总体摘要
此次更新主要涉及代码示例的简化与规范化、特定模型(Sonnet 5)功能的启用声明,以及 Amazon Bedrock 平台对最新模型支持范围的澄清。开发者需重点关注 Bedrock 平台上对模型支持列表的调整。
## 2. 关键变更主题
- **代码示例简化**:在 TypeScript 示例中,SDK 初始化代码移除了显式的 `apiKey` 参数配置(`new Anthropic()`),倾向于依赖环境变量自动加载,减少了样板代码。
- **功能特性更新**:Claude Sonnet 5 现已支持在对话中途添加系统指令(Mid-conversation system messages)且不会使 Prompt Cache 失效,功能对齐了 Opus 5 和 Mythos 5。
- **平台支持范围修正**:关于 Amazon Bedrock 上的 Structured Outputs,文档移除了对 Claude Opus 5、Sonnet 5 等新模型的“可用”声明,仅保留了 4.x 系列模型的明确支持列表。
- **细节完善**:价格描述增加了 "USD" 货币单位以消除歧义;修正了 Cookbook 的 URL 拼写错误(复数变单数)。
## 3. 影响程度
**中等**
*理由*:虽然大部分为文档润色和代码示例优化,但关于 Amazon Bedrock 上 Structured Outputs 的支持列表变更可能表明新模型(Opus 5, Sonnet 5)在该平台上的功能尚未就绪或存在限制,这对特定技术栈的开发者有直接影响。
## 4. 开发者行动项
- **核查 Bedrock 兼容性**:如果您计划在 Amazon Bedrock 上使用 Claude Opus 5 或 Sonnet 5 的 Structured Outputs 功能,请务必验证当前的可用性,因为文档已将其从支持列表中移除。
- **利用 Sonnet 5 新功能**:在使用 Sonnet 5 进行 Prompt Caching 时,现在可以安全地在对话过程中追加系统指令,而无需担心缓存失效,这将提升灵活性。
- **更新代码风格**:虽然显式传入 API Key 依然有效,但建议参考新文档风格,使用环境变量配置 SDK 以简化代码。
💭 Model Reasoning
1. **Analyze the Request:**
* **Role:** World-class programmer analyzing documentation changes.
* **Input:** 4 pages of diffs (intro.md, vision.md, prompt-caching.md, structured-outputs.md).
* **Task:** Summarize changes and explain why they matter.
* **Format:** Markdown, Concise.
* **Language:** Chinese.
* **Output Structure:** Overall Summary, Key Themes, Impact Level, Action Items.
2. **Analyze Page 1: `intro.md`**
* *Diff:* `https://platform.claude.com/cookbooks` -> `https://platform.claude.com/cookbook` (removed 's').
* *Meaning:* A URL typo fix. "Cookbooks" -> "Cookbook".
* *Impact:* Negligible to developers (just a link update).
3. **Analyze Page 2: `build-with-claude/vision.md`**
* *Diff 1 (Code Snippets):* Multiple instances of `const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });` changed to `const anthropic = new Anthropic();`.
* *Meaning:* This implies the SDK now automatically looks for the `ANTHROPIC_API_KEY` environment variable if the constructor isn't provided one, or the documentation is simplifying the examples to assume environment setup is already known (though usually, standard practice in SDKs like OpenAI/Anthropic is to show the explicit init or assume it's elsewhere). Actually, looking at modern SDK conventions, often the API key is required, but if the docs are removing it, it suggests a configuration change or a simplification preference for brevity (implying standard env var loading). *Self-correction:* It's likely just cleaning up boilerplate code in examples to reduce clutter, assuming the developer knows how to instantiate the client or relies on default env var detection.
* *Diff 2 (Text):* Pricing text changed from `$1`, `$5`, `$1.30`, `$6.48` to `$1 USD`, `$5 USD`, `$1.30 USD`, `$6.48 USD`.
* *Meaning:* Adding currency specification for clarity, likely to avoid ambiguity.
* *Impact:* Low. Code simplification in examples; minor text clarity.
4. **Analyze Page 3: `build-with-claude/prompt-caching.md`**
* *Diff:* Updated a note about "Mid-conversation system messages".
* *Change:* Removed "Claude Sonnet 5" from the list of models that *do not* support this feature. Added "Claude Sonnet 5" to the list of models that *do* support it (alongside Fable 5, Mythos 5, Opus 4.8, Opus 5).
* *Meaning:* Feature parity update. Claude Sonnet 5 now supports appending system instructions mid-conversation without invalidating cache.
* *Impact:* Medium for developers specifically using Prompt Caching with Sonnet 5.
5. **Analyze Page 4: `build-with-claude/structured-outputs.md`**
* *Diff:* Updated the footnote about Amazon Bedrock support.
* *Change:* Removed mentions of "natively GA" for Opus 5, Opus 4.8, Sonnet 4.6, etc. Removed mentions of Sonnet 5, Opus 4.7, and Mythos Preview being available via the specific Messages-API Bedrock endpoint.
* *New Text:* "On Amazon Bedrock, structured outputs are available for Claude Opus 4.6, Claude Sonnet 4.6, Claude Sonnet 4.5, Claude Opus 4.5, and Claude Haiku 4.5."
* *Meaning:* This looks like a restriction or clarification. It explicitly lists older versions (4.6, 4.5) but omits Opus 5, Sonnet 5, Mythos, etc., from the Bedrock list in this specific context.
* *Interpretation:* This is potentially a significant limitation clarification. It suggests that on Bedrock, the *latest* models (Opus 5, Sonnet 5) might not support Structured Outputs yet, or the documentation is correcting an error where they were previously listed as supported. Given the removal of Opus 5/Sonnet 5 from the "available" list, this implies a **support gap** on Bedrock for the new models regarding this specific feature.
* *Impact:* High/Medium for Bedrock users using new models.
6. **Synthesize and Translate to Chinese:**
* *Overall Summary:* 主要是文档的清理、代码示例的简化以及功能支持状态的更新。特别是针对 Prompt Caching(Sonnet 5 现已支持)和 Amazon Bedrock 上的 Structured Outputs(新模型支持范围变更)。
* *Key Themes:*
* 代码示例简化:TypeScript 客户端初始化中移除了显式的 API Key 配置(暗示默认环境变量读取)。
* 功能状态澄清:Sonnet 5 现支持对话中途添加系统指令且不破坏缓存。
* 平台兼容性调整:Amazon Bedrock 上的 Structured Outputs 支持模型列表发生变更(移除了 Opus 5, Sonnet 5 等新模型的提及)。
* 文本规范化:货币符号增加 "USD" 后缀,URL 修正。
* *Impact Level:* Medium.
* *Reasoning:* Most changes are cosmetic (code simplification, typos). However, the removal of Claude Sonnet 5 and Opus 5 from the Amazon Bedrock structured outputs availability list suggests a potential change in support or a correction of previous inaccurate claims, which affects developers building on that specific platform.
* *Action Items:*
* 如果您在 Amazon Bedrock 上使用 Sonnet 5 或 Opus 5 的 Structured Outputs,请立即核实该功能当前是否可用,因为文档已将其从支持列表中移除。
* 如果使用 Sonnet 5 进行 Prompt Caching,现在可以利用动态系统指令功能而无需担心缓存失效。
* 更新代码示例以反映最新的客户端初始化最佳实践(虽然显式传 key 依然有效,但新示例更简洁)。
7. **Refining the Output (Self-Correction during drafting):**
* Make sure the distinction about the API key code change is clear. It's likely just cleaner docs, not a breaking change in the SDK behavior (SDKs usually still accept the explicit arg).
* The Bedrock change is the most "risky" one to flag.
* The Prompt Caching change is a "feature enablement".
8. **Final Polish (Markdown & Chinese):**
* Structure as requested.
*(Drafting content)*:
1. Overall: 这一批次更新主要集中在代码示例的简化、URL 修复,以及针对特定模型(Sonnet 5)和平台(Amazon Bedrock)的功能支持状态修正。
2. Key Themes:
- **代码示例简化**: TypeScript 示例中移除了显式的 `apiKey` 传递,倾向于使用环境变量自动加载。
- **功能特性更新**: Claude Sonnet 5 现已支持“中途对话系统消息”且不破坏 Prompt Cache。
- **平台支持范围澄清**: Amazon Bedrock 上的 Structured Outputs 支持列表发生了显著变化,移除了 Opus 5 和 Sonnet 5。
- **细节优化**: 价格描述增加了 "USD" 单位,修正了 Cookbook 的 URL。
3. Impact: Medium (主要是由于 Bedrock 支持列表的变更,可能影响生产环境规划)。
4. Action Items:
- 核查 Bedrock: 如果您计划在 Bedrock 上使用 Opus 5 或 Sonnet 5 的 Structured Outputs,请重新确认其可用性。
- 更新缓存策略: 针对 Sonnet 5,您可以开始利用动态系统指令功能。
- 代码审查: 确保代码符合新的初始化风格(尽管旧式初始化依然有效)。
*Checking the vision.md API key change again:* `const anthropic = new Anthropic();`. This suggests the SDK picks up `ANTHROPIC_API_KEY` from env automatically. If a developer hardcodes keys or passes a different variable name, the change is just a doc style, but if they copy-pasted the old code, they might think they *must* pass the object. The new doc shows they don't *have* to.
*Checking the Bedrock change again:* Removed Opus 5, Sonnet 5 from the "available" list. This is a big deal if you were assuming they worked.
*Checking Prompt Caching change again:* Added Sonnet 5 to the "yes" list. This is a positive change.
*Final Translation Check:* "Mid-conversation system messages" -> "中途对话系统消息". "Prompt Caching" -> "提示词缓存".
*Let's write the final response.*