diff --git a/src/content/docs/ai-gateway/prompt-management/index.mdx b/src/content/docs/ai-gateway/prompt-management/index.mdx new file mode 100644 index 000000000000000..88157d70c832c4f --- /dev/null +++ b/src/content/docs/ai-gateway/prompt-management/index.mdx @@ -0,0 +1,22 @@ +--- +title: Prompt Management +pcx_content_type: navigation +order: 1 +sidebar: + order: 8 + group: + badge: Beta +--- + +Effective communication with AI models hinges on well-crafted prompts. Even small changes in wording or structure can influence model responses and impact performance. + +This process of refining prompts, known as prompt engineering, is essential to producing correct outputs. It involves providing clear instructions, iterative testing, and analyzing model responses to check prompt performance. This is where prompt management comes in. + +Prompt Management feature simplifies the process of creating, editing, and testing prompts, ensuring that your AI applications perform at their best. You can: + +- Create, manage, and version prompts across your gateways. +- Keep track of changes and who made them. +- Store and deploy prompts without hard-coding them into applications. +- Evaluate prompt performance using [AI Gateway's Evaluations](/ai-gateway/evaluations/), including speed, cost, and performance. + +[Learn how to create and manage prompts](/ai-gateway/prompt-management/prompt-management/) next. diff --git a/src/content/docs/ai-gateway/prompt-management/prompt-management.mdx b/src/content/docs/ai-gateway/prompt-management/prompt-management.mdx new file mode 100644 index 000000000000000..74d76a9d4ade53f --- /dev/null +++ b/src/content/docs/ai-gateway/prompt-management/prompt-management.mdx @@ -0,0 +1,79 @@ +--- +pcx_content_type: configuration +title: Set up Prompts +sidebar: + order: 8 +--- + +## How to create a prompt + +Creating prompts in AI Gateway is done via the Cloudflare Dashboard. + +### Using the Dashboard: + +1. Log into the [Cloudflare dashboard](https://dash.cloudflare.com/) and select your account. + +2. Go to the **Prompts** tab. + +3. Create a new prompt: + + - Click on the **New Prompt** button. + - Provide the following details: + - Prompt name: A unique name to identify the prompt. + - Prompt copy: The instructions or text for the AI model. + - Tags: (Optional) Add tags to organize and search prompts easily. + +4. Save the Prompt: + + - Click **Create Prompt** to store your prompt. + + :::note[Note] + + Creating a new prompt will also generate a new prompt version. By default, this new version will be set as the active version and used to process requests made to the Gateway. + + ::: + +5. Copy the code snippet: + - After saving, a code snippet will be available: + +``` +curl https://gateway.ai.cloudflare.com/v1/0d37909e38d3e99c29fa2cd343ac421a/{gateway_id}/workers-ai/@cf/meta/llama-3.1-8b-instruct \ + --header 'Authorization: Bearer {cf_api_token}' \ + --header 'Content-Type: application/json' \ + --data '{"prompt": ""}' +``` + +- Test this prompt by sending the cURL request or copying the snippet to add directly to your code. + +5. Prompt ID: + - Here is an example of the prompt ID generated: + +``` + +``` + +6. Confirmation: + - A success page will confirm that your prompt has been created. + +## Managing Prompt versions + +AI Gateway allows you to maintain prompt versions to test changes and roll back if needed. + +1. Create a new version: + + - Make changes to an existing prompt (for example tweak wording). + - Save the changes as a new version. + - By default, the newly saved version will become the active version. + +2. Track versions: + + - The dashboard shows all versions, indicating which is active and which are older. + - Compare versions to see changes and their impact by ticking the `show diff` box. + +3. Version control benefits: + + - Easily roll back to a previous version if a new prompt doesn't perform well. + +4. Search and tagging: + +- Quickly find prompts by searching names or filtering by tags.