evalrouter-sdk 0.4.4a1__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 (49) hide show
  1. evalrouter_sdk-0.4.4a1/LICENSE +29 -0
  2. evalrouter_sdk-0.4.4a1/PKG-INFO +306 -0
  3. evalrouter_sdk-0.4.4a1/README.md +272 -0
  4. evalrouter_sdk-0.4.4a1/pyproject.toml +48 -0
  5. evalrouter_sdk-0.4.4a1/src/evalrouter/__init__.py +26 -0
  6. evalrouter_sdk-0.4.4a1/src/evalrouter/agents.py +63 -0
  7. evalrouter_sdk-0.4.4a1/src/evalrouter/langsmith.py +18 -0
  8. evalrouter_sdk-0.4.4a1/src/evalrouter/py.typed +0 -0
  9. evalrouter_sdk-0.4.4a1/src/evalrouter/tracing.py +5 -0
  10. evalrouter_sdk-0.4.4a1/src/evalrouter/types.py +9 -0
  11. evalrouter_sdk-0.4.4a1/src/evalrouter_contracts/__init__.py +11 -0
  12. evalrouter_sdk-0.4.4a1/src/evalrouter_contracts/bundle.py +46 -0
  13. evalrouter_sdk-0.4.4a1/src/evalrouter_contracts/components.py +181 -0
  14. evalrouter_sdk-0.4.4a1/src/evalrouter_contracts/models.py +288 -0
  15. evalrouter_sdk-0.4.4a1/src/evalrouter_contracts/protocol.py +221 -0
  16. evalrouter_sdk-0.4.4a1/src/evalrouter_contracts/py.typed +0 -0
  17. evalrouter_sdk-0.4.4a1/src/evalrouter_contracts/templates.py +136 -0
  18. evalrouter_sdk-0.4.4a1/src/evalrouter_contracts/validation.py +329 -0
  19. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/__init__.py +263 -0
  20. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_acp_agents.py +702 -0
  21. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_acp_controller.py +746 -0
  22. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_acp_launch.py +229 -0
  23. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_acp_registry/LICENSE +176 -0
  24. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_acp_registry/registry-2026-10-06.json +1547 -0
  25. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_boundary.py +162 -0
  26. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_client_run.py +1405 -0
  27. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_client_trace.py +819 -0
  28. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_client_trace_otel.py +208 -0
  29. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_forecasts.py +101 -0
  30. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_helpers.py +138 -0
  31. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_in_code.py +522 -0
  32. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_local_state.py +14 -0
  33. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_progress.py +289 -0
  34. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_repository_checkout.py +331 -0
  35. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_resolution.py +550 -0
  36. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_resources.py +3027 -0
  37. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_task_adapters/__init__.py +90 -0
  38. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_task_adapters/a1_prompt_answer.py +44 -0
  39. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_task_adapters/a2_environment.py +62 -0
  40. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_task_adapters/a3_file_task.py +237 -0
  41. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_task_adapters/a4_repository.py +115 -0
  42. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_task_mcp.py +374 -0
  43. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_transport.py +546 -0
  44. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/_web_routes.py +113 -0
  45. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/agents.py +723 -0
  46. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/langsmith.py +1279 -0
  47. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/py.typed +0 -0
  48. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/tracing.py +996 -0
  49. evalrouter_sdk-0.4.4a1/src/kimpton_evalrouter/types.py +5603 -0
@@ -0,0 +1,29 @@
1
+ Kimpton EvalRouter SDK License
2
+
3
+ Copyright (c) 2026 Kimpton. All rights reserved.
4
+
5
+ Permission is granted to download, install, execute, and make internal copies of
6
+ this SDK and its documentation solely to access the EvalRouter service and to
7
+ integrate that access into applications you own or control, subject to your
8
+ applicable EvalRouter service agreement and authorization.
9
+
10
+ This is proprietary software, not an open-source license. Except for the limited
11
+ permission above or as required by applicable law, no permission is granted to
12
+ modify, redistribute, sublicense, sell, or use this software to provide a
13
+ competing service. Preserve this license and all copyright notices in permitted
14
+ copies. All rights not expressly granted are reserved.
15
+
16
+ This license covers only the distributed SDK, CLI, and accompanying
17
+ documentation. It grants no rights to EvalRouter backend or service source,
18
+ benchmarks, datasets, models, credentials, trademarks, or other excluded material.
19
+ Third-party dependencies remain subject to their own licenses.
20
+
21
+ Downloading this software does not create an account, grant service access,
22
+ provide credits, or waive service charges. Access remains subject to separate
23
+ account, workspace, authorization, and billing requirements.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
27
+ PURPOSE, AND NONINFRINGEMENT. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28
+ THE COPYRIGHT HOLDERS SHALL NOT BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
29
+ LIABILITY ARISING FROM THE SOFTWARE OR ITS USE.
@@ -0,0 +1,306 @@
1
+ Metadata-Version: 2.4
2
+ Name: evalrouter-sdk
3
+ Version: 0.4.4a1
4
+ Summary: The EvalRouter Python SDK: typed client, agent evaluations and trace capture
5
+ Project-URL: Homepage, https://evalrouter.ai
6
+ Project-URL: Documentation, https://evalrouter.ai/developers/docs/python
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,evalrouter,llm,model-evaluation,sdk
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Typing :: Typed
17
+ Requires-Python: <3.14,>=3.12
18
+ Requires-Dist: httpx==0.28.1
19
+ Provides-Extra: agents
20
+ Requires-Dist: agent-client-protocol==0.12.1; extra == 'agents'
21
+ Requires-Dist: pydantic==2.13.5; extra == 'agents'
22
+ Provides-Extra: benchmark
23
+ Requires-Dist: pydantic==2.13.5; extra == 'benchmark'
24
+ Provides-Extra: langsmith
25
+ Requires-Dist: langsmith==0.12.6; extra == 'langsmith'
26
+ Provides-Extra: strands
27
+ Requires-Dist: opentelemetry-api==1.45.0; extra == 'strands'
28
+ Requires-Dist: opentelemetry-sdk==1.45.0; extra == 'strands'
29
+ Requires-Dist: strands-agents==1.57.2; extra == 'strands'
30
+ Provides-Extra: tracing
31
+ Requires-Dist: opentelemetry-api==1.45.0; extra == 'tracing'
32
+ Requires-Dist: opentelemetry-sdk==1.45.0; extra == 'tracing'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # EvalRouter Python SDK
36
+
37
+ The programmatic interface to EvalRouter: a typed client for discovery, quotes,
38
+ evaluations and results, local waiting and exports, `evalrouter.agents` for
39
+ evaluating an agent you run, trace capture and the LangSmith connector.
40
+
41
+ Requires Python 3.12 or 3.13. Distributed under the proprietary Kimpton EvalRouter
42
+ SDK License, included as `LICENSE` in the package.
43
+
44
+ The SDK has no terminal interface. For the `evalrouter` command and its
45
+ interactive workspace, install [`evalrouter`](https://pypi.org/project/evalrouter/)
46
+ (`uv tool install --prerelease allow evalrouter`), which depends on this package at the
47
+ same version.
48
+
49
+ ## Python client
50
+
51
+ Install this alpha with `python -m pip install --pre evalrouter-sdk` in your application's environment. The
52
+ import name is `evalrouter`; the client supports context-manager cleanup:
53
+
54
+ Canonical imports require a release containing this namespace. Older registry
55
+ releases through 0.3.24 use `kimpton_evalrouter`. Select alpha releases explicitly
56
+ to use the canonical `evalrouter` import and current tracing APIs.
57
+
58
+ ```python
59
+ import os
60
+ from evalrouter import Client
61
+
62
+ with Client(
63
+ base_url="https://api.evalrouter.ai",
64
+ api_key=os.environ["EVALROUTER_API_KEY"],
65
+ workspace_id=os.environ["EVALROUTER_WORKSPACE_ID"],
66
+ ) as client:
67
+ print(client.catalog.models())
68
+ ```
69
+
70
+ Use `client.catalog`, `client.evals`, `client.quotes` and `client.runs` for
71
+ typed discovery, submission and result resources. Creating a quote starts no evaluation; submitting its accepted
72
+ ID can start paid work. Keep the quote ID and idempotency key before submission.
73
+ The [model API guide](https://evalrouter.ai/developers/docs/model-api) describes
74
+ request fields, limits and result contracts.
75
+
76
+ `client.catalog.resolve_benchmark(name)` and `resolve_model(name, benchmark=...)`
77
+ resolve the names the command line accepts, without prompting.
78
+ `client.runs.follow(run_id)` yields a run's events until it ends;
79
+ `client.evaluation_jobs.wait(job_id)` waits for a multi-model job; `report_url`
80
+ on runs and evaluation jobs returns the web report, where the charts are drawn.
81
+
82
+ Resources and imports are stable or preview. Preview ones (including
83
+ `evalrouter.agents` and `evalrouter.tracing`) are supported but may change in a
84
+ minor release. The [Python SDK guide](https://evalrouter.ai/developers/docs/python#stability-tiers)
85
+ lists each tier and the deprecation notes for entries that left stable.
86
+
87
+ ## Evaluate an agent you run
88
+
89
+ `evalrouter.agents` evaluates an agent on EvalRouter tasks while the agent runs
90
+ on your machine. EvalRouter delivers each task, meters every model call through
91
+ the run's gateway (managed models only), grades the submission with the
92
+ benchmark's own grader and records the trajectory. It is available where your
93
+ workspace has agent evaluation enabled; otherwise quoting refuses with
94
+ `client_run_unavailable`.
95
+
96
+ The agent can be an ACP Registry agent (`registry_agent("opencode")`), any
97
+ local ACP command (`local_agent("my-agent --acp")`, which needs
98
+ `evalrouter-sdk[agents]`), or an agent written in Python:
99
+
100
+ ```python
101
+ from evalrouter import Client, agents
102
+
103
+
104
+ class Solver(agents.Agent):
105
+ name = "my solver"
106
+
107
+ async def run(self, context):
108
+ task = await context.task.task()
109
+ reply = await context.gateway.chat(messages=task["messages"])
110
+ await context.task.submit(reply["choices"][0]["message"]["content"])
111
+ await context.task.done()
112
+
113
+
114
+ client = Client()
115
+ evaluation = agents.quote(
116
+ client,
117
+ agent=Solver(),
118
+ model="ADMITTED_ROUTE_ID",
119
+ tasks=agents.benchmark("eval://PROVIDER/NAME/VERSION"),
120
+ coverage={"mode": "sample", "sample_count": 3, "seed": 42},
121
+ budget_usd="2",
122
+ )
123
+ # Review evaluation.quote before starting; nothing is charged until start().
124
+ run = evaluation.start()
125
+ for event in run.events(): # or: async for event in run.events_async()
126
+ print(event.type, event.task_ref, event.failure_code or "")
127
+ print(run.wait()["status"], run.results())
128
+ ```
129
+
130
+ Tasks can also come from an environment version (`agents.environment(REF,
131
+ split="test")`), your private benchmarks (`agents.private_benchmark(ID)`) or a
132
+ suite. `context.task` offers the attempt's task tools (`call`, `list`,
133
+ `instructions`, `task`, `submit`, `done`); file tasks are written in
134
+ `context.workspace`. `context.gateway` is OpenAI chat-compatible
135
+ (`gateway.openai()` returns an `AsyncOpenAI` client when `openai` is installed).
136
+ Leaving the event loop early finishes the attempt in flight as an interrupted
137
+ controller; `agents.AgentRun.resume(client, RUN_ID, agent)` continues the run
138
+ with the same agent, and `run.cancel()` stops it. `run.costs()`,
139
+ `run.export("csv")`, `run.trajectories()` and `agents.compare(client, [run_a,
140
+ run_b])` read the finalized results. `agents.evaluate(...)` does all of this in
141
+ one call. Its result's `status` and `succeeded` report the run's outcome: a
142
+ failed, partial or abandoned run is returned with `succeeded` false, as
143
+ `runs.wait` returns it, not raised. The CLI's `evalrouter run --agent` uses the
144
+ same functions and exits 0 only for a completed run (1 when it failed, 4
145
+ otherwise).
146
+
147
+ ## Import LangSmith traces
148
+
149
+ The optional `langsmith` extra provides a local connector for completed agent
150
+ runs. Where your workspace has Traces, create an SDK destination connection in
151
+ **Traces → Connect agent**, then supply `LANGSMITH_API_KEY` and the connection's
152
+ EvalRouter environment variables through your secret manager. The source key
153
+ is never sent to EvalRouter.
154
+
155
+ ```sh
156
+ python -m pip install --pre 'evalrouter-sdk[langsmith]'
157
+ python -m evalrouter.langsmith projects
158
+ python -m evalrouter.langsmith sync --project 'YOUR_PROJECT_ID' \
159
+ --state './.private/evalrouter-langsmith-state.json' --metadata-only --watch
160
+ ```
161
+
162
+ The process must stay running for automatic imports. Its private checkpoint
163
+ resumes progress across restarts. Set `--since` to an ISO timestamp to choose
164
+ the initial import window. This explicit metadata-only mode omits source names,
165
+ inputs, outputs, error text, tags, events and arbitrary metadata. Hierarchy,
166
+ timing, error status and reported numeric usage remain. The compatibility default
167
+ captures bounded field-name-redacted content if `--metadata-only` is omitted.
168
+
169
+ Checkpoint version 2 binds the content policy and destination. Unknown
170
+ acknowledgments replay a private adjacent `.delivery.json` payload unchanged;
171
+ keep it with the checkpoint. A policy change on an existing checkpoint is
172
+ refused. Version 1 upgrades only in its original content-capture mode and cannot
173
+ restore payload bytes lost by the older connector. Finish unresolved deliveries
174
+ before using a new checkpoint and connection for a different policy. Only
175
+ activity recorded by LangSmith can be imported; two stable closed reads are
176
+ observed coverage, not proof that every upstream child exists.
177
+
178
+ ## Live agent capture
179
+
180
+ Install the alpha with `python -m pip install --pre 'evalrouter-sdk[tracing]'` in your agent's own environment.
181
+ Configure `EVALROUTER_BASE_URL`, `EVALROUTER_WORKSPACE_ID`,
182
+ `EVALROUTER_TRACE_CONNECTION_ID` and the restricted `EVALROUTER_TRACE_KEY` through
183
+ an authorized secret manager. Install alpha releases explicitly; an ordinary install selects the stable release.
184
+
185
+ ```python
186
+ import json
187
+ import os
188
+ from anthropic import Anthropic
189
+ from evalrouter.tracing import TraceCapture
190
+
191
+ # Also install anthropic, and supply ANTHROPIC_API_KEY privately.
192
+ model = Anthropic(max_retries=0)
193
+ capture = TraceCapture(capture_content=True)
194
+ with capture.agent("Support assistant") as root:
195
+ root.input({"message": "Explain what an evaluation benchmark is."})
196
+ with capture.model(os.environ["ANTHROPIC_MODEL"]) as span:
197
+ answer = model.messages.create(
198
+ model=os.environ["ANTHROPIC_MODEL"], max_tokens=256,
199
+ messages=[{"role": "user", "content": "Explain what an evaluation benchmark is."}],
200
+ )
201
+ text = "".join(block.text for block in answer.content if block.type == "text")
202
+ span.output({"answer": text})
203
+ root.output({"answer": text})
204
+ receipt = capture.seal(root.trace_id)
205
+ print(json.dumps(receipt))
206
+ if receipt["state"] != "accepted" or not receipt["complete"] or not capture.close():
207
+ raise SystemExit(1)
208
+ ```
209
+
210
+ This example makes a real paid model request. Content capture is explicitly
211
+ enabled; use `capture_content=False` to omit input, output and error payloads.
212
+ Caller attributes still require your metadata policy.
213
+ Common secret field names are redacted, but secrets in arbitrary text cannot be
214
+ detected. Content capture defaults to true; select metadata-only explicitly.
215
+
216
+ Root exit and `flush()` do not seal. Join owned children, then `seal(root.trace_id)`
217
+ to acknowledge closure. `receipt(root.trace_id)` reports local delivery state,
218
+ counts, accepted server UUID and server completion, independently of evaluation
219
+ completion. Unknown acknowledgments retain identical batches for later
220
+ flush/seal/close on the same instance. Zero newly inserted spans on replay is
221
+ success. `close()` returns false while active, failed or unknown, and true after
222
+ acknowledged closure and shutdown. A context manager calls close, but does not
223
+ raise on a false result; inspect receipts explicitly. There is no background HTTP
224
+ export. Buffers are process-local; retry before exit. Each instance retains at
225
+ most 64 local trace receipts, 512 active spans and 16 MiB of pending records.
226
+ When another root needs room, the oldest successfully sealed idle receipt is
227
+ evicted. Save the receipt/server UUID if you need it later; `receipt(id)` raises
228
+ `ValueError` after eviction. Pending, unknown, active or dropped traces are never
229
+ evicted. If all 64 are unsettled, a new root is not recorded (its handle has no
230
+ trace ID and `failed_exports` increases); resolve delivery or use another instance.
231
+ Late activity inherited from an evicted trace is rejected, never made a new root.
232
+ Close attempts every retained trace within one aggregate deadline and leaves the
233
+ provider alive if any closure fails. Capture loss prevents successful seal. The optional OpenTelemetry dependency stays
234
+ isolated from the base HTTP client.
235
+
236
+ Create a connection under **Traces → Connect agent** where Traces is enabled for
237
+ your workspace. Detailed delivery receipts are described in the trace connection setup in your workspace.
238
+
239
+
240
+ ## Attach existing OpenTelemetry instrumentation
241
+
242
+ Install the alpha `evalrouter-sdk[tracing]` extra into your existing Python
243
+ 3.12/3.13 agent environment. Pass the OTel SDK provider the framework actually
244
+ uses; do not replace its global provider. No agent inheritance or per-call
245
+ EvalRouter wrappers are required for supported spans:
246
+
247
+ ```python
248
+ from evalrouter.tracing import TraceCapture
249
+
250
+ capture = TraceCapture(capture_content=False)
251
+ attachment = capture.attach(existing_provider, scope_names=("your.instrumentation",))
252
+ # Run the already-instrumented agent, then join all owned child work.
253
+ for trace_id in attachment.trace_ids:
254
+ receipt = capture.seal(trace_id)
255
+ print(receipt) # IDs/counts/delivery state only; inspect accepted + complete.
256
+ # At application shutdown, check capture.close(); it never stops existing_provider.
257
+ ```
258
+
259
+ Attachment exports metadata only, even when wrapper content capture is enabled.
260
+ It removes source names, resource attributes, events, prompts, tool arguments,
261
+ results and exception text. It retains original trace/span/parent IDs, closed
262
+ operation/kind/status enums and bounded numeric token counters. Source counters
263
+ are observations, not native usage charges. `evalrouter.otel.status=unset` means
264
+ unknown source success: wire `ok` only means no explicit source ERROR, never a
265
+ native grade or proof that a tool succeeded. Unknown/conflicting kinds are
266
+ counted in `attachment.unsupported_spans` and prevent successful sealing.
267
+ Provider flush queues records; it does not prove accepted ingestion or closure.
268
+
269
+ The optional `[strands]` extra pins Strands for applications that need it; the
270
+ base client has no Strands dependency. Attachment only sees selected spans that
271
+ the supplied provider actually records. It cannot recover unsampled or missing
272
+ work, or capture uninstrumented frameworks automatically. LangSmith project
273
+ imports and ACP evaluation execution are separate integrations.
274
+
275
+ ## Native multi-model client requests
276
+
277
+ Preview the matrix before starting paid work. Save the request and idempotency
278
+ key so an uncertain reply can be recovered without starting another job.
279
+
280
+ ```python
281
+ from evalrouter import Client
282
+
283
+ with Client() as client:
284
+ request = {
285
+ "name": "Model comparison",
286
+ "candidates": [
287
+ {"model": {"kind": "managed", "route_id": "YOUR_FIRST_ROUTE"}},
288
+ {"model": {"kind": "managed", "route_id": "YOUR_SECOND_ROUTE"}},
289
+ ],
290
+ "evaluations": [{
291
+ "selection": {"profile_ids": ["YOUR_EXACT_NATIVE_PROFILE"]},
292
+ "coverage": {"mode": "sample", "sample_count": 1, "seed": 42},
293
+ }],
294
+ }
295
+ preview = client.evaluation_jobs.preflight(request)
296
+ if preview["supported"]:
297
+ job = client.evaluation_jobs.start(
298
+ {**request, "preflight_digest": preview["digest"]},
299
+ idempotency_key="persist-this-job-request-key",
300
+ )
301
+ print(job["id"])
302
+ ```
303
+
304
+ The job's selected models or agents and benchmarks stay together in the results
305
+ board. Each runnable pair has its own run and receipt. Charges draw from the
306
+ workspace wallet as work proceeds. Existing capped quotes keep their terms.
@@ -0,0 +1,272 @@
1
+ # EvalRouter Python SDK
2
+
3
+ The programmatic interface to EvalRouter: a typed client for discovery, quotes,
4
+ evaluations and results, local waiting and exports, `evalrouter.agents` for
5
+ evaluating an agent you run, trace capture and the LangSmith connector.
6
+
7
+ Requires Python 3.12 or 3.13. Distributed under the proprietary Kimpton EvalRouter
8
+ SDK License, included as `LICENSE` in the package.
9
+
10
+ The SDK has no terminal interface. For the `evalrouter` command and its
11
+ interactive workspace, install [`evalrouter`](https://pypi.org/project/evalrouter/)
12
+ (`uv tool install --prerelease allow evalrouter`), which depends on this package at the
13
+ same version.
14
+
15
+ ## Python client
16
+
17
+ Install this alpha with `python -m pip install --pre evalrouter-sdk` in your application's environment. The
18
+ import name is `evalrouter`; the client supports context-manager cleanup:
19
+
20
+ Canonical imports require a release containing this namespace. Older registry
21
+ releases through 0.3.24 use `kimpton_evalrouter`. Select alpha releases explicitly
22
+ to use the canonical `evalrouter` import and current tracing APIs.
23
+
24
+ ```python
25
+ import os
26
+ from evalrouter import Client
27
+
28
+ with Client(
29
+ base_url="https://api.evalrouter.ai",
30
+ api_key=os.environ["EVALROUTER_API_KEY"],
31
+ workspace_id=os.environ["EVALROUTER_WORKSPACE_ID"],
32
+ ) as client:
33
+ print(client.catalog.models())
34
+ ```
35
+
36
+ Use `client.catalog`, `client.evals`, `client.quotes` and `client.runs` for
37
+ typed discovery, submission and result resources. Creating a quote starts no evaluation; submitting its accepted
38
+ ID can start paid work. Keep the quote ID and idempotency key before submission.
39
+ The [model API guide](https://evalrouter.ai/developers/docs/model-api) describes
40
+ request fields, limits and result contracts.
41
+
42
+ `client.catalog.resolve_benchmark(name)` and `resolve_model(name, benchmark=...)`
43
+ resolve the names the command line accepts, without prompting.
44
+ `client.runs.follow(run_id)` yields a run's events until it ends;
45
+ `client.evaluation_jobs.wait(job_id)` waits for a multi-model job; `report_url`
46
+ on runs and evaluation jobs returns the web report, where the charts are drawn.
47
+
48
+ Resources and imports are stable or preview. Preview ones (including
49
+ `evalrouter.agents` and `evalrouter.tracing`) are supported but may change in a
50
+ minor release. The [Python SDK guide](https://evalrouter.ai/developers/docs/python#stability-tiers)
51
+ lists each tier and the deprecation notes for entries that left stable.
52
+
53
+ ## Evaluate an agent you run
54
+
55
+ `evalrouter.agents` evaluates an agent on EvalRouter tasks while the agent runs
56
+ on your machine. EvalRouter delivers each task, meters every model call through
57
+ the run's gateway (managed models only), grades the submission with the
58
+ benchmark's own grader and records the trajectory. It is available where your
59
+ workspace has agent evaluation enabled; otherwise quoting refuses with
60
+ `client_run_unavailable`.
61
+
62
+ The agent can be an ACP Registry agent (`registry_agent("opencode")`), any
63
+ local ACP command (`local_agent("my-agent --acp")`, which needs
64
+ `evalrouter-sdk[agents]`), or an agent written in Python:
65
+
66
+ ```python
67
+ from evalrouter import Client, agents
68
+
69
+
70
+ class Solver(agents.Agent):
71
+ name = "my solver"
72
+
73
+ async def run(self, context):
74
+ task = await context.task.task()
75
+ reply = await context.gateway.chat(messages=task["messages"])
76
+ await context.task.submit(reply["choices"][0]["message"]["content"])
77
+ await context.task.done()
78
+
79
+
80
+ client = Client()
81
+ evaluation = agents.quote(
82
+ client,
83
+ agent=Solver(),
84
+ model="ADMITTED_ROUTE_ID",
85
+ tasks=agents.benchmark("eval://PROVIDER/NAME/VERSION"),
86
+ coverage={"mode": "sample", "sample_count": 3, "seed": 42},
87
+ budget_usd="2",
88
+ )
89
+ # Review evaluation.quote before starting; nothing is charged until start().
90
+ run = evaluation.start()
91
+ for event in run.events(): # or: async for event in run.events_async()
92
+ print(event.type, event.task_ref, event.failure_code or "")
93
+ print(run.wait()["status"], run.results())
94
+ ```
95
+
96
+ Tasks can also come from an environment version (`agents.environment(REF,
97
+ split="test")`), your private benchmarks (`agents.private_benchmark(ID)`) or a
98
+ suite. `context.task` offers the attempt's task tools (`call`, `list`,
99
+ `instructions`, `task`, `submit`, `done`); file tasks are written in
100
+ `context.workspace`. `context.gateway` is OpenAI chat-compatible
101
+ (`gateway.openai()` returns an `AsyncOpenAI` client when `openai` is installed).
102
+ Leaving the event loop early finishes the attempt in flight as an interrupted
103
+ controller; `agents.AgentRun.resume(client, RUN_ID, agent)` continues the run
104
+ with the same agent, and `run.cancel()` stops it. `run.costs()`,
105
+ `run.export("csv")`, `run.trajectories()` and `agents.compare(client, [run_a,
106
+ run_b])` read the finalized results. `agents.evaluate(...)` does all of this in
107
+ one call. Its result's `status` and `succeeded` report the run's outcome: a
108
+ failed, partial or abandoned run is returned with `succeeded` false, as
109
+ `runs.wait` returns it, not raised. The CLI's `evalrouter run --agent` uses the
110
+ same functions and exits 0 only for a completed run (1 when it failed, 4
111
+ otherwise).
112
+
113
+ ## Import LangSmith traces
114
+
115
+ The optional `langsmith` extra provides a local connector for completed agent
116
+ runs. Where your workspace has Traces, create an SDK destination connection in
117
+ **Traces → Connect agent**, then supply `LANGSMITH_API_KEY` and the connection's
118
+ EvalRouter environment variables through your secret manager. The source key
119
+ is never sent to EvalRouter.
120
+
121
+ ```sh
122
+ python -m pip install --pre 'evalrouter-sdk[langsmith]'
123
+ python -m evalrouter.langsmith projects
124
+ python -m evalrouter.langsmith sync --project 'YOUR_PROJECT_ID' \
125
+ --state './.private/evalrouter-langsmith-state.json' --metadata-only --watch
126
+ ```
127
+
128
+ The process must stay running for automatic imports. Its private checkpoint
129
+ resumes progress across restarts. Set `--since` to an ISO timestamp to choose
130
+ the initial import window. This explicit metadata-only mode omits source names,
131
+ inputs, outputs, error text, tags, events and arbitrary metadata. Hierarchy,
132
+ timing, error status and reported numeric usage remain. The compatibility default
133
+ captures bounded field-name-redacted content if `--metadata-only` is omitted.
134
+
135
+ Checkpoint version 2 binds the content policy and destination. Unknown
136
+ acknowledgments replay a private adjacent `.delivery.json` payload unchanged;
137
+ keep it with the checkpoint. A policy change on an existing checkpoint is
138
+ refused. Version 1 upgrades only in its original content-capture mode and cannot
139
+ restore payload bytes lost by the older connector. Finish unresolved deliveries
140
+ before using a new checkpoint and connection for a different policy. Only
141
+ activity recorded by LangSmith can be imported; two stable closed reads are
142
+ observed coverage, not proof that every upstream child exists.
143
+
144
+ ## Live agent capture
145
+
146
+ Install the alpha with `python -m pip install --pre 'evalrouter-sdk[tracing]'` in your agent's own environment.
147
+ Configure `EVALROUTER_BASE_URL`, `EVALROUTER_WORKSPACE_ID`,
148
+ `EVALROUTER_TRACE_CONNECTION_ID` and the restricted `EVALROUTER_TRACE_KEY` through
149
+ an authorized secret manager. Install alpha releases explicitly; an ordinary install selects the stable release.
150
+
151
+ ```python
152
+ import json
153
+ import os
154
+ from anthropic import Anthropic
155
+ from evalrouter.tracing import TraceCapture
156
+
157
+ # Also install anthropic, and supply ANTHROPIC_API_KEY privately.
158
+ model = Anthropic(max_retries=0)
159
+ capture = TraceCapture(capture_content=True)
160
+ with capture.agent("Support assistant") as root:
161
+ root.input({"message": "Explain what an evaluation benchmark is."})
162
+ with capture.model(os.environ["ANTHROPIC_MODEL"]) as span:
163
+ answer = model.messages.create(
164
+ model=os.environ["ANTHROPIC_MODEL"], max_tokens=256,
165
+ messages=[{"role": "user", "content": "Explain what an evaluation benchmark is."}],
166
+ )
167
+ text = "".join(block.text for block in answer.content if block.type == "text")
168
+ span.output({"answer": text})
169
+ root.output({"answer": text})
170
+ receipt = capture.seal(root.trace_id)
171
+ print(json.dumps(receipt))
172
+ if receipt["state"] != "accepted" or not receipt["complete"] or not capture.close():
173
+ raise SystemExit(1)
174
+ ```
175
+
176
+ This example makes a real paid model request. Content capture is explicitly
177
+ enabled; use `capture_content=False` to omit input, output and error payloads.
178
+ Caller attributes still require your metadata policy.
179
+ Common secret field names are redacted, but secrets in arbitrary text cannot be
180
+ detected. Content capture defaults to true; select metadata-only explicitly.
181
+
182
+ Root exit and `flush()` do not seal. Join owned children, then `seal(root.trace_id)`
183
+ to acknowledge closure. `receipt(root.trace_id)` reports local delivery state,
184
+ counts, accepted server UUID and server completion, independently of evaluation
185
+ completion. Unknown acknowledgments retain identical batches for later
186
+ flush/seal/close on the same instance. Zero newly inserted spans on replay is
187
+ success. `close()` returns false while active, failed or unknown, and true after
188
+ acknowledged closure and shutdown. A context manager calls close, but does not
189
+ raise on a false result; inspect receipts explicitly. There is no background HTTP
190
+ export. Buffers are process-local; retry before exit. Each instance retains at
191
+ most 64 local trace receipts, 512 active spans and 16 MiB of pending records.
192
+ When another root needs room, the oldest successfully sealed idle receipt is
193
+ evicted. Save the receipt/server UUID if you need it later; `receipt(id)` raises
194
+ `ValueError` after eviction. Pending, unknown, active or dropped traces are never
195
+ evicted. If all 64 are unsettled, a new root is not recorded (its handle has no
196
+ trace ID and `failed_exports` increases); resolve delivery or use another instance.
197
+ Late activity inherited from an evicted trace is rejected, never made a new root.
198
+ Close attempts every retained trace within one aggregate deadline and leaves the
199
+ provider alive if any closure fails. Capture loss prevents successful seal. The optional OpenTelemetry dependency stays
200
+ isolated from the base HTTP client.
201
+
202
+ Create a connection under **Traces → Connect agent** where Traces is enabled for
203
+ your workspace. Detailed delivery receipts are described in the trace connection setup in your workspace.
204
+
205
+
206
+ ## Attach existing OpenTelemetry instrumentation
207
+
208
+ Install the alpha `evalrouter-sdk[tracing]` extra into your existing Python
209
+ 3.12/3.13 agent environment. Pass the OTel SDK provider the framework actually
210
+ uses; do not replace its global provider. No agent inheritance or per-call
211
+ EvalRouter wrappers are required for supported spans:
212
+
213
+ ```python
214
+ from evalrouter.tracing import TraceCapture
215
+
216
+ capture = TraceCapture(capture_content=False)
217
+ attachment = capture.attach(existing_provider, scope_names=("your.instrumentation",))
218
+ # Run the already-instrumented agent, then join all owned child work.
219
+ for trace_id in attachment.trace_ids:
220
+ receipt = capture.seal(trace_id)
221
+ print(receipt) # IDs/counts/delivery state only; inspect accepted + complete.
222
+ # At application shutdown, check capture.close(); it never stops existing_provider.
223
+ ```
224
+
225
+ Attachment exports metadata only, even when wrapper content capture is enabled.
226
+ It removes source names, resource attributes, events, prompts, tool arguments,
227
+ results and exception text. It retains original trace/span/parent IDs, closed
228
+ operation/kind/status enums and bounded numeric token counters. Source counters
229
+ are observations, not native usage charges. `evalrouter.otel.status=unset` means
230
+ unknown source success: wire `ok` only means no explicit source ERROR, never a
231
+ native grade or proof that a tool succeeded. Unknown/conflicting kinds are
232
+ counted in `attachment.unsupported_spans` and prevent successful sealing.
233
+ Provider flush queues records; it does not prove accepted ingestion or closure.
234
+
235
+ The optional `[strands]` extra pins Strands for applications that need it; the
236
+ base client has no Strands dependency. Attachment only sees selected spans that
237
+ the supplied provider actually records. It cannot recover unsampled or missing
238
+ work, or capture uninstrumented frameworks automatically. LangSmith project
239
+ imports and ACP evaluation execution are separate integrations.
240
+
241
+ ## Native multi-model client requests
242
+
243
+ Preview the matrix before starting paid work. Save the request and idempotency
244
+ key so an uncertain reply can be recovered without starting another job.
245
+
246
+ ```python
247
+ from evalrouter import Client
248
+
249
+ with Client() as client:
250
+ request = {
251
+ "name": "Model comparison",
252
+ "candidates": [
253
+ {"model": {"kind": "managed", "route_id": "YOUR_FIRST_ROUTE"}},
254
+ {"model": {"kind": "managed", "route_id": "YOUR_SECOND_ROUTE"}},
255
+ ],
256
+ "evaluations": [{
257
+ "selection": {"profile_ids": ["YOUR_EXACT_NATIVE_PROFILE"]},
258
+ "coverage": {"mode": "sample", "sample_count": 1, "seed": 42},
259
+ }],
260
+ }
261
+ preview = client.evaluation_jobs.preflight(request)
262
+ if preview["supported"]:
263
+ job = client.evaluation_jobs.start(
264
+ {**request, "preflight_digest": preview["digest"]},
265
+ idempotency_key="persist-this-job-request-key",
266
+ )
267
+ print(job["id"])
268
+ ```
269
+
270
+ The job's selected models or agents and benchmarks stay together in the results
271
+ board. Each runnable pair has its own run and receipt. Charges draw from the
272
+ workspace wallet as work proceeds. Existing capped quotes keep their terms.
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["hatchling==1.27.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "evalrouter-sdk"
7
+ version = "0.4.4a1"
8
+ description = "The EvalRouter Python SDK: typed client, agent evaluations and trace capture"
9
+ readme = "README.md"
10
+ license = "LicenseRef-Kimpton-EvalRouter-SDK"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.12,<3.14"
13
+ keywords = ["evalrouter", "model-evaluation", "benchmarks", "sdk", "llm"]
14
+ classifiers = [
15
+ "Intended Audience :: Developers",
16
+ "Intended Audience :: Science/Research",
17
+ "Programming Language :: Python :: 3 :: Only",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Typing :: Typed",
21
+ ]
22
+ # The SDK's base installation is only the HTTP client (exact pin). Terminal
23
+ # rendering and the `evalrouter` command belong to the `evalrouter` CLI
24
+ # distribution (packages/python-cli). The import name stays `evalrouter`. Validation stays out: the published wheel bundles the
25
+ # normative `evalrouter_contracts` modules, but their one dependency (pydantic)
26
+ # arrives only through the optional `[benchmark]` extra, never through this list.
27
+ dependencies = ["httpx==0.28.1"]
28
+
29
+ [project.urls]
30
+ Homepage = "https://evalrouter.ai"
31
+ Documentation = "https://evalrouter.ai/developers/docs/python"
32
+ "Model API" = "https://evalrouter.ai/developers/docs/model-api"
33
+
34
+ [project.optional-dependencies]
35
+ tracing = ["opentelemetry-api==1.45.0", "opentelemetry-sdk==1.45.0"]
36
+ # Optional only: existing Strands apps can instead install [tracing].
37
+ strands = ["opentelemetry-api==1.45.0", "opentelemetry-sdk==1.45.0", "strands-agents==1.57.2"]
38
+ # Exactly the internal contracts package's own dependency list
39
+ # (packages/contracts/pyproject.toml); build_packages.py refuses any drift.
40
+ benchmark = ["pydantic==2.13.5"]
41
+ # Agent evaluations (`evalrouter.agents`): the ACP SDK the bundled controller
42
+ # (packages/agents acp_client.py) is pinned to, and its one dependency.
43
+ agents = ["agent-client-protocol==0.12.1", "pydantic==2.13.5"]
44
+ # Pull LangSmith projects into a local EvalRouter live trace connection.
45
+ langsmith = ["langsmith==0.12.6"]
46
+
47
+ [tool.hatch.build.targets.wheel]
48
+ packages = ["src/evalrouter", "src/kimpton_evalrouter", "src/evalrouter_contracts"]