Meningkatkan prompt
Membuat prompt baru yang lebih baik dengan panduan umpan balik
API alat prompt sedang dalam pratinjau penelitian tertutup. Minta untuk bergabung dengan pratinjau penelitian tertutup.
Sebelum Anda memulai
Alat prompt adalah serangkaian API untuk menghasilkan dan meningkatkan prompt. Tidak seperti API kami yang lain, ini adalah API eksperimental: Anda perlu meminta akses, dan tidak memiliki tingkat komitmen yang sama untuk dukungan jangka panjang seperti API lainnya.
API ini mirip dengan yang tersedia di Anthropic Workbench, dan dimaksudkan untuk digunakan oleh platform rekayasa prompt dan playground lainnya.
Memulai dengan peningkat prompt
Untuk menggunakan API generasi prompt, Anda perlu:
- Telah bergabung dengan pratinjau penelitian tertutup untuk API alat prompt
- Menggunakan API secara langsung, bukan SDK
- Menambahkan header beta
prompt-tools-2025-04-02
API ini tidak tersedia di SDK
Meningkatkan prompt
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
The prompt to improve, 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
As a simple text prompt:
[
{
"role": "user",
"content": [
{
"type": "text",
"text": "Concise recipe for {{food}}"
}
]
}
]
With example interactions to guide improvement:
[
{
"role": "user",
"content": [
{
"type": "text",
"text": "Concise for {{food}}.\n\nexample\mandu: Put the mandu in the air fryer at 380F for 7 minutes."
}
]
}
]
Note that only contiguous user messages with text content are allowed. Assistant prefill is permitted, but other content types will cause validation errors.
[
{
"content": [
{
"text": "<generated prompt>",
"type": "text"
}
],
"role": "user"
}
]
Feedback for improving the prompt.
Use this parameter to share specific guidance on what aspects of the prompt should be enhanced or modified.
Example:
{
"messages": [...],
"feedback": "Make the recipes shorter"
}
When not set, the API will improve the prompt using general prompt engineering best practices.
"Make it more detailed and include cooking times"
The existing system prompt to incorporate, if any.
{
"system": "You are a professional meal prep chef",
[...]
}
Note that while system prompts typically appear as separate parameters in standard API calls, in the improve_prompt
response, the system content will be incorporated directly into the returned user message.
"You are a professional chef"
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
"claude-3-7-sonnet-20250219"
Response
Contains the result of the prompt improvement process in a list of message
objects.
Includes a user
-role message with the improved prompt text and may optionally include an assistant
-role message with a prefill. These messages follow the standard Messages API format and can be used directly in subsequent API calls.
[
{
"content": [
{
"text": "<improved prompt>",
"type": "text"
}
],
"role": "user"
},
{
"content": [
{
"text": "<assistant prefill>",
"type": "text"
}
],
"role": "assistant"
}
]
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 improving a prompt.
""
Usage information