Loading...
    • 開發者指南
    • API 參考
    • MCP
    • 資源
    • 發行說明
    Search...
    ⌘K

    第一步

    Claude 介紹快速入門

    模型與定價

    模型概覽選擇模型Claude 4.5 的新功能遷移到 Claude 4.5模型棄用定價

    使用 Claude 建構

    功能概覽使用 Messages API上下文視窗提示詞最佳實踐

    功能

    提示詞快取上下文編輯延伸思考串流訊息批次處理引用多語言支援Token 計數嵌入向量視覺PDF 支援Files API搜尋結果Google Sheets 附加元件

    工具

    概述如何實現工具使用代幣高效工具使用細粒度工具串流Bash 工具代碼執行工具電腦使用工具文字編輯工具網頁擷取工具網路搜尋工具記憶工具

    代理技能

    概述在 API 中開始使用 Agent Skills技能編寫最佳實踐使用 Agent Skills 與 API

    Agent SDK

    概述Agent SDK 參考 - TypeScriptPython SDK

    指南

    串流輸入處理權限會話管理託管 Agent SDK修改系統提示SDK 中的 MCP自訂工具SDK 中的子代理SDK 中的斜線命令SDK 中的代理技能追蹤成本和使用量待辦事項清單SDK 中的外掛程式

    API 中的 MCP

    MCP 連接器遠端 MCP 伺服器

    Claude 在第三方平台上

    Amazon BedrockVertex AI

    提示工程

    概述提示詞生成器使用提示模板提示詞改進器保持清晰和直接使用範例(多樣提示)讓 Claude 思考(思維鏈)使用 XML 標籤給 Claude 分配角色(系統提示詞)預填 Claude 的回應串接複雜提示長文本技巧延伸思考技巧

    測試與評估

    定義成功標準開發測試案例使用評估工具降低延遲

    加強防護措施

    減少幻覺提高輸出一致性防範越獄handle-streaming-refusals減少提示詞洩漏保持 Claude 的角色特性

    管理和監控

    Admin API 概述使用量和成本 APIClaude Code 分析 API
    Console
    提示工程

    使用提示模板和變數

    當使用 Claude 部署基於 LLM 的應用程式時,您的 API 呼叫通常會包含兩種類型的內容:

    • 固定內容: 在多次互動中保持不變的靜態指令或上下文
    • 變數內容: 隨每次請求或對話而變化的動態元素,例如:
      • 使用者輸入
      • 檢索增強生成 (RAG) 的檢索內容
      • 對話上下文,如使用者帳戶歷史記錄
      • 系統生成的資料,如從其他獨立的 Claude 呼叫中輸入的工具使用結果

    提示模板結合了這些固定和變數部分,使用佔位符來表示動態內容。在 Claude Console 中,這些佔位符用**{{雙括號}}**表示,使它們易於識別並允許快速測試不同的值。


    何時使用提示模板和變數

    當您期望提示的任何部分會在另一次對 Claude 的呼叫中重複使用時,您應該始終使用提示模板和變數(僅透過 API 或 Claude Console。claude.ai 目前不支援提示模板或變數)。

    提示模板提供了幾個好處:

    • 一致性: 確保在多次互動中提示結構的一致性
    • 效率: 輕鬆替換變數內容而無需重寫整個提示
    • 可測試性: 透過僅更改變數部分來快速測試不同的輸入和邊緣情況
    • 可擴展性: 隨著應用程式複雜性的增長,簡化提示管理
    • 版本控制: 透過僅關注提示的核心部分(與動態輸入分離),輕鬆追蹤提示結構隨時間的變化

    Claude Console 大量使用提示模板和變數,以支援上述所有功能和工具,例如:

    • 提示生成器: 決定您的提示需要哪些變數,並將它們包含在輸出的模板中
    • 提示改進器: 接受您現有的模板,包括所有變數,並在輸出的改進模板中維護它們
    • 評估工具: 透過分離提示模板的變數和固定部分,讓您輕鬆測試、擴展和追蹤提示的版本

    提示模板範例

    讓我們考慮一個將英文文本翻譯成西班牙文的簡單應用程式。翻譯的文本會是變數,因為您期望這個文本在使用者之間或對 Claude 的呼叫之間會發生變化。這個翻譯文本可以從資料庫或使用者的輸入中動態檢索。

    因此,對於您的翻譯應用程式,您可能會使用這個簡單的提示模板:

    將此文本從英文翻譯成西班牙文:{{text}}

    下一步

    生成提示

    了解 Claude Console 中的提示生成器,並嘗試讓 Claude 為您生成提示。

    應用 XML 標籤

    如果您想提升提示變數的技巧,請將它們包裝在 XML 標籤中。

    Claude Console

    查看 Claude Console 中提供的眾多提示開發工具。

      © 2025 ANTHROPIC PBC

      Products

      • Claude
      • Claude Code
      • Max plan
      • Team plan
      • Enterprise plan
      • Download app
      • Pricing
      • Log in

      Features

      • Claude and Slack
      • Claude in Excel

      Models

      • Opus
      • Sonnet
      • Haiku

      Solutions

      • AI agents
      • Code modernization
      • Coding
      • Customer support
      • Education
      • Financial services
      • Government
      • Life sciences

      Claude Developer Platform

      • Overview
      • Developer docs
      • Pricing
      • Amazon Bedrock
      • Google Cloud’s Vertex AI
      • Console login

      Learn

      • Blog
      • Catalog
      • Courses
      • Use cases
      • Connectors
      • Customer stories
      • Engineering at Anthropic
      • Events
      • Powered by Claude
      • Service partners
      • Startups program

      Company

      • Anthropic
      • Careers
      • Economic Futures
      • Research
      • News
      • Responsible Scaling Policy
      • Security and compliance
      • Transparency

      Help and security

      • Availability
      • Status
      • Support center

      Terms and policies

      • Privacy policy
      • Responsible disclosure policy
      • Terms of service: Commercial
      • Terms of service: Consumer
      • Usage policy

      Products

      • Claude
      • Claude Code
      • Max plan
      • Team plan
      • Enterprise plan
      • Download app
      • Pricing
      • Log in

      Features

      • Claude and Slack
      • Claude in Excel

      Models

      • Opus
      • Sonnet
      • Haiku

      Solutions

      • AI agents
      • Code modernization
      • Coding
      • Customer support
      • Education
      • Financial services
      • Government
      • Life sciences

      Claude Developer Platform

      • Overview
      • Developer docs
      • Pricing
      • Amazon Bedrock
      • Google Cloud’s Vertex AI
      • Console login

      Learn

      • Blog
      • Catalog
      • Courses
      • Use cases
      • Connectors
      • Customer stories
      • Engineering at Anthropic
      • Events
      • Powered by Claude
      • Service partners
      • Startups program

      Company

      • Anthropic
      • Careers
      • Economic Futures
      • Research
      • News
      • Responsible Scaling Policy
      • Security and compliance
      • Transparency

      Help and security

      • Availability
      • Status
      • Support center

      Terms and policies

      • Privacy policy
      • Responsible disclosure policy
      • Terms of service: Commercial
      • Terms of service: Consumer
      • Usage policy
      © 2025 ANTHROPIC PBC