evalrouter 0.3.23__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. evalrouter-0.4.0/PKG-INFO +406 -0
  2. evalrouter-0.4.0/README.md +370 -0
  3. {evalrouter-0.3.23 → evalrouter-0.4.0}/pyproject.toml +4 -2
  4. evalrouter-0.4.0/src/evalrouter/__init__.py +26 -0
  5. evalrouter-0.4.0/src/evalrouter/__main__.py +6 -0
  6. evalrouter-0.4.0/src/evalrouter/langsmith.py +18 -0
  7. evalrouter-0.4.0/src/evalrouter/tracing.py +5 -0
  8. evalrouter-0.4.0/src/evalrouter/types.py +9 -0
  9. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/evalrouter_contracts/__init__.py +1 -1
  10. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/__init__.py +57 -7
  11. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_account.py +7 -8
  12. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_boundary.py +49 -6
  13. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_comparison.py +198 -3
  14. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_comparison_html.py +45 -10
  15. evalrouter-0.4.0/src/kimpton_evalrouter/_environment_publishing.py +136 -0
  16. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_group_review.py +6 -1
  17. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_groups.py +448 -19
  18. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_guided.py +196 -87
  19. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_listing.py +44 -3
  20. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_reasoning_controls.py +28 -19
  21. evalrouter-0.4.0/src/kimpton_evalrouter/_report_brand.py +15 -0
  22. evalrouter-0.4.0/src/kimpton_evalrouter/_report_document_html.py +317 -0
  23. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_report_theme.py +1 -1
  24. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_resources.py +842 -0
  25. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_transport.py +38 -9
  26. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_tui.py +51 -19
  27. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_tui_session.py +102 -35
  28. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_tui_views.py +36 -3
  29. evalrouter-0.4.0/src/kimpton_evalrouter/_tune.py +178 -0
  30. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_update_notice.py +137 -2
  31. evalrouter-0.4.0/src/kimpton_evalrouter/_web_routes.py +69 -0
  32. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/cli.py +292 -46
  33. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/langsmith.py +317 -39
  34. evalrouter-0.4.0/src/kimpton_evalrouter/py.typed +0 -0
  35. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/render/picker.py +5 -2
  36. evalrouter-0.4.0/src/kimpton_evalrouter/tracing.py +836 -0
  37. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/types.py +1277 -2
  38. evalrouter-0.3.23/PKG-INFO +0 -596
  39. evalrouter-0.3.23/README.md +0 -564
  40. evalrouter-0.3.23/src/kimpton_evalrouter/_report_brand.py +0 -15
  41. evalrouter-0.3.23/src/kimpton_evalrouter/_report_document_html.py +0 -100
  42. evalrouter-0.3.23/src/kimpton_evalrouter/tracing.py +0 -360
  43. {evalrouter-0.3.23 → evalrouter-0.4.0}/LICENSE +0 -0
  44. {evalrouter-0.3.23/src/evalrouter_contracts → evalrouter-0.4.0/src/evalrouter}/py.typed +0 -0
  45. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/evalrouter_contracts/bundle.py +0 -0
  46. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/evalrouter_contracts/components.py +0 -0
  47. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/evalrouter_contracts/models.py +0 -0
  48. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/evalrouter_contracts/protocol.py +0 -0
  49. {evalrouter-0.3.23/src/kimpton_evalrouter → evalrouter-0.4.0/src/evalrouter_contracts}/py.typed +0 -0
  50. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/evalrouter_contracts/templates.py +0 -0
  51. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/evalrouter_contracts/validation.py +0 -0
  52. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/__main__.py +0 -0
  53. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_artifacts.py +0 -0
  54. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_chain_prefetch.py +0 -0
  55. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_comparison_checkpoint.py +0 -0
  56. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_forecasts.py +0 -0
  57. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_group_results.py +0 -0
  58. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_group_summary_prefetch.py +0 -0
  59. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_helpers.py +0 -0
  60. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_history_labels.py +0 -0
  61. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_progress.py +0 -0
  62. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_read_cache.py +0 -0
  63. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_report_chart_data.py +0 -0
  64. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_report_charts.py +0 -0
  65. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_report_document.py +0 -0
  66. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_report_pareto.py +0 -0
  67. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_tui_port.py +0 -0
  68. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/_tui_table.py +0 -0
  69. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/render/__init__.py +0 -0
  70. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/render/_console.py +0 -0
  71. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/render/_theme.py +0 -0
  72. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/render/_widgets.py +0 -0
  73. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/render/live.py +0 -0
  74. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/render/screens.py +0 -0
  75. {evalrouter-0.3.23 → evalrouter-0.4.0}/src/kimpton_evalrouter/render/tables.py +0 -0
@@ -0,0 +1,406 @@
1
+ Metadata-Version: 2.4
2
+ Name: evalrouter
3
+ Version: 0.4.0
4
+ Summary: Interactive evaluation workspace, command-line tools, and Python client for EvalRouter
5
+ Project-URL: Homepage, https://evalrouter.ai
6
+ Project-URL: Documentation, https://evalrouter.ai/developers/docs/cli
7
+ Project-URL: Model API, https://evalrouter.ai/developers/docs/model-api
8
+ License-Expression: LicenseRef-Kimpton-EvalRouter-SDK
9
+ License-File: LICENSE
10
+ Keywords: benchmarks,cli,evalrouter,llm,model-evaluation
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: <3.14,>=3.12
19
+ Requires-Dist: httpx==0.28.1
20
+ Requires-Dist: rich==15.0.0
21
+ Requires-Dist: textual==8.2.8
22
+ Provides-Extra: benchmark
23
+ Requires-Dist: pydantic==2.13.5; extra == 'benchmark'
24
+ Provides-Extra: keyring
25
+ Requires-Dist: keyring==25.7.0; extra == 'keyring'
26
+ Provides-Extra: langsmith
27
+ Requires-Dist: langsmith==0.12.6; extra == 'langsmith'
28
+ Provides-Extra: strands
29
+ Requires-Dist: opentelemetry-api==1.45.0; extra == 'strands'
30
+ Requires-Dist: opentelemetry-sdk==1.45.0; extra == 'strands'
31
+ Requires-Dist: strands-agents==1.57.2; extra == 'strands'
32
+ Provides-Extra: tracing
33
+ Requires-Dist: opentelemetry-api==1.45.0; extra == 'tracing'
34
+ Requires-Dist: opentelemetry-sdk==1.45.0; extra == 'tracing'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # EvalRouter CLI and Python client
38
+
39
+ Evaluate models in a full-screen terminal workspace or from scripts. Browse
40
+ benchmarks, choose models, optionally set a spending cap, follow runs, and
41
+ compare or export their results. The same package includes the typed Python
42
+ client, optional trace capture, and benchmark authoring tools.
43
+
44
+ Requires Python 3.12 or 3.13. Distributed under the proprietary Kimpton EvalRouter
45
+ SDK License, included as `LICENSE` in the package.
46
+
47
+ ## Install and create your account
48
+
49
+ We recommend [uv](https://docs.astral.sh/uv/getting-started/installation/) to install the CLI in its own Python environment:
50
+
51
+ ```sh
52
+ uv tool install evalrouter
53
+ evalrouter
54
+ ```
55
+
56
+ With pip, use `python -m pip install evalrouter` in a Python 3.12 or 3.13 environment.
57
+ uv selects a compatible Python for the CLI and downloads one if needed. If
58
+ your shell cannot find `evalrouter`, run `uv tool update-shell` and restart your
59
+ terminal. Upgrade an existing installation with `evalrouter upgrade` (or
60
+ `evalrouter --upgrade`). Stable installations stay on stable unless you pass
61
+ `--pre`; installed prereleases include prereleases automatically. The command
62
+ uses uv, pipx or pip in the current virtual environment. Source installs,
63
+ system Python and installer-pinned versions need their original installer.
64
+ Check the installed version with `evalrouter --version`. Use `evalrouter --help`
65
+ for explicit commands, or see the [CLI guide](https://evalrouter.ai/developers/docs/cli).
66
+
67
+ The interactive workspace checks for newer releases in the background and shows
68
+ an update notice when one is available. The check never installs an update or
69
+ delays opening the workspace. Set `EVALROUTER_NO_UPDATE_CHECK=1` to disable it.
70
+ Scripts, editable installs and explicitly pinned installations skip update checks.
71
+
72
+ ### Complete command names with Tab
73
+
74
+ For zsh, add this line to `~/.zshrc` after your `compinit` setup, then start a new
75
+ terminal:
76
+
77
+ ```sh
78
+ eval "$(evalrouter completion zsh)"
79
+ ```
80
+
81
+ For bash, add this line to `~/.bashrc`:
82
+
83
+ ```sh
84
+ eval "$(evalrouter completion bash)"
85
+ ```
86
+
87
+ Type `evalrouter ru` and press Tab to complete `run`. With `evalrouter r`, Tab
88
+ shows matching commands such as `run`, `resume` and `results`. The shell setup
89
+ only completes top-level command names and makes no API request. It does not
90
+ change interactive prompts or run an evaluation.
91
+
92
+ This package was previously published as `kimpton-evalrouter-sdk`. The command
93
+ stays `evalrouter`. Use `from evalrouter import Client` for new integrations;
94
+ legacy `kimpton_evalrouter` imports remain compatible and refer to the same
95
+ public classes. To switch, run
96
+ `uv tool uninstall kimpton-evalrouter-sdk` (or
97
+ `pip uninstall -y kimpton-evalrouter-sdk evalrouter`) and install `evalrouter`.
98
+
99
+ The package supplies the `evalrouter` command; no repository checkout is needed.
100
+ [Create an EvalRouter account](https://evalrouter.ai/register), verify your email,
101
+ and follow the browser sign-in below.
102
+ Package installation does not grant account access or evaluation credit.
103
+
104
+ Sign in with your account:
105
+
106
+ ```sh
107
+ evalrouter login
108
+ evalrouter whoami
109
+ ```
110
+
111
+ Follow the browser sign-in; on a local computer the browser returns to the
112
+ waiting CLI. For a remote terminal, use `evalrouter login --no-browser` and
113
+ approve the code on a device with a browser. New accounts finish setup there.
114
+ The CLI selects your only workspace automatically, or lets you choose one.
115
+ Production is the default API; `evalrouter options` lists `--base-url` and the other
116
+ settings that apply to every command.
117
+ No API key or credential-storage setup is needed for a normal sign-in.
118
+ The optional `evalrouter[keyring]` extra enables a compatible OS keychain
119
+ backend; otherwise credentials use a private file readable only by your user.
120
+ In the workspace, **Account and workspace → Sign in** starts the same flow.
121
+ See the [sign-in guide](https://evalrouter.ai/developers/docs/cli-login) for
122
+ workspace switching, stored API keys and signing out.
123
+
124
+ CI and services can use `EVALROUTER_API_KEY` and `EVALROUTER_WORKSPACE_ID` supplied
125
+ privately by a secret manager. Never put credentials in arguments, URLs, request
126
+ files or logs.
127
+
128
+ ## Interactive workspace
129
+
130
+ Run `evalrouter` without arguments in a terminal to open the full-screen
131
+ workspace. Choose **Account and workspace → Sign in** to connect your account.
132
+ Local sign-in returns from the browser to the waiting CLI; for a remote terminal,
133
+ use `evalrouter login --no-browser` and approve the code on a device with a browser.
134
+
135
+ **Run a benchmark** guides you through the benchmark, one to eight models, each
136
+ model's reasoning settings and coverage. Type to filter lists; Space or Enter
137
+ toggles a model and Tab continues. A supported native one-model evaluation
138
+ starts directly with the optional `--max-cost` cap or available wallet credit,
139
+ limited by the service maximum. Supported native separate multi-model groups
140
+ also start directly, with an optional aggregate cap. Their finite service bounds
141
+ do not reserve the wallet once per model: mandatory fees and live calls use
142
+ shared available credit. Supported native matched comparisons also start directly with an optional cap; unsupported execution paths retain their quote and cap requirements.
143
+
144
+ Choose a suggested sample, **Custom sample size**, or **Full benchmark** for
145
+ coverage. A custom sample accepts 1 to 1,000 tasks, limited to the benchmark's
146
+ task count when known. Full benchmark includes every task.
147
+
148
+ Home includes **Run history**, **Run groups**, and **Results**, plus model and
149
+ benchmark browsing, billing and account settings. **Results** offers **Single
150
+ run**, **Group run**, then **Compare runs**. Group status shows each model's state;
151
+ open a member run, return to its group, or keep watching live progress.
152
+ While watching, choose **Open live run in browser** or **Open live group in
153
+ browser** with Enter, B or a click. Live status continues in the terminal.
154
+
155
+ Escape goes back; Left also goes back when you are not editing text. Leaving a
156
+ live run stops watching only: submitted server work continues. Ctrl+Q exits. Use
157
+ PgUp/PgDn for long reviews and results, and F1 for keyboard help. Select output
158
+ with the mouse and press Ctrl+C to copy; with no selection, Ctrl+C goes back.
159
+ Password fields cannot be copied. `EVALROUTER_TUI=off` selects the older interactive
160
+ shell; explicit commands, plain output and JSON remain available.
161
+
162
+ ## Run a model benchmark
163
+
164
+ Sign in, choose a ready benchmark and compatible model, then run:
165
+
166
+ ```sh
167
+ evalrouter login
168
+ evalrouter catalog
169
+ evalrouter catalog --models
170
+ evalrouter run BENCHMARK_SLUG --model MODEL_ID --sample 3
171
+ ```
172
+
173
+ Supported native single-model benchmarks start directly. A spending cap is
174
+ optional; use `--max-cost USD` to set one. Without a cap, the service bounds
175
+ admission using your available wallet credit and its service maximum. An
176
+ explicit cap is never silently raised. Supported native separate groups and matched comparisons also accept an optional aggregate cap. Other execution paths retain their compatibility, funding and quote requirements.
177
+
178
+ For scripts, approve paid work explicitly and retain the operation identity:
179
+
180
+ ```sh
181
+ evalrouter run BENCHMARK_SLUG --model MODEL_ID --sample 3 --yes --json
182
+ evalrouter status
183
+ evalrouter wait RUN_ID
184
+ evalrouter results RUN_ID
185
+ evalrouter export RUN_ID --format json --output result.json
186
+ ```
187
+
188
+ A sample is not a full-benchmark score. A local timeout or interrupted watcher
189
+ does not stop server work. Reuse the saved request identity when recovering an
190
+ uncertain submission; a new identity can start another evaluation.
191
+
192
+ Use `evalrouter --help` and each command's `--help` for supported options.
193
+ Account commands include `login`, `whoami`, `workspace` and `logout`;
194
+ `credits` reads balance and holds. Payments take place on the website.
195
+
196
+ ## Author your own benchmark
197
+
198
+ `benchmark init`, `benchmark validate` and `benchmark bundle` run entirely on
199
+ your machine: no account, no network request, and nothing from your package is
200
+ imported or executed. The normative validator ships inside `evalrouter`, and
201
+ its one dependency (pydantic) is an optional extra. The base installation uses
202
+ httpx, Rich and Textual. With pip, use `pip install 'evalrouter[benchmark]'`:
203
+
204
+ ```sh
205
+ uv tool install "evalrouter[benchmark]"
206
+ evalrouter benchmark init ./my-benchmark --namespace example --name my-benchmark
207
+ evalrouter benchmark validate ./my-benchmark
208
+ evalrouter benchmark bundle ./my-benchmark # evalrouter-bundle-example-my-benchmark-<version>.zip
209
+ ```
210
+
211
+ Without the extra these three commands stop before reading your package and
212
+ report `benchmark_extra_required` with the exact install string; `--help` and
213
+ every network command keep working. `init` writes an explicitly synthetic draft
214
+ and claims no license: replace the tasks, rights, references and limits before
215
+ submitting. Local validation is not platform admission — EvalRouter revalidates
216
+ every submission on its own servers.
217
+
218
+ Where private benchmark imports are enabled, `benchmark upload`, `import` and
219
+ `create` use workspace-private data with the service's built-in graders. These
220
+ are account-backed operations, separate from local package validation. See the
221
+ [private benchmark guide](https://evalrouter.ai/developers/docs/byob) for manifests,
222
+ supported formats, source management and permissions.
223
+
224
+ ## Python client
225
+
226
+ Install with `python -m pip install evalrouter` in your application's environment. The
227
+ import name is `evalrouter`; the client supports context-manager cleanup:
228
+
229
+ Canonical imports require a release containing this namespace. Older registry
230
+ releases through 0.3.24 use `kimpton_evalrouter`. Current releases provide the canonical `evalrouter` import.
231
+
232
+ ```python
233
+ import os
234
+ from evalrouter import Client
235
+
236
+ with Client(
237
+ base_url="https://api.evalrouter.ai",
238
+ api_key=os.environ["EVALROUTER_API_KEY"],
239
+ workspace_id=os.environ["EVALROUTER_WORKSPACE_ID"],
240
+ ) as client:
241
+ print(client.catalog.models())
242
+ ```
243
+
244
+ Use `client.catalog`, `client.evals`, `client.quotes` and `client.runs` for
245
+ typed discovery, submission and result resources. Creating a quote starts no evaluation; submitting its accepted
246
+ ID can start paid work. Keep the quote ID and idempotency key before submission.
247
+ The [model API guide](https://evalrouter.ai/developers/docs/model-api) describes
248
+ request fields, limits and result contracts.
249
+
250
+ ## Import LangSmith traces
251
+
252
+ The optional `langsmith` extra provides a local connector for completed agent
253
+ runs. Where your workspace has Traces, create an SDK destination connection in
254
+ **Traces → Connect agent**, then supply `LANGSMITH_API_KEY` and the connection's
255
+ EvalRouter environment variables through your secret manager. The source key
256
+ is never sent to EvalRouter.
257
+
258
+ ```sh
259
+ python -m pip install 'evalrouter[langsmith]'
260
+ python -m evalrouter.langsmith projects
261
+ python -m evalrouter.langsmith sync --project 'YOUR_PROJECT_ID' \
262
+ --state './.private/evalrouter-langsmith-state.json' --metadata-only --watch
263
+ ```
264
+
265
+ The process must stay running for automatic imports. Its private checkpoint
266
+ resumes progress across restarts. Set `--since` to an ISO timestamp to choose
267
+ the initial import window. This explicit metadata-only mode omits source names,
268
+ inputs, outputs, error text, tags, events and arbitrary metadata. Hierarchy,
269
+ timing, error status and reported numeric usage remain. The compatibility default
270
+ captures bounded field-name-redacted content if `--metadata-only` is omitted.
271
+
272
+ Checkpoint version 2 binds the content policy and destination. Unknown
273
+ acknowledgments replay a private adjacent `.delivery.json` payload unchanged;
274
+ keep it with the checkpoint. A policy change on an existing checkpoint is
275
+ refused. Version 1 upgrades only in its original content-capture mode and cannot
276
+ restore payload bytes lost by the older connector. Finish unresolved deliveries
277
+ before using a new checkpoint and connection for a different policy. Only
278
+ activity recorded by LangSmith can be imported; two stable closed reads are
279
+ observed coverage, not proof that every upstream child exists.
280
+
281
+ ## Live agent capture
282
+
283
+ Install with `python -m pip install 'evalrouter[tracing]'` in your agent's own environment.
284
+ Configure `EVALROUTER_BASE_URL`, `EVALROUTER_WORKSPACE_ID`,
285
+ `EVALROUTER_TRACE_CONNECTION_ID` and the restricted `EVALROUTER_TRACE_KEY` through
286
+ an authorized secret manager. Package installation and connection authorization are separate.
287
+
288
+ ```python
289
+ import json
290
+ import os
291
+ from anthropic import Anthropic
292
+ from evalrouter.tracing import TraceCapture
293
+
294
+ # Also install anthropic, and supply ANTHROPIC_API_KEY privately.
295
+ model = Anthropic(max_retries=0)
296
+ capture = TraceCapture(capture_content=True)
297
+ with capture.agent("Support assistant") as root:
298
+ root.input({"message": "Explain what an evaluation benchmark is."})
299
+ with capture.model(os.environ["ANTHROPIC_MODEL"]) as span:
300
+ answer = model.messages.create(
301
+ model=os.environ["ANTHROPIC_MODEL"], max_tokens=256,
302
+ messages=[{"role": "user", "content": "Explain what an evaluation benchmark is."}],
303
+ )
304
+ text = "".join(block.text for block in answer.content if block.type == "text")
305
+ span.output({"answer": text})
306
+ root.output({"answer": text})
307
+ receipt = capture.seal(root.trace_id)
308
+ print(json.dumps(receipt))
309
+ if receipt["state"] != "accepted" or not receipt["complete"] or not capture.close():
310
+ raise SystemExit(1)
311
+ ```
312
+
313
+ This example makes a real paid model request. Content capture is explicitly
314
+ enabled; use `capture_content=False` to omit input, output and error payloads.
315
+ Caller attributes still require your metadata policy.
316
+ Common secret field names are redacted, but secrets in arbitrary text cannot be
317
+ detected. Content capture defaults to true; select metadata-only explicitly.
318
+
319
+ Root exit and `flush()` do not seal. Join owned children, then `seal(root.trace_id)`
320
+ to acknowledge closure. `receipt(root.trace_id)` reports local delivery state,
321
+ counts, accepted server UUID and server completion, independently of evaluation
322
+ completion. Unknown acknowledgments retain identical batches for later
323
+ flush/seal/close on the same instance. Zero newly inserted spans on replay is
324
+ success. `close()` returns false while active, failed or unknown, and true after
325
+ acknowledged closure and shutdown. A context manager calls close, but does not
326
+ raise on a false result; inspect receipts explicitly. There is no background HTTP
327
+ export. Buffers are process-local; retry before exit. Each instance retains at
328
+ most 64 local trace receipts, 512 active spans and 16 MiB of pending records.
329
+ When another root needs room, the oldest successfully sealed idle receipt is
330
+ evicted. Save the receipt/server UUID if you need it later; `receipt(id)` raises
331
+ `ValueError` after eviction. Pending, unknown, active or dropped traces are never
332
+ evicted. If all 64 are unsettled, a new root is not recorded (its handle has no
333
+ trace ID and `failed_exports` increases); resolve delivery or use another instance.
334
+ Late activity inherited from an evicted trace is rejected, never made a new root.
335
+ Close attempts every retained trace within one aggregate deadline and leaves the
336
+ provider alive if any closure fails. Capture loss prevents successful seal. The optional OpenTelemetry dependency stays
337
+ isolated from the base HTTP client.
338
+
339
+ Create a connection under **Traces → Connect agent** where Traces is enabled for
340
+ your workspace. Detailed delivery receipts are described in the trace connection setup in your workspace.
341
+
342
+
343
+ ## Attach existing OpenTelemetry instrumentation
344
+
345
+ Install the `evalrouter[tracing]` extra into your existing Python
346
+ 3.12/3.13 agent environment. Pass the OTel SDK provider the framework actually
347
+ uses; do not replace its global provider. No agent inheritance or per-call
348
+ EvalRouter wrappers are required for supported spans:
349
+
350
+ ```python
351
+ from evalrouter.tracing import TraceCapture
352
+
353
+ capture = TraceCapture(capture_content=False)
354
+ attachment = capture.attach(existing_provider, scope_names=("your.instrumentation",))
355
+ # Run the already-instrumented agent, then join all owned child work.
356
+ for trace_id in attachment.trace_ids:
357
+ receipt = capture.seal(trace_id)
358
+ print(receipt) # IDs/counts/delivery state only; inspect accepted + complete.
359
+ # At application shutdown, check capture.close(); it never stops existing_provider.
360
+ ```
361
+
362
+ Attachment exports metadata only, even when wrapper content capture is enabled.
363
+ It removes source names, resource attributes, events, prompts, tool arguments,
364
+ results and exception text. It retains original trace/span/parent IDs, closed
365
+ operation/kind/status enums and bounded numeric token counters. Source counters
366
+ are observations, not native usage charges. `evalrouter.otel.status=unset` means
367
+ unknown source success: wire `ok` only means no explicit source ERROR, never a
368
+ native grade or proof that a tool succeeded. Unknown/conflicting kinds are
369
+ counted in `attachment.unsupported_spans` and prevent successful sealing.
370
+ Provider flush queues records; it does not prove accepted ingestion or closure.
371
+
372
+ The optional `[strands]` extra pins Strands for applications that need it; the
373
+ base client has no Strands dependency. Attachment only sees selected spans that
374
+ the supplied provider actually records. It cannot recover unsampled or missing
375
+ work, or capture uninstrumented frameworks automatically. LangSmith project
376
+ imports and ACP evaluation execution are separate integrations.
377
+
378
+ ## Native multi-model client requests
379
+
380
+ Supported native separate groups and matched comparisons start directly with an
381
+ optional aggregate spending cap. Other execution paths retain their quote and
382
+ cap requirements. Hosted route availability is checked by the service.
383
+
384
+ ```python
385
+ from evalrouter import Client
386
+
387
+ with Client() as client:
388
+ group = client.run_groups.create({
389
+ "models": [
390
+ {"kind": "managed", "route_id": "YOUR_FIRST_ROUTE"},
391
+ {"kind": "managed", "route_id": "YOUR_SECOND_ROUTE"},
392
+ ],
393
+ "selection": {"profile_ids": ["YOUR_EXACT_NATIVE_PROFILE"]},
394
+ "coverage": {"mode": "sample", "sample_count": 1, "seed": 42},
395
+ # Optional aggregate stop limit, in integer micro-USD:
396
+ # "max_charge_microusd": "2000000",
397
+ }, idempotency_key="persist-this-group-request-key")
398
+ # If work stops, resume eligible native member chains with a NEW durable key:
399
+ # continued = client.run_groups.resume(group["id"], {},
400
+ # idempotency_key="persist-this-continuation-request-key")
401
+ ```
402
+
403
+ An omitted customer cap returns `max_charge_microusd=None`;
404
+ `authorization_limit_microusd` is a finite service bound. It is not the money
405
+ reserved or a budget selected by you. Preserve the exact body and key across
406
+ uncertain replies. Actual charges and available wallet credit remain authoritative.