Automate Prompt Management

Build automated prompt management pipelines via the Evals API

Overview

Instead of manually creating and updating prompts on the platform, you can automate prompt management via the Evals API. This allows you to:

  • Push new prompt commits from your codebase or CI/CD pipeline
  • Promote commits to versions programmatically
  • Optionally configure model settings, output type, and tools to track alongside prompts
  • Integrate prompt management into your development workflow

Most of this page focuses on the core use case: tracking prompt changes via commits. Model settings, output types, and other configurations are optional add-ons for teams who want to manage their entire LLM configuration (prompt + model) as a single tracked unit.

If you haven’t already, get familiar with prompt commits and versions on the platform to understand the relationship between prompts, commits, versions, and labels.

Push Prompt Commits

Push a new commit of a prompt to Confident AI. If the prompt alias doesn’t exist, it will be created automatically. Every push creates a new commit that tracks your changes.

For message prompts:

main.py
1from deepeval.prompt import Prompt
2from deepeval.prompt.api import PromptMessage
3
4prompt = Prompt(alias="YOUR-PROMPT-ALIAS")
5prompt.push(
6 messages=[
7 PromptMessage(role="system", content="You are a helpful assistant called {name}."),
8 ]
9)

For text prompts:

main.py
1from deepeval.prompt import Prompt
2
3prompt = Prompt(alias="YOUR-PROMPT-ALIAS")
4prompt.push(text="You are a helpful assistant called {name}.")

You can also specify the interpolation type:

main.py
1from deepeval.prompt import Prompt
2from deepeval.prompt.api import PromptInterpolationType
3
4prompt = Prompt(alias="YOUR-PROMPT-ALIAS")
5prompt.push(
6 text="You are a helpful assistant called {{name}}.",
7 interpolation_type=PromptInterpolationType.MUSTACHE
8)

Each push creates a new commit automatically. When you’re ready to mark a commit as a stable release, you can promote it to a version. Version numbers are controlled by Confident AI in the format 00.00.0X.

Create a Version

When you’re ready to mark a commit as a stable release, you can promote it to a version. Version numbers are automatically assigned by Confident AI in the format 00.00.0X (e.g., 00.00.01, 00.00.02).

main.py
1from deepeval.prompt import Prompt
2
3prompt = Prompt(alias="YOUR-PROMPT-ALIAS")
4
5# Create a version from the latest commit
6
7prompt.create_version()
8
9# Or create a version from a specific commit
10
11prompt.create_version(hash="COMMIT-HASH")

A new version can only be created for commits made after the most recently versioned commit. Commits made before an existing version cannot be promoted to a version.

Once a commit is promoted to a version, you can assign labels (like staging or production) to it. Labels can only exist on versions, not commits.

Adding Model Configs

Model settings, output type, and tools are completely optional. You can track and use prompts without any of these — simply pull the prompt and use it with whatever model you choose in your code. These options are for teams who want to co-locate their model configuration with their prompts.

If you want to manage your model configuration alongside your prompts — tracking the prompt + model together in each commit — you can include model_settings and output_type when pushing.

This is useful when:

  • You want to ensure a specific prompt always runs with a specific model and parameters
  • You’re A/B testing different prompt + model combinations together
  • You want to centralize both prompt and model configuration in one place
main.py
1from deepeval.prompt import Prompt
2from deepeval.prompt.api import (
3 PromptMessage,
4 ModelSettings,
5 ModelProvider,
6 OutputType,
7 ReasoningEffort,
8 Verbosity,
9)
10from pydantic import BaseModel
11
12class ResponseSchema(BaseModel):
13 answer: str
14 confidence: float
15
16prompt = Prompt(alias="YOUR-PROMPT-ALIAS")
17
18# Use with push() to create a new commit
19prompt.push(
20 messages=[
21 PromptMessage(role="system", content="You are a helpful assistant."),
22 ],
23 model_settings=ModelSettings(
24 provider=ModelProvider.OPEN_AI,
25 name="gpt-4o",
26 temperature=0.7,
27 max_tokens=1000,
28 top_p=0.9,
29 frequency_penalty=0.1,
30 presence_penalty=0.1,
31 stop_sequence=["END"],
32 reasoning_effort=ReasoningEffort.MINIMAL,
33 verbosity=Verbosity.LOW,
34 ),
35 output_type=OutputType.SCHEMA,
36 output_schema=ResponseSchema,
37)

Reference

Model settings

Model settings include the provider, model name, and model parameters:

FieldTypeDefaultDescription
providerModelProviderOPEN_AIThe model provider (see supported providers below)
namestrNoneThe model name (e.g., “gpt-4o”, “claude-3-opus”)

Parameters

Here are all the available parameters you could set:

FieldTypeDefaultDescription
temperaturefloat0Controls randomness (0-2)
max_tokensintNoneMaximum tokens in the response
top_pfloat1Nucleus sampling parameter
frequency_penaltyfloat0Penalize repeated tokens (-2 to 2)
presence_penaltyfloat0Penalize tokens based on presence (-2 to 2)
stop_sequenceList[str][]Sequences that stop generation
reasoning_effortReasoningEffortMEDIUMReasoning effort level (MINIMAL, LOW, MEDIUM, HIGH)
verbosityVerbosityMEDIUMOutput verbosity (LOW, MEDIUM, HIGH)

Only include parameters that are valid for your chosen model provider and model name. For example, reasoning_effort may only apply to certain OpenAI models, while other parameters may not be supported by all providers. Confident AI does not exhaustively validate which parameter combinations are allowed — invalid configurations may result in runtime errors when using the prompt in your code.

Providers

Here are the list of available model providers:

ProviderDescription
OPEN_AIOpenAI (GPT-4, GPT-4o, etc.)
ANTHROPICAnthropic (Claude models)
GEMINIGoogle Gemini
VERTEX_AIGoogle Vertex AI
BEDROCKAmazon Bedrock
AZUREAzure OpenAI
MISTRALMistral AI
DEEPSEEKDeepSeek
X_AIxAI (Grok)
MOONSHOT_AIMoonshot AI
PERPLEXITYPerplexity
PORTKEYPortkey (gateway)
LITE_LLMLiteLLM (gateway)

Output configurations

You can also configure structured outputs:

FieldTypeDefaultDescription
output_typeOutputTypeTEXTOutput format (TEXT, JSON, or SCHEMA)
output_schemaBaseModelNonePydantic model for structured output (when output_type is SCHEMA)

Output Types:

  • TEXT - Plain text output
  • JSON - JSON formatted output
  • SCHEMA - Structured output validated against a Pydantic schema

Interpolation types

Specify how variables are interpolated in your prompts:

TypeSyntaxExample
FSTRING{variable}Hello, {name}!
MUSTACHE{{variable}}Hello, {{name}}!
MUSTACHE_WITH_SPACE{{ variable }}Hello, {{ name }}!
DOLLAR_BRACKETS${variable}Hello, ${name}!
JINJA{% ... %}{% if admin %}Hello!{% endif %}

What about Tools?

You can create and update tools using prompts by pushing prompts with tools. Tools in Confident AI are identified using their names — passing a tool with a new name creates a tool and passing a tool with an existing name updates the tool on the platform. Each push creates a new commit that tracks the tool configuration. Here’s how you can create / update tools:

1from deepeval.prompt import Prompt, Tool
2from deepeval.prompt.api import ToolMode
3from pydantic import BaseModel
4
5class ToolInputSchema(BaseModel):
6 result: str
7 confidence: float
8
9prompt = Prompt(alias="YOUR-PROMPT-ALIAS")
10tool = Tool(
11 name="SearchTool",
12 description="Search functionality",
13 mode=ToolMode.STRICT,
14 structured_schema=ToolInputSchema,
15)
16
17# Use with push() to create a new commit with the tool
18prompt.push(
19 text="This a prompt for a tool using agent",
20 tools=[tool]
21)
22
23tool_2 = Tool(
24 name="SearchTool",
25 description="New search functionality",
26 mode=ToolMode.STRICT,
27 structured_schema=ToolInputSchema,
28)
29
30# Create a new commit with the new updated tool using 'push'
31prompt.push(
32 text="This a prompt for a tool using agent",
33 tools=[tool_2]
34)

Prompts in CI/CD

Automate prompt tracking as part of your CI/CD pipeline. A common pattern is to push prompt commits whenever your prompt files change:

prompts-ci.yml
1name: Push Prompt Commits
2
3on:
4 push:
5 paths:
6 - "prompts/**"
7
8jobs:
9 push-prompts:
10 runs-on: ubuntu-latest
11 steps:
12 - uses: actions/checkout@v3
13
14 - name: Set up Python
15 uses: actions/setup-python@v4
16 with:
17 python-version: "3.11"
18
19 - name: Install dependencies
20 run: pip install deepeval
21
22 - name: Push prompts
23 env:
24 CONFIDENT_API_KEY: ${{ secrets.CONFIDENT_API_KEY }}
25 run: python scripts/push_prompts.py

Your push_prompts.py script can read prompt files and push them:

scripts/push_prompts.py
1from deepeval.prompt import Prompt
2
3# Read your prompt content from file or config
4with open("prompts/assistant.txt") as f:
5 prompt_text = f.read()
6
7prompt = Prompt(alias="assistant-prompt")
8prompt.push(text=prompt_text)
9
10print("Prompt commit pushed successfully!")

Combine automated prompt pushing with prompt labeling to control which versions are deployed to different environments (e.g., staging, production). Remember that labels can only be assigned to versions, so you’ll need to promote commits to versions before labeling them.

Next Steps

Now that you can push prompts programmatically, learn how to pull them into your app for usage.