> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eigenpal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Optimize cost

> Fix the quality bar with evaluations, then pick the cheapest model configuration that still passes.

Once [evaluations](/concepts/evals) define what correct means, cost becomes a
search problem instead of a guess. The quality bar is fixed, so you can try
cheaper configurations and keep any that still pass. The goal is not the most
capable model; it is the cheapest one that does the job.

## Why model choice is the cost lever

A workflow's cost is mostly its model choices: the OCR engine and the language
model each step uses. Those are configuration, not code, so they are easy to
change. Evaluations tell you whether a change broke anything.

```mermaid theme={null}
flowchart TD
    A[Define the quality bar with evaluators] --> B[Try a cheaper configuration<br/>cheaper OCR or smaller model]
    B --> C[Run the experiment over the dataset]
    C --> D{Still passes the threshold?}
    D -->|Yes| E[Keep the configuration]
    D -->|No| F[Revert and try another]
    F --> B
```

## Swap a model and re-run

Change the model on the relevant step, push a new version, and run the
experiment. If the score still clears the threshold, you lowered cost with
no loss of reliability.

```bash theme={null}
# in workflow.yaml, set a cheaper model on the step, e.g. ai.parse / ai.extract
eigenpal workflow push
eigenpal workflow experiment run <workflow-id> --wait
eigenpal workflow experiment compare <expensiveBatchId> <cheapBatchId>
```

`compare` shows you exactly which examples moved, so a small quality drop on a
non-critical field is a deliberate decision rather than a surprise.

## Re-run the search when prices change

Prices change and new models ship. Because the evaluations are permanent, you
can re-run this search whenever that happens and re-pick the cheapest passing
configuration. Operating cost stays at the minimum required to hold the agreed
quality level, without anyone re-checking outputs by hand.
