POST
/
v1
/
experimental
/
templatize_prompt
cURL
curl -X POST https://api.anthropic.com/v1/experimental/templatize_prompt \
     --header "x-api-key: $ANTHROPIC_API_KEY" \
     --header "anthropic-version: 2023-06-01" \
     --header "anthropic-beta: prompt-tools-2025-04-02" \
     --header "content-type: application/json" \
     --data \
'{
    "messages": [{"role": "user", "content": "Translate hello to German"}],
    "system": "You are an English to German translator"
}'
{
  "messages": [
    {
      "content": [
        {
          "text": "Translate {{WORD_TO_TRANSLATE}} to {{TARGET_LANGUAGE}}",
          "type": "text"
        }
      ],
      "role": "user"
    }
  ],
  "system": "You are a professional English to {{TARGET_LANGUAGE}} translator",
  "usage": [
    {
      "input_tokens": 490,
      "output_tokens": 661
    }
  ],
  "variable_values": {
    "TARGET_LANGUAGE": "German",
    "WORD_TO_TRANSLATE": "hello"
  }
}
提示词工具 API 正处于封闭研究预览阶段。申请加入封闭研究预览

开始之前

提示词工具是一套用于生成和改进提示词的 API。与我们的其他 API 不同,这是一个实验性 API:您需要申请访问权限,并且它不具备与其他 API 相同级别的长期支持承诺。 这些 API 类似于 Anthropic Workbench 中提供的功能,旨在供其他提示词工程平台和游乐场使用。

开始使用提示词改进器

要使用提示词生成 API,您需要:
  1. 已加入提示词工具 API 的封闭研究预览
  2. 直接使用 API,而不是 SDK
  3. 添加 beta 头部 prompt-tools-2025-04-02
此 API 在 SDK 中不可用

模板化提示词

Headers

anthropic-beta
string[]

Optional header to specify the beta version(s) you want to use.

To use multiple betas, use a comma separated list like beta1,beta2 or specify the header multiple times for each beta.

x-api-key
string
required

Your unique API key for authentication.

This key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the Console. Each key is scoped to a Workspace.

Body

application/json

Response

200
application/json

Successful Response

The response is of type object.