POST
/
v1
/
experimental
/
templatize_prompt

프롬프트 도구 API는 비공개 연구 프리뷰 단계에 있습니다. 비공개 연구 프리뷰 참여 신청하기

시작하기 전에

프롬프트 도구는 프롬프트를 생성하고 개선하기 위한 API 세트입니다. 다른 API들과 달리, 이것은 실험적인 API입니다: 접근 권한을 요청해야 하며, 다른 API들과 같은 수준의 장기 지원을 보장하지 않습니다.

이러한 API들은 Anthropic Workbench에서 사용 가능한 것과 유사하며, 다른 프롬프트 엔지니어링 플랫폼과 플레이그라운드에서 사용하도록 설계되었습니다.

프롬프트 개선기 시작하기

프롬프트 생성 API를 사용하기 위해서는 다음이 필요합니다:

  1. 프롬프트 도구 API의 비공개 연구 프리뷰에 참여하고 있어야 합니다
  2. SDK가 아닌 API를 직접 사용해야 합니다
  3. 베타 헤더 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
messages
object[]
required

The prompt to templatize, structured as a list of message objects.

Each message in the messages array must:

  • Contain only text-only content blocks
  • Not include tool calls, images, or prompt caching blocks

Example of a simple text prompt:

[
  {
    "role": "user", 
    "content": [
      {
        "type": "text",
        "text": "Translate hello to German"
      }
    ]
  }
]

Note that only contiguous user messages with text content are allowed. Assistant prefill is permitted, but other content types will cause validation errors.

system
string | null

The existing system prompt to templatize.

{
  "system": "You are a professional English to German translator",
  [...]
}

Note that this differs from the Messages API; it is strictly a string.

Response

200 - application/json
messages
object[]
required

The templatized prompt with variable placeholders.

The response includes the input messages with specific values replaced by variable placeholders. These messages maintain the original message structure but contain uppercase variable names in place of concrete values.

For example, an input message content like "Translate hello to German" would be transformed to "Translate {{WORD_TO_TRANSLATE}} to {{TARGET_LANGUAGE}}".

{
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Translate {{WORD_TO_TRANSLATE}} to {{TARGET_LANGUAGE}}"
        }
      ]
    }
  ]
}
system
string
required

The input system prompt with variables identified and replaced.

If no system prompt was provided in the original request, this field will be an empty string.

usage
object
required

Usage information

variable_values
object
required

A mapping of template variable names to their original values, as extracted from the input prompt during templatization. Each key represents a variable name identified in the templatized prompt, and each value contains the corresponding content from the original prompt that was replaced by that variable.

Example:

"variable_values": {
  "WORD_TO_TRANSLATE": "hello",
  "TARGET_LANGUAGE": "German"
}

In this example response, the original prompt – Translate hello to German – was templatized to Translate WORD_TO_TRANSLATE to TARGET_LANGUAGE, with the variable values extracted as shown.