# MetaPrompt Optimizer

> Learn how to use the MetaPrompt Optimizer to refine and improve your LLM prompts through systematic analysis and iterative refinement.

The MetaPrompter is a specialized optimizer designed for meta-prompt optimization. It focuses on
improving the structure and effectiveness of prompts through systematic analysis and refinement of
prompt templates, instructions, and examples.

<Note>
  The `MetaPromptOptimizer` is a strong choice when you have an initial instruction prompt and want to
  iteratively refine its wording, structure, and clarity using LLM-driven suggestions. It excels at
  general-purpose prompt improvement where the core idea of your prompt is sound but could be
  phrased better for the LLM, or when you want to explore variations suggested by a reasoning model.
</Note>

## How it works

The `MetaPromptOptimizer` automates the process of prompt refinement by using a "reasoning" LLM to
critique and improve your initial prompt. Here's a conceptual breakdown:

<Frame>
  <img src="https://files.buildwithfern.com/https://opik.docs.buildwithfern.com/docs/opik/2026-01-30T17:33:07.444Z/img/agent_optimization/metaprompt_optimizer.png" alt="MetaPrompt Optimizer" />
</Frame>

<Tip>
  The optimizer is open-source, you can check out the code in the
  [Opik repository](https://github.com/comet-ml/opik/tree/main/sdks/opik_optimizer/src/opik_optimizer/algorithms/meta_prompt_optimizer).
</Tip>

## Quickstart

You can use the `MetaPromptOptimizer` to optimize a prompt by following these steps:

```python maxLines=1000
from opik_optimizer import MetaPromptOptimizer
from opik.evaluation.metrics import LevenshteinRatio
from opik_optimizer import datasets, ChatPrompt