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"
  }
}
Die Prompt-Tools-APIs befinden sich in einer geschlossenen Forschungsvorschau. Beantragen Sie die Teilnahme an der geschlossenen Forschungsvorschau.

Bevor Sie beginnen

Die Prompt-Tools sind eine Reihe von APIs zur Generierung und Verbesserung von Prompts. Im Gegensatz zu unseren anderen APIs ist dies eine experimentelle API: Sie müssen Zugang beantragen, und sie hat nicht das gleiche Maß an Verpflichtung zur langfristigen Unterstützung wie andere APIs. Diese APIs sind ähnlich zu dem, was in der Anthropic Workbench verfügbar ist, und sind für die Verwendung durch andere Prompt-Engineering-Plattformen und Playgrounds gedacht.

Erste Schritte mit dem Prompt-Verbesserer

Um die Prompt-Generierungs-API zu verwenden, müssen Sie:
  1. Der geschlossenen Forschungsvorschau für die Prompt-Tools-APIs beigetreten sein
  2. Die API direkt verwenden, anstatt das SDK
  3. Den Beta-Header prompt-tools-2025-04-02 hinzufügen
Diese API ist nicht im SDK verfügbar

Einen Prompt als Vorlage erstellen

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

Successful Response

The response is of type object.