Run your first evaluation in 5 minutes
Run your first Stratix evaluation end-to-end in five minutes. One Python file, copy-paste-runnable.
Step 1 — Install and authenticate (60 seconds)
pip install layerlens --extra-index-url https://sdk.layerlens.ai/package
export LAYERLENS_STRATIX_API_KEY="sk-..." # macOS / Linux
# PowerShell: $env:LAYERLENS_STRATIX_API_KEY = "sk-..."python -c "import layerlens; print(layerlens.__version__)"Step 2 — The whole thing in one file
"""
first_eval.py — your first end-to-end Stratix evaluation.
Run with: python first_eval.py
Requires: LAYERLENS_STRATIX_API_KEY set in your environment.
"""
from layerlens import Stratix
# 1) Authenticate. The Stratix() constructor reads LAYERLENS_STRATIX_API_KEY
# from the environment. Pass api_key="..." explicitly if you prefer.
client = Stratix()
# 2) Pick a model from the public catalog. get_by_key() is case-sensitive
# and uses the "<provider>/<model>" key shown in the Catalog UI.
model = client.models.get_by_key("anthropic/claude-opus-4-7")
print(f"Model: {model.name}")
# 3) Pick a benchmark. MMLU is a fast, well-known public benchmark — good
# for a smoke test on day one.
benchmark = client.benchmarks.get_by_key("mmlu")
print(f"Benchmark: {benchmark.name}")
# 4) Create the evaluation. The platform queues it; the SDK returns
# immediately with an Evaluation object you can poll.
evaluation = client.evaluations.create(
model=model,
benchmark=benchmark,
)
print(f"Started: {evaluation.id} (status={evaluation.status})")
# 5) Block until the evaluation finishes. wait_for_completion polls every
# interval_seconds and gives up after timeout_seconds. MMLU on Opus 4.7
# typically completes in 2–4 minutes.
evaluation = client.evaluations.wait_for_completion(
evaluation,
interval_seconds=10,
timeout_seconds=600,
)
if not evaluation.is_success:
raise SystemExit(f"Evaluation did not succeed: status={evaluation.status}")
print(f"Done: accuracy={evaluation.accuracy:.3f}")
# 6) Pull per-prompt results. get_all_by_id auto-paginates across pages and
# returns a flat list of Result objects (.prompt,.result,.truth,.score).
results = client.results.get_all_by_id(evaluation.id)
print(f"Rows: {len(results)}")
# 7) Show the first three rows so you can see what real data looks like.
for r in results[:3]:
verdict = "PASS" if r.score and r.score >= 0.5 else "FAIL"
print(f" [{verdict}] {r.prompt[:60]}... score={r.score}")
# 8) Done. The same evaluation now appears in Premium → Evaluations.
print(f"\nView in UI: https://stratix.layerlens.ai/evaluations/{evaluation.id}")Step 3 — Run it
You just did five things
Common failure modes
Where to next
Last updated
Was this helpful?