生成提示词
生成一个写得很好的提示词
提示词工具API目前处于封闭研究预览阶段。申请加入封闭研究预览。
开始之前
提示词工具是一组用于生成和改进提示词的API。与我们的其他API不同,这是一个实验性API:您需要申请访问权限,并且它不像其他API那样对长期支持有相同程度的承诺。
这些API与Anthropic Workbench中提供的功能类似,旨在供其他提示词工程平台和实验环境使用。
开始使用提示词生成器
要使用提示词生成API,您需要:
- 已加入提示词工具API的封闭研究预览
- 直接使用API,而不是SDK
- 添加beta标头
prompt-tools-2025-04-02
此API在SDK中不可用
生成提示词
Headers
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.
Body
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"}
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"
1 - 256
Response
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>"
}
]
}
]
}
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.
Usage information
Was this page helpful?