> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://www.comet.com/docs/opik/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://www.comet.com/docs/opik/_mcp/server.

# Opik Agent Optimizer Core Concepts

> Learn about the core concepts of Opik Agent Optimizer, including key terms, evaluation processes, optimization workflows, and best practices for effective LLM optimization.

## Overview

Understanding the core concepts of the Opik Agent Optimizer is essential for unlocking its full
potential in LLM evaluation and optimization. This section explains the foundational terms,
processes, and strategies that underpin effective agent and prompt optimization within Opik.

## What is Agent Optimization (and Prompt Optimization)?

In Opik, **Agent Optimization** refers to the systematic process of refining and evaluating the
prompts, configurations, and overall design of language model-based applications to maximize their
performance. This is an iterative approach leveraging continuous testing, data-driven refinement,
and advanced evaluation techniques.

**Prompt Optimization** is a crucial subset of Agent Optimization. It focuses specifically on
improving the instructions (prompts) given to Large Language Models (LLMs) to achieve desired
outputs more accurately, consistently, and efficiently. Since prompts are the primary way to
interact with and guide LLMs, optimizing them is fundamental to enhancing any LLM-powered agent or
application.

`Opik Agent Optimizer` provides tools for both: directly optimizing individual prompt strings and
also for optimizing more complex agentic structures that might involve multiple prompts, few-shot
examples, or tool interactions.

## Key Terms

#### Optimizer

A specialized algorithm within the Opik Agent Optimizer SDK designed to enhance prompt effectiveness. Each optimizer
(e.g., [`MetaPromptOptimizer`](/development/optimization-runs/algorithms/metaprompt_optimizer),
[`FewShotBayesianOptimizer`](/development/optimization-runs/algorithms/fewshot_bayesian_optimizer),
[`EvolutionaryOptimizer`](/development/optimization-runs/algorithms/evolutionary_optimizer),
[`HRPO`](/development/optimization-runs/algorithms/hierarchical_adaptive_optimizer))
employs unique strategies and configurable parameters to address specific optimization goals.

#### ChatPrompt

The object to optimize which contains your chat messages with placeholders for variables that change on each example.
See the [API Reference](/development/optimization-runs/advanced/api_reference#chatprompt).

#### Candidate

A concrete prompt (or multi-prompt bundle) produced by an optimizer for evaluation. Candidates are what get scored and compared
during optimization, and each candidate maps to a specific set of messages, parameters, and tool configuration.

#### Metric

An object defining how to measure the performance of a prompt. The metric functions should accept two parameters:

* `dataset_item`: A dictionary with the dataset item keys
* `llm_output`: This will be populated with the LLM response

It should return either a [ScoreResult](https://www.comet.com/docs/opik/python-sdk-reference/Objects/ScoreResult.html) object or a float.

#### Dataset (for Optimization)

A collection of data items, typically with inputs and expected outputs (ground truth), used to guide and evaluate
the prompt optimization process. For best results, split your data into separate training and validation datasets—the optimizer uses the training dataset to analyze failures and generate improvements, then evaluates candidates on the validation dataset to prevent overfitting. See [Datasets](/evaluation/advanced/manage_datasets) and [Define datasets](/development/optimization-runs/optimization/define_datasets) for more information.

#### Optimization Run

A single execution of a prompt optimization process using a specific configuration. For example,
calling `optimizer.optimize_prompt(...)` once constitutes a Run. Each Run is logged as an Optimization Run
in Opik and contains multiple rounds, trials, and candidate evaluations.

#### Optimization Trial

Each optimization run is made up of one or more optimization trials. A trial corresponds to evaluating
a candidate on the chosen dataset slice (full, sampled, or minibatch). You can view each trial's prompt,
score, and reasoning history inside the Opik UI to understand optimizer progress.

#### Optimization Round

A logical iteration within a run where the optimizer proposes one or more candidates, evaluates them,
and uses the results to decide the next candidates. Some optimizers expose rounds explicitly (e.g., evolutionary,
hierarchical), while others operate with a simpler trial-by-trial loop.

#### Prompt model

The model that is used to evaluate the prompt. This is the model that you use the prompt with,
should be the same as the model you use in your application. Configure it via `ChatPrompt(model="provider/model-name")`.

See [Configure LLM Providers](/development/optimization-runs/optimization/configure_models) for setup instructions.

#### Optimizer model

The model that is used to optimize the prompt. This is the model that the optimizer uses to improve your prompt,
you will get the best performance by using the most powerful model for the optimization. Configure it via the optimizer's `model` parameter.

See [Configure LLM Providers](/development/optimization-runs/optimization/configure_models) for setup instructions.

## Next Steps

* Explore specific [Optimizers](/development/optimization-runs/algorithms/overview) for algorithm details.
* Refer to the [FAQ](/development/optimization-runs/faq) for common questions and troubleshooting.
* Refer to the [API Reference](/development/optimization-runs/advanced/api_reference) for detailed configuration options.

📓 Want to see these concepts in action? Check out our [Example Projects & Cookbooks](/development/optimization-runs/cookbooks/optimizer_introduction_cookbook)
for step-by-step, runnable Colab notebooks.