POST
/
v1
/
experimental
/
generate_prompt
curl -X POST https://api.anthropic.com/v1/experimental/generate_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 \
'{
    "task": "a chef for a meal prep planning service",
    "target_model": "claude-3-7-sonnet-20250219"
}'
{
  "messages": [
    {
      "content": [
        {
          "text": "<generated prompt>",
          "type": "text"
        }
      ],
      "role": "user"
    }
  ],
  "system": "",
  "usage": [
    {
      "input_tokens": 490,
      "output_tokens": 661
    }
  ]
}

API инструментов промптов находятся в закрытом исследовательском превью. Запросить присоединение к закрытому исследовательскому превью.

Прежде чем начать

Инструменты промптов представляют собой набор API для генерации и улучшения промптов. В отличие от наших других API, это экспериментальный API: вам нужно будет запросить доступ, и он не имеет такого же уровня обязательств по долгосрочной поддержке, как другие API.

Эти API похожи на то, что доступно в Anthropic Workbench, и предназначены для использования другими платформами инженерии промптов и песочницами.

Начало работы с генератором промптов

Чтобы использовать API генерации промптов, вам необходимо:

  1. Присоединиться к закрытому исследовательскому превью для API инструментов промптов
  2. Использовать API напрямую, а не SDK
  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
task
string
required

Description of the prompt's purpose.

The task parameter tells Claude what the prompt should do or what kind of role or functionality you want to create. This helps guide the prompt generation process toward your intended use case.

Example:

{"task": "a chef for a meal prep planning service"}
Examples:

"a chef for a meal prep planning service"

target_model
string | null
default:

The model this prompt will be used for. This optional parameter helps us understand which models our prompt tools are being used with, but it doesn't currently affect functionality.

Example:

"claude-3-7-sonnet-20250219"
Required string length: 1 - 256
Examples:

"claude-3-7-sonnet-20250219"

Response

200
application/json
Successful Response
messages
object[]
required

The response contains a list of message objects in the same format used by the Messages API. Typically includes a user message with the complete generated prompt text, and may include an assistant message with a prefill to guide the model's initial response.

These messages can be used directly in a Messages API request to start a conversation with the generated prompt.

Example:

{
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "You are a chef for a meal prep planning service..."
        }
      ]
    },
    {
      "role": "assistant",
      "content": [
        {
          "type": "text",
          "text": "<recipe_planning>"
        }
      ]
    }
  ]
}
Examples:
[
  {
    "content": [
      {
        "text": "<generated prompt>",
        "type": "text"
      }
    ],
    "role": "user"
  }
]
system
string
default:
required

Currently, the system field is always returned as an empty string (""). In future iterations, this field may contain generated system prompts.

Directions similar to what would normally be included in a system prompt are included in messages when generating a prompt.

Examples:

""

usage
object
required

Usage information