# Introduction Source: https://docs.zeroeval.com/autotune/introduction Run evaluations on models and prompts to find the best variants for your agents Autotune is a different approach to the traditional evals experience. Instead of setting up complex eval pipelines, we simply ingest your production traces and let you replay them with different models and generate optimized prompts based on your feedback. Some of the key features include: * **Content-based versioning**: Each unique prompt content gets its own version via SHA-256 hashing * **Variable templating**: Use `{{variable}}` syntax for dynamic content * **Automatic tracking**: All interactions are traced for analysis * **One-click model deployments**: Models update instantly without code changes ## How it works Replace hardcoded prompts with `ze.prompt()` calls Each time you modify your prompt content, a new version is automatically created and tracked ZeroEval automatically tracks all LLM interactions and their outcomes Use the UI to run experiments, vote on outputs, and identify the best prompt/model combinations Winning configurations are automatically deployed to your application without code changes Learn how to integrate ze.prompt() into your codebase Run experiments and deploy winning combinations # Reference Source: https://docs.zeroeval.com/autotune/reference Parameters and configuration for ze.prompt `ze.prompt` creates or fetches versioned prompts from the Prompt Library and returns decorated content for downstream LLM calls. ## Parameters | Parameter | Type | Required | Default | Description | | ----------- | -------------- | -------- | ------- | ----------------------------------------------------------------------------------------- | | `name` | string | yes | — | Task name associated with the prompt in the library | | `content` | string | no | `None` | Raw prompt content to ensure/create a version by content | | `from_` | string | no | `None` | Either `"latest"` or a 64‑char lowercase SHA‑256 content hash to fetch a specific version | | `from` | string (alias) | no | `None` | Alias for `from_` (keyword‑only) | | `variables` | dict | no | `None` | Template variables to render `{{variable}}` tokens in content | Notes: * Exactly one of `content` or `from_/from` must be provided. * `from="latest"` fetches the latest version bound to the task; otherwise `from_` must be a 64‑char hex SHA‑256 hash. ## Behavior * **content provided**: Computes a normalized SHA‑256 hash, ensures a prompt version exists for `name`, and returns decorated content. * **from="latest"**: Fetches the latest version for `name` and returns decorated content. * **from=**``: Fetches by content hash for `name` and returns decorated content. Decoration adds a compact metadata header used by integrations: * `task`, `prompt_slug`, `prompt_version`, `prompt_version_id`, `variables`, and (when created by content) `content_hash`. OpenAI integration: when `prompt_version_id` is present, the SDK will automatically patch the `model` parameter to the model bound to that prompt version. ## Return Value * `str`: Decorated prompt content ready to pass into LLM clients. ## Errors | Error | When | | --------------------- | ------------------------------------------------------------------------------------------------ | | `ValueError` | Both `content` and `from_` provided, or neither; invalid `from_` (not `"latest"` or 64‑char hex) | | `PromptRequestError` | `from_="latest"` but no versions exist for `name` | | `PromptNotFoundError` | `from_` is a hash that does not exist for `name` | ## Examples ```python import zeroeval as ze # Create/ensure a version by content system = ze.prompt( name="support-triage", content="You are a helpful assistant for {{product}}.", variables={"product": "Acme"}, ) # Fetch the latest version for this task system = ze.prompt(name="support-triage", from_="latest") # Fetch a specific version by content hash system = ze.prompt(name="support-triage", from_="c6a7...deadbeef...0123") ``` # Setup Source: https://docs.zeroeval.com/autotune/setup Getting started with autotune ZeroEval's autotune feature allows you to continuously improve your prompts and automatically deploy the best-performing models. The setup is simple and powerful. Setup ## Getting started (\<5 mins) Replace hardcoded prompts with `ze.prompt()` and include the name of the specific part of your agent that you want to tune. ```python # Before prompt = "You are a helpful assistant" # After - with autotune prompt = ze.prompt( name="assistant", content="You are a helpful assistant" ) ``` That's it! You'll start seeing production traces in your dashboard for this specific task at [`ZeroEval › Tuning › [task_name]`](https://app.zeroeval.com). ## Pushing models to production Once you see a model that performs well, you can send it to production with a single click, as seen below. Model deployment Your specified model gets replaced automatically any time you use the prompt from `ze.prompt()`, as seen below. ```python # You write this response = client.chat.completions.create( model="gpt-4", # ← Gets replaced! messages=[{"role": "system", "content": prompt}] ) ``` ## Example Here's autotune in action for a simple customer support bot: ```python import zeroeval as ze from openai import OpenAI ze.init() client = OpenAI() # Define your prompt with version tracking system_prompt = ze.prompt( name="support-bot", content="""You are a customer support agent for {{company}}. Be helpful, concise, and professional.""", variables={"company": "TechCorp"} ) # Use it normally - model gets patched automatically response = client.chat.completions.create( model="gpt-4", # This might run claude-3-sonnet in production! messages=[ {"role": "system", "content": system_prompt}, {"role": "user", "content": "I need help with my order"} ] ) ``` ## Understanding Prompt Versions Every time you change your prompt content, a new version is created: ```python # Version 1 - Initial prompt prompt_v1 = ze.prompt( name="customer-support", content="You are a helpful assistant." ) # Version 2 - Updated prompt (automatically creates new version) prompt_v2 = ze.prompt( name="customer-support", content="You are a helpful customer support assistant." # Changed! ) # Fetch specific versions by hash latest_prompt = ze.prompt( name="customer-support", from="latest" # Always get the latest tuned version ) # Or fetch a specific version by its content hash specific_prompt = ze.prompt( name="customer-support", from="a1b2c3d4..." # 64-character SHA-256 hash ) ``` # Models Source: https://docs.zeroeval.com/autotune/tuning/models Evaluate your agent's performance across multiple models