> For the complete documentation index, see [llms.txt](https://docs.layerlens.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.layerlens.ai/more-in-this-section-9/judges-2.md).

# Judges

## Create

`name` and `evaluation_goal` are required. `model_id` is optional — if omitted, a default judging model is used.

```python
from layerlens import Stratix

client = Stratix()

# Optionally fetch a model to use as the judge's LLM
models = client.models.get(type="public", name="gpt-4o")
model = models[0]

judge = client.judges.create(
 name="Code Quality Judge",
 evaluation_goal="Evaluate the quality of code output including correctness, readability, and style",
 model_id=model.id,
)
print(f"Created judge {judge.id}: {judge.name}")
```

## Get

```python
judge = client.judges.get(judge_id)
print(f"Judge: {judge.name}, version: {judge.version}")
```

## List

`get_many()` returns a `JudgesResponse` with `.judges`, `.total_count`:

```python
response = client.judges.get_many()
print(f"Found {response.total_count} judges")
for j in response.judges:
 print(f" - {j.name} (v{j.version}, {j.run_count} runs)")
```

## Update — creates a new version

Updating a judge **creates a new version**. The prior version remains accessible for already-attached evaluations:

```python
updated = client.judges.update(
 judge.id,
 name="Updated Code Quality Judge",
 evaluation_goal="Evaluate code output for correctness, readability, style, and security",
)
print(f"Updated judge {updated.id}, version {updated.version}")
```

## Delete

```python
deleted = client.judges.delete(judge.id)
print(f"Deleted judge {deleted.id}")
```

## Async

```python
from layerlens import AsyncStratix

async def example():
 client = AsyncStratix()
 judge = await client.judges.create(name="...", evaluation_goal="...")
 response = await client.judges.get_many()
```

## Versioning model

* Each `update()` call creates a new `JudgeVersion` linked to the parent judge
* The judge's `.version` field reflects the latest version
* Already-running evaluations stay pinned to the version they started with
* Use `JudgeSnapshot` for point-in-time references in audit trails

## Source samples

| Sample                                    | What it shows                                      |
| ----------------------------------------- | -------------------------------------------------- |
| `samples/core/create_judge.py`            | Full CRUD lifecycle                                |
| `samples/core/judge_creation_and_test.py` | Build a custom PII detection judge with validation |
| `samples/core/judge_optimization.py`      | Estimate, run, apply judge optimizations           |
| `samples/core/trace_evaluation.py`        | Apply judge to traces                              |
| `samples/industry/healthcare_clinical.py` | Domain-tuned clinical judge                        |

## See also

* [Concept: Judges](/more-in-this-section-9/judges-2.md)
* [Judge optimizations (GEPA)](/more-in-this-section-9/judge-optimizations-1.md)
* [Tutorial 2: Build your first judge](/8.-evaluate-score-the-outputs/02-first-judge.md)
* [Bootstrap a judge before GEPA](/more-in-this-section-6/bootstrap-judges.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.layerlens.ai/more-in-this-section-9/judges-2.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
