# GEPA basics

Canonical sample: [`samples/core/judge_optimization.py`](https://github.com/layerlens/stratix-python/blob/main/samples/core/judge_optimization.py) — estimate, run, and apply judge optimizations.

## SDK pattern

```python
# Estimate cost first
estimate = client.judge_optimizations.estimate(judge_id=judge.id, budget="medium")

# Start optimization (async)
optimization = client.judge_optimizations.create(judge_id=judge.id, budget="medium")

# Poll until done
while True:
 optimization = client.judge_optimizations.get(optimization.id)
 if optimization.status.value in ("success", "failure"):
 break

# Apply on success — creates a new judge version
if optimization.status.value == "success":
 client.judge_optimizations.apply(optimization.id)
```

Budget levels: `"light"`, `"medium"` (default), `"heavy"`. See [Bootstrap a judge before GEPA](https://github.com/LayerLens/gitbook-full/blob/main/08-evaluate/guides/bootstrap-judges.md) for the week-1 setup.

## See also

* [Tutorial 5: GEPA optimize](/9.-improve-tune-the-system/05-gepa-optimize.md)
* [Concept: Judges](/8.-evaluate-score-the-outputs/judges-1.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.layerlens.ai/9.-improve-tune-the-system/gepa-basics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
