# Samples (70+ runnable)

The LayerLens Python SDK ships with **70+ runnable samples** covering every public resource — from a single trace evaluation to multi-agent evaluation patterns and CI/CD quality gates. All samples live in [`stratix-python/samples/`](https://github.com/layerlens/stratix-python/tree/main/samples) and run directly after installing the SDK.

## Quick start

```bash
pip install layerlens --extra-index-url https://sdk.layerlens.ai/package
export LAYERLENS_STRATIX_API_KEY=your-api-key
python samples/core/quickstart.py
```

[`quickstart.py`](https://github.com/layerlens/stratix-python/blob/main/samples/core/quickstart.py) walks through the complete workflow end-to-end: upload a trace, create a judge, run an evaluation, and retrieve results.

## Samples by category

Each category groups samples around a specific Stratix capability or integration surface. Pick the category closest to what you're building.

| Category                                                | What's in it                                                                                                                                                          | Count         |
| ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
| [Core SDK operations](#core-sdk-operations)             | Every public resource — traces, judges, evaluations, results, models, benchmarks — used individually and together, including async patterns and pagination            | 18            |
| [Industry solutions](#industry-solutions)               | Domain-specific evaluation scenarios with judges tuned for regulated and high-stakes verticals (healthcare, financial services, legal, government, insurance, retail) | 10            |
| [Multi-agent evaluation](#multi-agent-evaluation)       | Patterns for evaluating multi-agent collaboration where each agent's output needs independent quality assessment                                                      | 5             |
| [Content-type evaluations](#content-type-evaluations)   | Specialized judges applied to different content types — text responses, brand assets, structured documents                                                            | 3             |
| [CI/CD integration](#cicd-integration)                  | Quality gates that embed evaluation into build and deployment pipelines so regressions never reach production                                                         | 2 + workflow  |
| [LLM provider integrations](#llm-provider-integrations) | Trace and evaluate outputs from OpenAI and Anthropic — both manual trace upload and auto-instrumentation paths                                                        | 4             |
| [OpenClaw agent evaluation](#openclaw-agent-evaluation) | Trace, evaluate, and monitor [OpenClaw](https://openclaw.ai/) autonomous AI agents — cage-match tournaments, code gating, drift detection, content auditing           | 10 + skill    |
| [MCP server](#mcp-server)                               | Expose Stratix capabilities as tools for Claude, Cursor, and any MCP-compatible AI assistant                                                                          | 1             |
| [CopilotKit integration](#copilotkit-integration)       | Full-stack pattern with LangGraph CoAgents + generative-UI cards for human-in-the-loop evaluation workflows                                                           | 2 agents + UI |
| [Claude Code skills](#claude-code-skills)               | Slash commands that bring Stratix workflows into the Claude Code CLI                                                                                                  | 6             |
| [Sample data](#sample-data)                             | Pre-built trace files and 16 industry-specific evaluation datasets so every sample runs without sourcing your own data                                                | n/a           |

***

## Core SDK operations

Located in [`samples/core/`](https://github.com/layerlens/stratix-python/tree/main/samples/core). Start here to learn how every public Stratix resource works, individually and combined.

Key samples:

* `quickstart.py` — first evaluation in under 30 lines
* `trace_evaluation.py` — full trace-evaluation lifecycle
* `judge_optimization.py` — optimize a judge via automated prompt evolution (GEPA)
* `evaluation_pipeline.py` — chain judges, traces, and results into an automated pipeline
* `async_workflow.py` — concurrent operations with `AsyncStratix`

See the [Core SDK README](https://github.com/layerlens/stratix-python/blob/main/samples/core/README.md). Maps to gitbook: [Tutorials](/2.-get-started/all-tutorials.md) · [Concept: Evaluations](https://github.com/LayerLens/gitbook-full/blob/main/13-reference/sdk-python/evaluations.md).

## Industry solutions

Located in [`samples/industry/`](https://github.com/layerlens/stratix-python/tree/main/samples/industry). Domain-specific scenarios with judges and scoring configurations tuned for regulated and high-stakes verticals.

Key samples:

* `healthcare_clinical.py` — clinical decision support evaluation
* `financial_trading.py` — SOX-aligned trading compliance
* `legal_contracts.py` — contract review quality assessment

See the [Industry Solutions README](https://github.com/layerlens/stratix-python/blob/main/samples/industry/README.md). Maps to gitbook: [Industry patterns](/6.-build-wire-your-code/sdk-python.md).

## Multi-agent evaluation

Located in [`samples/cowork/`](https://github.com/layerlens/stratix-python/tree/main/samples/cowork). Patterns for evaluating multi-agent collaboration — applicable to any framework where multiple agents produce intermediate outputs that need independent quality assessment.

Key samples:

* `multi_agent_eval.py` — Generator-Evaluator pattern
* `code_review.py` — Instrumentor-Reviewer pattern
* `rag_assessment.py` — RAG-quality evaluation

See the [Multi-Agent README](https://github.com/layerlens/stratix-python/blob/main/samples/cowork/README.md). Maps to gitbook: [Concept: Agentic evaluation](/8.-evaluate-score-the-outputs/agentic-evaluation.md).

## Content-type evaluations

Located in [`samples/modalities/`](https://github.com/layerlens/stratix-python/tree/main/samples/modalities). Specialized judges applied to different content types.

* `text_evaluation.py` — score text across safety, relevance, and compliance
* `brand_evaluation.py` — enforce brand-voice consistency
* `document_evaluation.py` — validate document-extraction accuracy

## CI/CD integration

Located in [`samples/cicd/`](https://github.com/layerlens/stratix-python/tree/main/samples/cicd). Embed evaluation quality gates into build and deployment pipelines.

* `quality_gate.py` — gate deployments on evaluation pass rates
* `pre_commit_hook.py` — catch regressions at commit time
* `github_actions_gate.yml` — drop-in GitHub Actions workflow

See the [CI/CD README](https://github.com/layerlens/stratix-python/blob/main/samples/cicd/README.md). Maps to gitbook: [Tutorial 3: CI/CD gates](/6.-build-wire-your-code/03-cicd-gates.md) · [Cookbook: containerized CI](/6.-build-wire-your-code/containerized-ci.md).

## LLM provider integrations

Located in [`samples/integrations/`](https://github.com/layerlens/stratix-python/tree/main/samples/integrations). Two paths: manual trace upload for full control, and auto-instrumentation via `layerlens.instrument` for zero-code observability.

* `openai_traced.py` — manual trace upload around an OpenAI completion
* `anthropic_traced.py` — capture multi-turn Claude conversations (manual trace upload)
* `openai_instrumented.py` — auto-instrument OpenAI with `instrument_openai()`, `@trace`, `span()`
* `langchain_instrumented.py` — auto-capture LangChain chain execution with `LangChainCallbackHandler`

Maps to gitbook: [Integrations](/6.-build-wire-your-code/sdk-python.md).

## OpenClaw agent evaluation

Located in [`samples/openclaw/`](https://github.com/layerlens/stratix-python/tree/main/samples/openclaw). Trace, evaluate, and monitor [OpenClaw](https://openclaw.ai/) autonomous AI agents — including cage-match model tournaments, code gating, drift detection, content auditing, honeypot-skill auditing, and adversarial red-teaming.

See the [OpenClaw README](https://github.com/layerlens/stratix-python/blob/main/samples/openclaw/README.md) for the full list and advanced evaluation patterns.

## MCP server

Located in [`samples/mcp/`](https://github.com/layerlens/stratix-python/tree/main/samples/mcp). Expose Stratix capabilities as tools for Claude, Cursor, and any MCP-compatible AI assistant.

* `layerlens_server.py` — MCP server exposing trace management, judge creation, and evaluation execution

See the [MCP README](https://github.com/layerlens/stratix-python/blob/main/samples/mcp/README.md) for setup.

## CopilotKit integration

Located in [`samples/copilotkit/`](https://github.com/layerlens/stratix-python/tree/main/samples/copilotkit). Full-stack pattern combining LangGraph CoAgents (Python) with generative-UI card components (React) for human-in-the-loop evaluation workflows.

* `agents/evaluator_agent.py` — LangGraph CoAgent for evaluation workflows (uses `interrupt()` for human-in-the-loop judge confirmation)
* `agents/investigator_agent.py` — LangGraph CoAgent for trace investigation
* `components/*.tsx` — React card components for rendering results (`EvaluationCard`, `JudgeVerdictCard`, `TraceCard`, `MetricCard`, `ComplianceCard`)
* `hooks/*.ts` — CopilotKit hooks for wiring Stratix actions (`useLayerLensActions`, `useLayerLensContext`)

> **Checkpointer note:** any LangGraph CoAgent that calls `interrupt()` (such as `evaluator_agent.py`) **must** be compiled with a checkpointer. Without one, the AG-UI stream ends without emitting `RUN_FINISHED` and CopilotKit blocks all subsequent messages. The sample ships with `InMemorySaver` for a zero-setup local run; the [README](https://github.com/layerlens/stratix-python/blob/main/samples/copilotkit/README.md) documents Postgres / SQLite / Redis / LangGraph Platform alternatives for production.

See the [CopilotKit README](https://github.com/layerlens/stratix-python/blob/main/samples/copilotkit/README.md) for setup, full file list, and the human-in-the-loop walkthrough.

## Claude Code skills

Located in [`samples/claude-code/`](https://github.com/layerlens/stratix-python/tree/main/samples/claude-code). Slash commands that bring Stratix workflows directly into the Claude Code CLI — manage traces, judges, evaluations, optimizations, benchmarks, and investigations without leaving your terminal.

`/trace`, `/judge`, `/evaluate`, `/optimize`, `/benchmark`, `/investigate`. See the [Claude Code Skills README](https://github.com/layerlens/stratix-python/blob/main/samples/claude-code/README.md).

## Sample data

Located in [`samples/data/`](https://github.com/layerlens/stratix-python/tree/main/samples/data). Pre-built trace files, test datasets, and 16 industry-specific evaluation datasets so every sample runs without you sourcing your own data first.

See the [Sample Data README](https://github.com/layerlens/stratix-python/blob/main/samples/data/README.md) for contents.

***

## Full sample reference

For the complete table of every sample with descriptions, see the [samples README in the SDK repo](https://github.com/layerlens/stratix-python/blob/main/samples/README.md).

## Where to next

* [SDK README](/6.-build-wire-your-code/sdk-python.md) — full resource list
* [Cookbook](/2.-get-started/all-cookbook-recipes.md) — recipes drawn from these samples
* [Integrations](/6.-build-wire-your-code/sdk-python.md) — full adapter list
* [Tutorials](/2.-get-started/all-tutorials.md) — guided walkthroughs anchored to these samples


---

# 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/2.-get-started/samples-overview.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.
