# Opik Agent Optimizer API Reference

> Technical SDK reference guide

The Opik Agent Optimizer SDK provides a comprehensive set of tools for optimizing LLM prompts and agents. This reference guide documents the standardized API that all optimizers follow, ensuring consistency and interoperability across different optimization algorithms.

## Key Features

* **Standardized API**: All optimizers follow the same interface for `optimize_prompt()` methods
* **Multiple Algorithms**: Support for various optimization strategies including evolutionary, few-shot, meta-prompt, and GEPA
* **MCP Support**: Built-in support for Model Context Protocol tool calling
* **Consistent Results**: All optimizers return standardized `OptimizationResult` objects
* **Counter Tracking**: Built-in LLM and tool call counters for monitoring usage
* **Backward Compatibility**: All original parameters preserved through kwargs extraction
* **Deprecation Warnings**: Clear warnings for deprecated parameters with migration guidance

## Core Classes

The SDK provides several optimizer classes that all inherit from `BaseOptimizer` and implement the same standardized interface:

* **ParameterOptimizer**: Optimizes LLM call parameters (temperature, top\_p, etc.) using Bayesian optimization
* **FewShotBayesianOptimizer**: Uses few-shot learning with Bayesian optimization
* **MetaPromptOptimizer**: Employs meta-prompting techniques for optimization
* **EvolutionaryOptimizer**: Uses genetic algorithms for prompt evolution
* **GepaOptimizer**: Leverages GEPA (Genetic-Pareto) optimization approach
* **HRPO (Hierarchical Reflective Prompt Optimizer)**: Uses hierarchical root cause analysis for targeted prompt refinement

## Standardized Method Signatures

All optimizers implement these core methods with identical signatures:

### optimize\_prompt()

```python
def optimize_prompt(
    self,
    prompt: ChatPrompt | dict[str, ChatPrompt],
    dataset: Dataset,
    metric: MetricFunction,
    agent: OptimizableAgent | None = None,
    experiment_config: dict | None = None,
    n_samples: int | None = None,
    auto_continue: bool = False,
    project_name: str | None = None,
    optimization_id: str | None = None,
    validation_dataset: Dataset | None = None,
    max_trials: int = 10,
    allow_tool_use: bool = True,
    **kwargs: Any,
) -> OptimizationResult
```

## Deprecation Warnings

The following parameters are deprecated and will be removed in future versions:

### Constructor Parameters

* **`num_threads`** in optimizer constructors: Use `n_threads` instead

### Example Migration

```python