diff --git a/.agents/skills/sdk-vcr-workflows/SKILL.md b/.agents/skills/sdk-vcr-workflows/SKILL.md index daaa2a23f..5be3298df 100644 --- a/.agents/skills/sdk-vcr-workflows/SKILL.md +++ b/.agents/skills/sdk-vcr-workflows/SKILL.md @@ -184,6 +184,29 @@ Bad reasons to re-record: If a cassette diff is large, verify that the behavioral change is truly intended before keeping it. +## When Recording Fails + +Live recording fails for reasons unrelated to the SDK change. Handle each case so a failed recording does not destroy a good cassette or leave a bad one behind. + +- **Missing or invalid API key (401/403, auth errors):** stop and ask the user for a working key. Never hand-write or edit a cassette to stand in for a recording. +- **Quota or rate limits (429, 402 "no remaining credits"):** a cassette that captured an error response is worse than the old one. Delete only the cassettes that captured the error, wait or ask for another key, then refill them with the default `once` mode. +- **Retired models or upstream drift:** if the live API no longer returns what the test asserts (a retired model returns 404, a moderation block, a search result that no longer appears, a different stop reason), keep the old cassette with `git checkout` and tell the user. Do not loosen the assertion just to get a recording. +- **Hand-authored cassettes:** some cassettes are hand-edited to force a scenario such as a validation retry. Never re-record them; restore them with `git checkout`. + +### Restore from git vs. re-record + +- Restore from git when the cassette is hand-authored, upstream behavior drifted, or the provider is unusable locally (no key, no quota). The old cassette still matches the request the SDK sends. +- Re-record when the SDK's request shape intentionally changed, or when the new pin changes the wire format and playback fails. +- If some tests in a directory may fail to record, record without deleting the directory first, so failed tests keep their old cassettes. If a test fails partway through, `git checkout` its cassette, because a partial refresh can leave truncated files. +- After any refresh, run `git status` on the cassette directory and look for ` D` entries (cassettes deleted but never recreated). + +### Traps that silently lose cassettes + +- **Skipped sessions record nothing.** If a session skips on your Python version (see `_skip_if_incompatible` and the constraints in `py/noxfile.py`), deleting its cassettes first destroys them. Run nox from a compatible interpreter instead. +- **Multi-file sessions stop at the first failing file.** After a partial failure, re-run in `once` mode to fill the files that later test files never recorded. +- **Shared cassette names under `--vcr-record=all`.** When several parametrizations share a cassette name, later cases read an earlier case's response. Delete only those cassettes and re-run in `once` mode, so the first case of each name records and the rest replay. +- **Hangs.** Tests that drive long-lived live sessions can hang while recording. Exclude them with `-k "not "` and keep their old cassettes. + ## Narrow Recording Strategy When you need new traffic, record the smallest thing possible: diff --git a/AGENTS.md b/AGENTS.md index 66167bc58..bb592589d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,6 +32,8 @@ Use this file as the default playbook for work in this repository. - This includes bugs in tracing/span shaping that happen after the SDK returns a real provider payload. If the behavior depends on the provider's actual response shape, treat it as VCR-first work, not mock-first work. - Be actively skeptical of mock/fake tests for provider integrations. Do not reach for mocks just because they are faster or easier to write. - Avoid mocks/fakes unless the code is purely local or there is no practical cassette-based option. + - Hand-written stand-ins for provider or framework objects count as fakes, even without `unittest.mock`: a plain function posing as a tool, a stub client or transport, or a dict/object built by hand to look like a provider response. Use the library's real classes (for example its built-in tools and real clients) and drive them with cassettes. + - Never use `MagicMock`/`Mock` in provider integration tests (`py/src/braintrust/integrations//test_*.py`). Shared helper unit tests such as `integrations/test_utils.py` are purely local and exempt. A narrow `monkeypatch` to inject an error path that recordings cannot provoke is still allowed. 7. **Do not assume optional provider packages are installed.** - Rely on the active nox session to install what it needs. diff --git a/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestBatchesResultsSpans.test_batches_results_produces_span[async].yaml b/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestBatchesResultsSpans.test_batches_results_produces_span[async].yaml new file mode 100644 index 000000000..5b465e01c --- /dev/null +++ b/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestBatchesResultsSpans.test_batches_results_produces_span[async].yaml @@ -0,0 +1,1208 @@ +interactions: +- request: + body: '{"requests":[{"custom_id":"req-1","params":{"model":"claude-haiku-4-5-20251001","max_tokens":100,"messages":[{"role":"user","content":"What + is 2+2?"}]}},{"custom_id":"req-2","params":{"model":"claude-haiku-4-5-20251001","max_tokens":100,"messages":[{"role":"user","content":"What + is 3+3?"}]}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '294' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: POST + uri: https://api.anthropic.com/v1/messages/batches + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-ratelimit-batch-requests-limit: + - '500000' + anthropic-ratelimit-batch-requests-remaining: + - '499998' + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e56fec3e92b6-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:20:11 GMT + request-id: + - req_011Cg4xZ7vNGuCwDeR7bd5WE + server: + - cloudflare + server-timing: + - x-originResponse;dur=277 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e5b0dd6636a6-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:20:21 GMT + request-id: + - req_011Cg4xZtVWXGZ6QYrsC81n8 + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=118 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e5f1095eaaf7-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:20:31 GMT + request-id: + - req_011Cg4xaeGmfcnm9qjgVLjAU + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=102 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e630eae04b56-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:20:41 GMT + request-id: + - req_011Cg4xbPxL7KY5Y2fyammS2 + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=103 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e670de0dab54-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:20:52 GMT + request-id: + - req_011Cg4xc9j6h234grEsnxdXQ + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=133 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e6b0e841ab88-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:21:02 GMT + request-id: + - req_011Cg4xcuYqbWpt6BpcfnCNf + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=107 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e6f0d874aadf-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:21:12 GMT + request-id: + - req_011Cg4xdfJ8CpvZAd7kgYHqf + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=118 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e730cda9ec71-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:21:22 GMT + request-id: + - req_011Cg4xeR9bmYNtLTCrpfEAB + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=154 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e770fbfdebc0-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:21:33 GMT + request-id: + - req_011Cg4xfAwMyfoc9NqaDqTAU + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=153 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e7b1af05f80a-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:21:43 GMT + request-id: + - req_011Cg4xfw9fcQC43B1c1p6i9 + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=102 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e7f19e35086a-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:21:53 GMT + request-id: + - req_011Cg4xggsxG9oRNczE8MkNG + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=133 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e831ccd83823-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:22:03 GMT + request-id: + - req_011Cg4xhSq8rytvd8VtWKuYq + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=113 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":2,"errored":0,"canceled":0,"expired":0},"ended_at":"2026-10-16T00:22:08.085125+00:00","created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e871a888103a-YYZ + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:22:14 GMT + request-id: + - req_011Cg4xiCZAz5dKwoiGJdvba + server: + - cloudflare + server-timing: + - x-originResponse;dur=127 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr + response: + body: + string: '{"id":"msgbatch_01GiQDBfJxsnmLJCJgTkouvr","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":2,"errored":0,"canceled":0,"expired":0},"ended_at":"2026-10-16T00:22:08.085125+00:00","created_at":"2026-10-16T00:20:11.136965+00:00","expires_at":"2026-10-17T00:20:11.136965+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e8732d95aa96-YYZ + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:22:14 GMT + request-id: + - req_011Cg4xiDXxuBQLNdnDeJLrT + server: + - cloudflare + server-timing: + - x-originResponse;dur=112 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/binary + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01GiQDBfJxsnmLJCJgTkouvr/results + response: + body: + string: '{"custom_id":"req-2","result":{"type":"succeeded","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Cg4xcLcCRugkyB99jaHyE","type":"message","role":"assistant","content":[{"type":"text","text":"3 + + 3 = 6"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":14,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":13,"service_tier":"batch","inference_geo":"not_available","speed":"standard"},"diagnostics":null}}} + + {"custom_id":"req-1","result":{"type":"succeeded","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Cg4xdEtBYpmLzhJpR3mW5","type":"message","role":"assistant","content":[{"type":"text","text":"2 + + 2 = 4"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":14,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":13,"service_tier":"batch","inference_geo":"not_available","speed":"standard"},"diagnostics":null}}} + + ' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e8743ecbaa96-YYZ + connection: + - keep-alive + content-disposition: + - attachment; filename*=utf-8''msgbatch_01GiQDBfJxsnmLJCJgTkouvr_results.jsonl + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/x-jsonl + date: + - Fri, 16 Oct 2026 00:22:14 GMT + request-id: + - req_011Cg4xiEG7e1tVF5cibyyi7 + server: + - cloudflare + server-timing: + - x-originResponse;dur=171 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +version: 1 diff --git a/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestBatchesResultsSpans.test_batches_results_produces_span[sync].yaml b/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestBatchesResultsSpans.test_batches_results_produces_span[sync].yaml new file mode 100644 index 000000000..7d86b543f --- /dev/null +++ b/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestBatchesResultsSpans.test_batches_results_produces_span[sync].yaml @@ -0,0 +1,1128 @@ +interactions: +- request: + body: '{"requests":[{"custom_id":"req-1","params":{"model":"claude-haiku-4-5-20251001","max_tokens":100,"messages":[{"role":"user","content":"What + is 2+2?"}]}},{"custom_id":"req-2","params":{"model":"claude-haiku-4-5-20251001","max_tokens":100,"messages":[{"role":"user","content":"What + is 3+3?"}]}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '294' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: POST + uri: https://api.anthropic.com/v1/messages/batches + response: + body: + string: '{"id":"msgbatch_01UeR6U8emQcTKwcotaBF3AG","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:18:17.083948+00:00","expires_at":"2026-10-17T00:18:17.083948+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-ratelimit-batch-requests-limit: + - '500000' + anthropic-ratelimit-batch-requests-remaining: + - '499998' + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e2a6eb640702-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:18:17 GMT + request-id: + - req_011Cg4xQiH6fP1ALowQUy2nJ + server: + - cloudflare + server-timing: + - x-originResponse;dur=298 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG + response: + body: + string: '{"id":"msgbatch_01UeR6U8emQcTKwcotaBF3AG","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:18:17.083948+00:00","expires_at":"2026-10-17T00:18:17.083948+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e2e89c1e0c69-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:18:27 GMT + request-id: + - req_011Cg4xRVBaVNbfvCjpVdmCY + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=127 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG + response: + body: + string: '{"id":"msgbatch_01UeR6U8emQcTKwcotaBF3AG","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:18:17.083948+00:00","expires_at":"2026-10-17T00:18:17.083948+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e328bed79113-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:18:37 GMT + request-id: + - req_011Cg4xSF1pDE1gSsseMqvSE + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=102 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG + response: + body: + string: '{"id":"msgbatch_01UeR6U8emQcTKwcotaBF3AG","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:18:17.083948+00:00","expires_at":"2026-10-17T00:18:17.083948+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e368a849aa71-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:18:47 GMT + request-id: + - req_011Cg4xSzj7NvVa6PbT9Yxat + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=126 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG + response: + body: + string: '{"id":"msgbatch_01UeR6U8emQcTKwcotaBF3AG","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:18:17.083948+00:00","expires_at":"2026-10-17T00:18:17.083948+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e3a92f41aacd-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:18:58 GMT + request-id: + - req_011Cg4xTmAp96px3RpYWQUww + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=213 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG + response: + body: + string: '{"id":"msgbatch_01UeR6U8emQcTKwcotaBF3AG","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:18:17.083948+00:00","expires_at":"2026-10-17T00:18:17.083948+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e3e9ca1e4b56-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:19:08 GMT + request-id: + - req_011Cg4xUX7zTvznC9bpbS2EM + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=93 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG + response: + body: + string: '{"id":"msgbatch_01UeR6U8emQcTKwcotaBF3AG","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:18:17.083948+00:00","expires_at":"2026-10-17T00:18:17.083948+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e429ba65aaf4-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:19:18 GMT + request-id: + - req_011Cg4xVGrH2uiyArkSte45m + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=123 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG + response: + body: + string: '{"id":"msgbatch_01UeR6U8emQcTKwcotaBF3AG","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:18:17.083948+00:00","expires_at":"2026-10-17T00:18:17.083948+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e469be985163-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:19:29 GMT + request-id: + - req_011Cg4xW2dJ445wgyCeCTWaG + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=108 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG + response: + body: + string: '{"id":"msgbatch_01UeR6U8emQcTKwcotaBF3AG","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:18:17.083948+00:00","expires_at":"2026-10-17T00:18:17.083948+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e4a9cadcaae5-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:19:39 GMT + request-id: + - req_011Cg4xWnT33ezaeYVuezT3W + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=157 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG + response: + body: + string: '{"id":"msgbatch_01UeR6U8emQcTKwcotaBF3AG","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:18:17.083948+00:00","expires_at":"2026-10-17T00:18:17.083948+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e4ea8a57ac75-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:19:49 GMT + request-id: + - req_011Cg4xXYkJYxcaBHtTywgnZ + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=115 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG + response: + body: + string: '{"id":"msgbatch_01UeR6U8emQcTKwcotaBF3AG","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:18:17.083948+00:00","expires_at":"2026-10-17T00:18:17.083948+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e52a7a2335ae-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:19:59 GMT + request-id: + - req_011Cg4xYJUqtKi5ZRkbYqH27 + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=145 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG + response: + body: + string: '{"id":"msgbatch_01UeR6U8emQcTKwcotaBF3AG","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":2,"errored":0,"canceled":0,"expired":0},"ended_at":"2026-10-16T00:20:09.136628+00:00","created_at":"2026-10-16T00:18:17.083948+00:00","expires_at":"2026-10-17T00:18:17.083948+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e56abc20ac57-YYZ + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:20:10 GMT + request-id: + - req_011Cg4xZ4QnVFPNakEfBU5WF + server: + - cloudflare + server-timing: + - x-originResponse;dur=113 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG + response: + body: + string: '{"id":"msgbatch_01UeR6U8emQcTKwcotaBF3AG","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":2,"errored":0,"canceled":0,"expired":0},"ended_at":"2026-10-16T00:20:09.136628+00:00","created_at":"2026-10-16T00:18:17.083948+00:00","expires_at":"2026-10-17T00:18:17.083948+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e56c4ac0aa9b-YYZ + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:20:10 GMT + request-id: + - req_011Cg4xZ5Wm2NboQpVUgxHRt + server: + - cloudflare + server-timing: + - x-originResponse;dur=175 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/binary + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.48.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01UeR6U8emQcTKwcotaBF3AG/results + response: + body: + string: '{"custom_id":"req-2","result":{"type":"succeeded","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Cg4xTcLVavt94SJvzedfH","type":"message","role":"assistant","content":[{"type":"text","text":"3 + + 3 = 6"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":14,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":13,"service_tier":"batch","inference_geo":"not_available","speed":"standard"},"diagnostics":null}}} + + {"custom_id":"req-1","result":{"type":"succeeded","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Cg4xTaV87gFkzXdytA1jU","type":"message","role":"assistant","content":[{"type":"text","text":"2 + + 2 = 4"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":14,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":13,"service_tier":"batch","inference_geo":"not_available","speed":"standard"},"diagnostics":null}}} + + ' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2e56ddc54aa9b-YYZ + connection: + - keep-alive + content-disposition: + - attachment; filename*=utf-8''msgbatch_01UeR6U8emQcTKwcotaBF3AG_results.jsonl + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/x-jsonl + date: + - Fri, 16 Oct 2026 00:20:10 GMT + request-id: + - req_011Cg4xZ6ZWi6Te7nLMLCwqa + server: + - cloudflare + server-timing: + - x-originResponse;dur=186 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +version: 1 diff --git a/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/test_anthropic_messages_create_stream_true.yaml b/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/test_anthropic_messages_create_stream_true.yaml deleted file mode 100644 index c34401395..000000000 --- a/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/test_anthropic_messages_create_stream_true.yaml +++ /dev/null @@ -1,148 +0,0 @@ -interactions: - - request: - body: '{"max_tokens":300,"messages":[{"role":"user","content":"What is 3*4?"}],"model":"claude-3-haiku-20240307","stream":true}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate - anthropic-version: - - "2023-06-01" - connection: - - keep-alive - content-length: - - "120" - content-type: - - application/json - host: - - api.anthropic.com - user-agent: - - Anthropic/Python 0.52.1 - x-stainless-arch: - - arm64 - x-stainless-async: - - "false" - x-stainless-lang: - - python - x-stainless-os: - - MacOS - x-stainless-package-version: - - 0.52.1 - x-stainless-read-timeout: - - "600" - x-stainless-retry-count: - - "0" - x-stainless-runtime: - - CPython - x-stainless-runtime-version: - - 3.13.3 - x-stainless-timeout: - - NOT_GIVEN - method: POST - uri: https://api.anthropic.com/v1/messages - response: - body: - string: 'event: message_start - - data: {"type":"message_start","message":{"id":"msg_012gPZeSmoemYgX2fdPcZFVH","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":14,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":4,"service_tier":"standard"}} } - - - event: content_block_start - - data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} } - - - event: ping - - data: {"type": "ping"} - - - event: content_block_delta - - data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"3 - *"} } - - - event: content_block_delta - - data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" - 4 ="} } - - - event: content_block_delta - - data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" - 12"} } - - - event: content_block_stop - - data: {"type":"content_block_stop","index":0 } - - - event: message_delta - - data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":13} } - - - event: message_stop - - data: {"type":"message_stop" } - - - ' - headers: - CF-RAY: - - 9472c88a8f806a50-EWR - Cache-Control: - - no-cache - Connection: - - keep-alive - Content-Type: - - text/event-stream; charset=utf-8 - Date: - - Thu, 29 May 2025 03:07:45 GMT - Server: - - cloudflare - Transfer-Encoding: - - chunked - X-Robots-Tag: - - none - anthropic-organization-id: - - 27796668-7351-40ac-acc4-024aee8995a5 - anthropic-ratelimit-input-tokens-limit: - - "8000000" - anthropic-ratelimit-input-tokens-remaining: - - "8000000" - anthropic-ratelimit-input-tokens-reset: - - "2025-05-29T03:07:45Z" - anthropic-ratelimit-output-tokens-limit: - - "1500000" - anthropic-ratelimit-output-tokens-remaining: - - "1500000" - anthropic-ratelimit-output-tokens-reset: - - "2025-05-29T03:07:45Z" - anthropic-ratelimit-requests-limit: - - "10000" - anthropic-ratelimit-requests-remaining: - - "9999" - anthropic-ratelimit-requests-reset: - - "2025-05-29T03:07:45Z" - anthropic-ratelimit-tokens-limit: - - "9500000" - anthropic-ratelimit-tokens-remaining: - - "9500000" - anthropic-ratelimit-tokens-reset: - - "2025-05-29T03:07:45Z" - cf-cache-status: - - DYNAMIC - request-id: - - req_011CPb5qta7AfiZd2KcxncsY - strict-transport-security: - - max-age=31536000; includeSubDomains; preload - via: - - 1.1 google - status: - code: 200 - message: OK -version: 1 diff --git a/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/test_anthropic_messages_sync.yaml b/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/test_anthropic_messages_sync.yaml deleted file mode 100644 index 95676479a..000000000 --- a/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/test_anthropic_messages_sync.yaml +++ /dev/null @@ -1,105 +0,0 @@ -interactions: - - request: - body: '{"max_tokens":300,"messages":[{"role":"user","content":"what''s 2+2?"}],"model":"claude-3-haiku-20240307"}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate - anthropic-version: - - "2023-06-01" - connection: - - keep-alive - content-length: - - "105" - content-type: - - application/json - host: - - api.anthropic.com - user-agent: - - Anthropic/Python 0.52.1 - x-stainless-arch: - - arm64 - x-stainless-async: - - "false" - x-stainless-lang: - - python - x-stainless-os: - - MacOS - x-stainless-package-version: - - 0.52.1 - x-stainless-read-timeout: - - "600" - x-stainless-retry-count: - - "0" - x-stainless-runtime: - - CPython - x-stainless-runtime-version: - - 3.13.3 - x-stainless-timeout: - - "600" - method: POST - uri: https://api.anthropic.com/v1/messages - response: - body: - string: !!binary | - H4sIAAAAAAAAA2SPQUsDMRSE/8ucs2W7XRRyKx4KVYseeqlICMljG7tN1rwXUZb977LFguLpwXwz - w5sRwUPjzJ2pl0/dw/5wv2n228fd3fN6sw4+H96gIF8DzS5ith1BIad+FixzYLFRoHBOnnpouN4W - T9WqOtpwKlVTN229qm+h4FIUigL9Ml4bhT7n7OVotAtMrwosaTCZLKcIDYreSMkRP4DpvVB0BB1L - 3yuUy0t6RIhDESPpRJGhl62Cs+5IxmWyElI0fw31lWey/j9LRX4rNwpM+SM4MhIoQ2Pe7W32mKZv - AAAA//8DAOBQupxFAQAA - headers: - CF-RAY: - - 9472c8abe82e4346-EWR - Connection: - - keep-alive - Content-Encoding: - - gzip - Content-Type: - - application/json - Date: - - Thu, 29 May 2025 03:07:51 GMT - Server: - - cloudflare - Transfer-Encoding: - - chunked - X-Robots-Tag: - - none - anthropic-organization-id: - - 27796668-7351-40ac-acc4-024aee8995a5 - anthropic-ratelimit-input-tokens-limit: - - "8000000" - anthropic-ratelimit-input-tokens-remaining: - - "8000000" - anthropic-ratelimit-input-tokens-reset: - - "2025-05-29T03:07:51Z" - anthropic-ratelimit-output-tokens-limit: - - "1500000" - anthropic-ratelimit-output-tokens-remaining: - - "1500000" - anthropic-ratelimit-output-tokens-reset: - - "2025-05-29T03:07:51Z" - anthropic-ratelimit-requests-limit: - - "10000" - anthropic-ratelimit-requests-remaining: - - "9999" - anthropic-ratelimit-requests-reset: - - "2025-05-29T03:07:51Z" - anthropic-ratelimit-tokens-limit: - - "9500000" - anthropic-ratelimit-tokens-remaining: - - "9500000" - anthropic-ratelimit-tokens-reset: - - "2025-05-29T03:07:51Z" - cf-cache-status: - - DYNAMIC - request-id: - - req_011CPb5rJW239uEPcCN6bpZm - strict-transport-security: - - max-age=31536000; includeSubDomains; preload - via: - - 1.1 google - status: - code: 200 - message: OK -version: 1 diff --git a/py/src/braintrust/integrations/anthropic/cassettes/latest/TestBatchesResultsSpans.test_batches_results_produces_span[async].yaml b/py/src/braintrust/integrations/anthropic/cassettes/latest/TestBatchesResultsSpans.test_batches_results_produces_span[async].yaml new file mode 100644 index 000000000..3758b11ef --- /dev/null +++ b/py/src/braintrust/integrations/anthropic/cassettes/latest/TestBatchesResultsSpans.test_batches_results_produces_span[async].yaml @@ -0,0 +1,1258 @@ +interactions: +- request: + body: '{"requests":[{"custom_id":"req-1","params":{"model":"claude-haiku-4-5-20251001","max_tokens":100,"messages":[{"role":"user","content":"What + is 2+2?"}]}},{"custom_id":"req-2","params":{"model":"claude-haiku-4-5-20251001","max_tokens":100,"messages":[{"role":"user","content":"What + is 3+3?"}]}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '294' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: POST + uri: https://api.anthropic.com/v1/messages/batches + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-ratelimit-batch-requests-limit: + - '500000' + anthropic-ratelimit-batch-requests-remaining: + - '499998' + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2db57ee48a253-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:13:17 GMT + request-id: + - req_011Cg4x2eM6JS2JGXFLEXKCn + server: + - cloudflare + server-timing: + - x-originResponse;dur=280 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2db9959e33a07-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:13:28 GMT + request-id: + - req_011Cg4x3R6trvXzeyAGSqw3F + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=147 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2dbd97ddd3972-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:13:38 GMT + request-id: + - req_011Cg4x4Axd3pAwWV6deABFy + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=119 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2dc197ac3a238-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:13:48 GMT + request-id: + - req_011Cg4x4vxXiywPgKWhyoB6T + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=174 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2dc5a6d11175c-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:13:58 GMT + request-id: + - req_011Cg4x5hAbX19U7WosYU9XG + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=119 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2dc9a8d6eabee-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:14:09 GMT + request-id: + - req_011Cg4x6T1aHborWuETr8qwA + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=217 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2dcdb38baac48-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:14:19 GMT + request-id: + - req_011Cg4x7DGrjwEnp1mgRmCXn + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=112 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2dd1baddeac75-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:14:29 GMT + request-id: + - req_011Cg4x7yLjZdbzn93yiAsUC + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=128 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2dd5bafa439dd-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:14:40 GMT + request-id: + - req_011Cg4x8jHBL9ew3R2PghmJb + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=160 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2dd9c0a6836b1-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:14:50 GMT + request-id: + - req_011Cg4x9VDruUBMh9o8CSySM + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=127 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2dddc2d58bf5d-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:15:00 GMT + request-id: + - req_011Cg4xAEzNvXmyhK2n4CDoQ + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=106 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2de1bf83564a6-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:15:10 GMT + request-id: + - req_011Cg4xAzhvkbahnYRvVk2GE + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=137 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2de5c9dd057af-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:15:21 GMT + request-id: + - req_011Cg4xBkuFBWHWzU55JWxMt + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=135 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":2,"errored":0,"canceled":0,"expired":0},"ended_at":"2026-10-16T00:15:25.682109+00:00","created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2de9ccee2ebb6-YYZ + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:15:31 GMT + request-id: + - req_011Cg4xCWqS8NFfUCbDeQ3fQ + server: + - cloudflare + server-timing: + - x-originResponse;dur=315 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX + response: + body: + string: '{"id":"msgbatch_01AF5YeWL4wmeXjhitstM6pX","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":2,"errored":0,"canceled":0,"expired":0},"ended_at":"2026-10-16T00:15:25.682109+00:00","created_at":"2026-10-16T00:13:17.713690+00:00","expires_at":"2026-10-17T00:13:17.713690+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2de9f8bc7aa55-YYZ + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:15:31 GMT + request-id: + - req_011Cg4xCYfp2gR5Lr2ESng5p + server: + - cloudflare + server-timing: + - x-originResponse;dur=126 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/binary + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_01AF5YeWL4wmeXjhitstM6pX/results + response: + body: + string: '{"custom_id":"req-1","result":{"type":"succeeded","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Cg4x4PhqVVe7Qi9Q8evyS","type":"message","role":"assistant","content":[{"type":"text","text":"2 + + 2 = 4"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":14,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":13,"service_tier":"batch","inference_geo":"not_available","speed":"standard"},"diagnostics":null}}} + + {"custom_id":"req-2","result":{"type":"succeeded","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Cg4x4PTT9MDfu1Ve14Usb","type":"message","role":"assistant","content":[{"type":"text","text":"3 + + 3 = 6"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":14,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":13,"service_tier":"batch","inference_geo":"not_available","speed":"standard"},"diagnostics":null}}} + + ' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2dea0b808aa55-YYZ + connection: + - keep-alive + content-disposition: + - attachment; filename*=utf-8''msgbatch_01AF5YeWL4wmeXjhitstM6pX_results.jsonl + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/x-jsonl + date: + - Fri, 16 Oct 2026 00:15:32 GMT + request-id: + - req_011Cg4xCZVRmRXNyERgb3oPj + server: + - cloudflare + server-timing: + - x-originResponse;dur=237 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +version: 1 diff --git a/py/src/braintrust/integrations/anthropic/cassettes/latest/TestBatchesResultsSpans.test_batches_results_produces_span[sync].yaml b/py/src/braintrust/integrations/anthropic/cassettes/latest/TestBatchesResultsSpans.test_batches_results_produces_span[sync].yaml new file mode 100644 index 000000000..e573286b8 --- /dev/null +++ b/py/src/braintrust/integrations/anthropic/cassettes/latest/TestBatchesResultsSpans.test_batches_results_produces_span[sync].yaml @@ -0,0 +1,1102 @@ +interactions: +- request: + body: '{"requests":[{"custom_id":"req-1","params":{"model":"claude-haiku-4-5-20251001","max_tokens":100,"messages":[{"role":"user","content":"What + is 2+2?"}]}},{"custom_id":"req-2","params":{"model":"claude-haiku-4-5-20251001","max_tokens":100,"messages":[{"role":"user","content":"What + is 3+3?"}]}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '294' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: POST + uri: https://api.anthropic.com/v1/messages/batches + response: + body: + string: '{"id":"msgbatch_012k3jW1JwstfHLL8QzvHfSw","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:11:23.867612+00:00","expires_at":"2026-10-17T00:11:23.867612+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-ratelimit-batch-requests-limit: + - '500000' + anthropic-ratelimit-batch-requests-remaining: + - '499998' + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2d8907dc0ac33-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:11:23 GMT + request-id: + - req_011Cg4wtFgMe6CS2YrbUvD7H + server: + - cloudflare + server-timing: + - x-originResponse;dur=275 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw + response: + body: + string: '{"id":"msgbatch_012k3jW1JwstfHLL8QzvHfSw","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:11:23.867612+00:00","expires_at":"2026-10-17T00:11:23.867612+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2d8d1dfcbc4c7-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:11:34 GMT + request-id: + - req_011Cg4wu2RutiniuuMDQM7oK + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=138 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw + response: + body: + string: '{"id":"msgbatch_012k3jW1JwstfHLL8QzvHfSw","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:11:23.867612+00:00","expires_at":"2026-10-17T00:11:23.867612+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2d9121d9aabfd-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:11:44 GMT + request-id: + - req_011Cg4wunMc61WqLmGesP8fU + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=115 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw + response: + body: + string: '{"id":"msgbatch_012k3jW1JwstfHLL8QzvHfSw","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:11:23.867612+00:00","expires_at":"2026-10-17T00:11:23.867612+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2d9522de8a21c-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:11:54 GMT + request-id: + - req_011Cg4wvY7dGzXoPnXSzHYH8 + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=118 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw + response: + body: + string: '{"id":"msgbatch_012k3jW1JwstfHLL8QzvHfSw","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:11:23.867612+00:00","expires_at":"2026-10-17T00:11:23.867612+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2d9921c35ac6c-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:12:04 GMT + request-id: + - req_011Cg4wwHtQBU3PCkoTfaJ7E + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=129 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw + response: + body: + string: '{"id":"msgbatch_012k3jW1JwstfHLL8QzvHfSw","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:11:23.867612+00:00","expires_at":"2026-10-17T00:11:23.867612+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2d9d21c2daaee-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:12:15 GMT + request-id: + - req_011Cg4wx3jdCUMSBY86y6gJx + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=158 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw + response: + body: + string: '{"id":"msgbatch_012k3jW1JwstfHLL8QzvHfSw","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:11:23.867612+00:00","expires_at":"2026-10-17T00:11:23.867612+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2da12dbdaaa71-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:12:25 GMT + request-id: + - req_011Cg4wxoyRa1Bu9fNFBVggV + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=123 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw + response: + body: + string: '{"id":"msgbatch_012k3jW1JwstfHLL8QzvHfSw","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:11:23.867612+00:00","expires_at":"2026-10-17T00:11:23.867612+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2da52ddbce5b3-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:12:35 GMT + request-id: + - req_011Cg4wyZjwdELbc886pN8Cg + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=123 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw + response: + body: + string: '{"id":"msgbatch_012k3jW1JwstfHLL8QzvHfSw","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:11:23.867612+00:00","expires_at":"2026-10-17T00:11:23.867612+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2da9339dbe702-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:12:46 GMT + request-id: + - req_011Cg4wzKnLPLstjQ7frMVfh + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=105 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw + response: + body: + string: '{"id":"msgbatch_012k3jW1JwstfHLL8QzvHfSw","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:11:23.867612+00:00","expires_at":"2026-10-17T00:11:23.867612+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2dad309b3375a-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:12:56 GMT + request-id: + - req_011Cg4x15UdkwdymCSXf8DdV + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=119 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw + response: + body: + string: '{"id":"msgbatch_012k3jW1JwstfHLL8QzvHfSw","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-10-16T00:11:23.867612+00:00","expires_at":"2026-10-17T00:11:23.867612+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2db130fa0ddfa-YYZ + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:13:06 GMT + request-id: + - req_011Cg4x1qDREpi52KbHpZFxG + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=130 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw + response: + body: + string: '{"id":"msgbatch_012k3jW1JwstfHLL8QzvHfSw","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":2,"errored":0,"canceled":0,"expired":0},"ended_at":"2026-10-16T00:13:09.106412+00:00","created_at":"2026-10-16T00:11:23.867612+00:00","expires_at":"2026-10-17T00:11:23.867612+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2db532fb2ab04-YYZ + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:13:16 GMT + request-id: + - req_011Cg4x2b68sogvHzYkxbVAB + server: + - cloudflare + server-timing: + - x-originResponse;dur=116 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw + response: + body: + string: '{"id":"msgbatch_012k3jW1JwstfHLL8QzvHfSw","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":2,"errored":0,"canceled":0,"expired":0},"ended_at":"2026-10-16T00:13:09.106412+00:00","created_at":"2026-10-16T00:11:23.867612+00:00","expires_at":"2026-10-17T00:11:23.867612+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2db54bce2ac15-YYZ + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 16 Oct 2026 00:13:17 GMT + request-id: + - req_011Cg4x2c8PjEV51mCpq6ePg + server: + - cloudflare + server-timing: + - x-originResponse;dur=100 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/binary + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.13.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.13.0 + x-stainless-read-timeout: + - '600' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.14.7 + x-stainless-timeout: + - NOT_GIVEN + method: GET + uri: https://api.anthropic.com/v1/messages/batches/msgbatch_012k3jW1JwstfHLL8QzvHfSw/results + response: + body: + string: '{"custom_id":"req-1","result":{"type":"succeeded","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Cg4wubTX25auKkqGK7rz9","type":"message","role":"assistant","content":[{"type":"text","text":"2 + + 2 = 4"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":14,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":13,"service_tier":"batch","inference_geo":"not_available","speed":"standard"},"diagnostics":null}}} + + {"custom_id":"req-2","result":{"type":"succeeded","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Cg4wuYKWG4fKufiyiuLjQ","type":"message","role":"assistant","content":[{"type":"text","text":"3 + + 3 = 6"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":14,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":13,"service_tier":"batch","inference_geo":"not_available","speed":"standard"},"diagnostics":null}}} + + ' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a4b2db55be01ac15-YYZ + connection: + - keep-alive + content-disposition: + - attachment; filename*=utf-8''msgbatch_012k3jW1JwstfHLL8QzvHfSw_results.jsonl + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/x-jsonl + date: + - Fri, 16 Oct 2026 00:13:17 GMT + request-id: + - req_011Cg4x2cr488hptmpdHYj9h + server: + - cloudflare + server-timing: + - x-originResponse;dur=215 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-robots-tag: + - none + status: + code: 200 + message: OK +version: 1 diff --git a/py/src/braintrust/integrations/anthropic/cassettes/latest/test_anthropic_messages_create_stream_true.yaml b/py/src/braintrust/integrations/anthropic/cassettes/latest/test_anthropic_messages_create_stream_true.yaml deleted file mode 100644 index 13722608a..000000000 --- a/py/src/braintrust/integrations/anthropic/cassettes/latest/test_anthropic_messages_create_stream_true.yaml +++ /dev/null @@ -1,156 +0,0 @@ -interactions: -- request: - body: '{"max_tokens":300,"messages":[{"role":"user","content":"What is 3*4?"}],"model":"claude-haiku-4-5-20251001","stream":true}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate, zstd - anthropic-version: - - '2023-06-01' - connection: - - keep-alive - content-length: - - '122' - content-type: - - application/json - host: - - api.anthropic.com - user-agent: - - Anthropic/Python 1.13.0 - x-stainless-arch: - - arm64 - x-stainless-async: - - 'false' - x-stainless-lang: - - python - x-stainless-os: - - MacOS - x-stainless-package-version: - - 1.13.0 - x-stainless-read-timeout: - - '600' - x-stainless-retry-count: - - '0' - x-stainless-runtime: - - CPython - x-stainless-runtime-version: - - 3.14.7 - x-stainless-timeout: - - NOT_GIVEN - method: POST - uri: https://api.anthropic.com/v1/messages - response: - body: - string: 'event: message_start - - data: {"type":"message_start","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011CfzNcn799c4J3KUKUdkHH","type":"message","role":"assistant","content":[],"container":null,"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":14,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":4,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null} } - - - event: content_block_start - - data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}} - - - event: ping - - data: {"type": "ping"} - - - event: content_block_delta - - data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"3 - *"} } - - - event: content_block_delta - - data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" - 4 ="} } - - - event: content_block_delta - - data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" - 12"}} - - - event: content_block_stop - - data: {"type":"content_block_stop","index":0 } - - - event: message_delta - - data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"container":null},"usage":{"input_tokens":14,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":13}} - - - event: message_stop - - data: {"type":"message_stop" } - - - ' - headers: - anthropic-organization-id: - - 27796668-7351-40ac-acc4-024aee8995a5 - anthropic-ratelimit-input-tokens-limit: - - '10000000' - anthropic-ratelimit-input-tokens-remaining: - - '10000000' - anthropic-ratelimit-input-tokens-reset: - - '2026-10-13T14:12:46Z' - anthropic-ratelimit-output-tokens-limit: - - '2000000' - anthropic-ratelimit-output-tokens-remaining: - - '2000000' - anthropic-ratelimit-output-tokens-reset: - - '2026-10-13T14:12:46Z' - anthropic-ratelimit-requests-limit: - - '20000' - anthropic-ratelimit-requests-remaining: - - '19999' - anthropic-ratelimit-requests-reset: - - '2026-10-13T14:12:46Z' - anthropic-ratelimit-tokens-limit: - - '12000000' - anthropic-ratelimit-tokens-remaining: - - '12000000' - anthropic-ratelimit-tokens-reset: - - '2026-10-13T14:12:46Z' - anthropic-workspace-id: - - wrkspc_018bFG1FgNVWqx5pthtdGTzS - cache-control: - - no-cache - cf-cache-status: - - DYNAMIC - cf-ray: - - a49ef0eaa986ac46-YYZ - connection: - - keep-alive - content-length: - - '1456' - content-security-policy: - - default-src 'none'; frame-ancestors 'none' - content-type: - - text/event-stream; charset=utf-8 - date: - - Tue, 13 Oct 2026 14:12:46 GMT - request-id: - - req_011CfzNcmsFgf4vJ5MHjzRga - server: - - cloudflare - strict-transport-security: - - max-age=31536000; includeSubDomains; preload - traceresponse: - - 00-2bbfd482a75211a8ca4fe446511ab729-aa9ea2434cffe03b-01 - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-robots-tag: - - none - status: - code: 200 - message: OK -version: 1 diff --git a/py/src/braintrust/integrations/anthropic/cassettes/latest/test_anthropic_messages_model_params_inputs.yaml b/py/src/braintrust/integrations/anthropic/cassettes/latest/test_anthropic_messages_model_params_inputs.yaml index 56949fa0b..eaabc442d 100644 --- a/py/src/braintrust/integrations/anthropic/cassettes/latest/test_anthropic_messages_model_params_inputs.yaml +++ b/py/src/braintrust/integrations/anthropic/cassettes/latest/test_anthropic_messages_model_params_inputs.yaml @@ -1,7 +1,7 @@ interactions: - request: - body: '{"max_tokens":300,"messages":[{"role":"user","content":"what is 1+1?"}],"model":"claude-haiku-4-5-20251001","stop_sequences":["END"],"system":"just - return the number"}' + body: '{"max_tokens":300,"messages":[{"role":"user","content":"what is 1+1?"}],"model":"claude-haiku-4-5-20251001","stop_sequences":["END"],"system":"Return + just the number, then the word END."}' headers: accept: - application/json @@ -12,7 +12,7 @@ interactions: connection: - keep-alive content-length: - - '167' + - '187' content-type: - application/json host: @@ -43,7 +43,7 @@ interactions: uri: https://api.anthropic.com/v1/messages response: body: - string: '{"model":"claude-haiku-4-5-20251001","id":"msg_011CfzNd8KpkAGWVtoKgbFey","type":"message","role":"assistant","content":[{"type":"text","text":"2"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":18,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":5,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null}' + string: '{"model":"claude-haiku-4-5-20251001","id":"msg_011Cg4vEVTQfFkhtGAdEKm5y","type":"message","role":"assistant","content":[{"type":"text","text":"2\n\n"}],"container":null,"stop_reason":"stop_sequence","stop_sequence":"END","stop_details":null,"usage":{"input_tokens":24,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":4,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}' headers: anthropic-organization-id: - 27796668-7351-40ac-acc4-024aee8995a5 @@ -52,49 +52,49 @@ interactions: anthropic-ratelimit-input-tokens-remaining: - '10000000' anthropic-ratelimit-input-tokens-reset: - - '2026-10-13T14:12:50Z' + - '2026-10-15T23:49:44Z' anthropic-ratelimit-output-tokens-limit: - '2000000' anthropic-ratelimit-output-tokens-remaining: - '2000000' anthropic-ratelimit-output-tokens-reset: - - '2026-10-13T14:12:50Z' + - '2026-10-15T23:49:44Z' anthropic-ratelimit-requests-limit: - '20000' anthropic-ratelimit-requests-remaining: - '19999' anthropic-ratelimit-requests-reset: - - '2026-10-13T14:12:50Z' + - '2026-10-15T23:49:44Z' anthropic-ratelimit-tokens-limit: - '12000000' anthropic-ratelimit-tokens-remaining: - '12000000' anthropic-ratelimit-tokens-reset: - - '2026-10-13T14:12:50Z' + - '2026-10-15T23:49:44Z' anthropic-workspace-id: - wrkspc_018bFG1FgNVWqx5pthtdGTzS cf-cache-status: - DYNAMIC cf-ray: - - a49ef1085942aaf1-YYZ + - a4b2b8d7b944e7e3-YYZ connection: - keep-alive content-length: - - '493' + - '522' content-security-policy: - default-src 'none'; frame-ancestors 'none' content-type: - application/json date: - - Tue, 13 Oct 2026 14:12:50 GMT + - Thu, 15 Oct 2026 23:49:44 GMT request-id: - - req_011CfzNd87BSoMkBrh4RNRTk + - req_011Cg4vEUcoxcRnEfFRCcwtL server: - cloudflare strict-transport-security: - max-age=31536000; includeSubDomains; preload traceresponse: - - 00-e86f9e1772d831203240338886718ca6-fdbf4d83acbbffee-01 + - 00-7033720e592849b25414be502f06ae07-8eef50783e6a08de-01 transfer-encoding: - chunked vary: @@ -105,8 +105,8 @@ interactions: code: 200 message: OK - request: - body: '{"max_tokens":300,"messages":[{"role":"user","content":"what is 1+1?"}],"model":"claude-haiku-4-5-20251001","stop_sequences":["END"],"system":"just - return the number","stream":true}' + body: '{"max_tokens":300,"messages":[{"role":"user","content":"what is 1+1?"}],"model":"claude-haiku-4-5-20251001","stop_sequences":["END"],"system":"Return + just the number, then the word END.","stream":true}' headers: accept: - application/json @@ -117,7 +117,7 @@ interactions: connection: - keep-alive content-length: - - '181' + - '201' content-type: - application/json host: @@ -154,12 +154,12 @@ interactions: body: string: 'event: message_start - data: {"type":"message_start","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011CfzNd9z38GDdakGTZ4H7A","type":"message","role":"assistant","content":[],"container":null,"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":18,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":2,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null} } + data: {"type":"message_start","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Cg4vEXVhPdfgw2KyZSvgB","type":"message","role":"assistant","content":[],"container":null,"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":24,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":2,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null} } event: content_block_start - data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} } + data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} } event: ping @@ -169,23 +169,27 @@ interactions: event: content_block_delta - data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"2"} - } + data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"2"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"\n\n"} } event: content_block_stop - data: {"type":"content_block_stop","index":0 } + data: {"type":"content_block_stop","index":0 } event: message_delta - data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"container":null},"usage":{"input_tokens":18,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":5} } + data: {"type":"message_delta","delta":{"stop_reason":"stop_sequence","stop_sequence":"END","stop_details":null,"container":null},"usage":{"input_tokens":24,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":4} } event: message_stop - data: {"type":"message_stop" } + data: {"type":"message_stop" } ' @@ -197,25 +201,25 @@ interactions: anthropic-ratelimit-input-tokens-remaining: - '10000000' anthropic-ratelimit-input-tokens-reset: - - '2026-10-13T14:12:51Z' + - '2026-10-15T23:49:45Z' anthropic-ratelimit-output-tokens-limit: - '2000000' anthropic-ratelimit-output-tokens-remaining: - '2000000' anthropic-ratelimit-output-tokens-reset: - - '2026-10-13T14:12:51Z' + - '2026-10-15T23:49:45Z' anthropic-ratelimit-requests-limit: - '20000' anthropic-ratelimit-requests-remaining: - '19999' anthropic-ratelimit-requests-reset: - - '2026-10-13T14:12:51Z' + - '2026-10-15T23:49:45Z' anthropic-ratelimit-tokens-limit: - '12000000' anthropic-ratelimit-tokens-remaining: - '12000000' anthropic-ratelimit-tokens-reset: - - '2026-10-13T14:12:51Z' + - '2026-10-15T23:49:45Z' anthropic-workspace-id: - wrkspc_018bFG1FgNVWqx5pthtdGTzS cache-control: @@ -223,25 +227,25 @@ interactions: cf-cache-status: - DYNAMIC cf-ray: - - a49ef10acc57aaf1-YYZ + - a4b2b8dbccefe7e3-YYZ connection: - keep-alive content-length: - - '1205' + - '1368' content-security-policy: - default-src 'none'; frame-ancestors 'none' content-type: - text/event-stream; charset=utf-8 date: - - Tue, 13 Oct 2026 14:12:51 GMT + - Thu, 15 Oct 2026 23:49:45 GMT request-id: - - req_011CfzNd9ndc96vQypXqhxkA + - req_011Cg4vEXJYEreS4x9ue6iYB server: - cloudflare strict-transport-security: - max-age=31536000; includeSubDomains; preload traceresponse: - - 00-5c77a0771912bbdebf3e6498deb6885a-13c27f4a087cd5ea-01 + - 00-b38040c1e499ea675692127f6995314d-0cd4a41aa4bad69a-01 transfer-encoding: - chunked vary: diff --git a/py/src/braintrust/integrations/anthropic/cassettes/latest/test_anthropic_messages_sync.yaml b/py/src/braintrust/integrations/anthropic/cassettes/latest/test_anthropic_messages_sync.yaml deleted file mode 100644 index 996721494..000000000 --- a/py/src/braintrust/integrations/anthropic/cassettes/latest/test_anthropic_messages_sync.yaml +++ /dev/null @@ -1,107 +0,0 @@ -interactions: -- request: - body: '{"max_tokens":300,"messages":[{"role":"user","content":"what''s 2+2?"}],"model":"claude-haiku-4-5-20251001"}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate, zstd - anthropic-version: - - '2023-06-01' - connection: - - keep-alive - content-length: - - '107' - content-type: - - application/json - host: - - api.anthropic.com - user-agent: - - Anthropic/Python 1.13.0 - x-stainless-arch: - - arm64 - x-stainless-async: - - 'false' - x-stainless-lang: - - python - x-stainless-os: - - MacOS - x-stainless-package-version: - - 1.13.0 - x-stainless-read-timeout: - - '600' - x-stainless-retry-count: - - '0' - x-stainless-runtime: - - CPython - x-stainless-runtime-version: - - 3.14.7 - x-stainless-timeout: - - '600' - method: POST - uri: https://api.anthropic.com/v1/messages - response: - body: - string: '{"model":"claude-haiku-4-5-20251001","id":"msg_011CfzNdEsU5DNJNWnzTh4dR","type":"message","role":"assistant","content":[{"type":"text","text":"2 - + 2 = 4"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":14,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":13,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null}' - headers: - anthropic-organization-id: - - 27796668-7351-40ac-acc4-024aee8995a5 - anthropic-ratelimit-input-tokens-limit: - - '10000000' - anthropic-ratelimit-input-tokens-remaining: - - '10000000' - anthropic-ratelimit-input-tokens-reset: - - '2026-10-13T14:12:52Z' - anthropic-ratelimit-output-tokens-limit: - - '2000000' - anthropic-ratelimit-output-tokens-remaining: - - '2000000' - anthropic-ratelimit-output-tokens-reset: - - '2026-10-13T14:12:52Z' - anthropic-ratelimit-requests-limit: - - '20000' - anthropic-ratelimit-requests-remaining: - - '19999' - anthropic-ratelimit-requests-reset: - - '2026-10-13T14:12:52Z' - anthropic-ratelimit-tokens-limit: - - '12000000' - anthropic-ratelimit-tokens-remaining: - - '12000000' - anthropic-ratelimit-tokens-reset: - - '2026-10-13T14:12:52Z' - anthropic-workspace-id: - - wrkspc_018bFG1FgNVWqx5pthtdGTzS - cf-cache-status: - - DYNAMIC - cf-ray: - - a49ef111c96844b0-YYZ - connection: - - keep-alive - content-length: - - '502' - content-security-policy: - - default-src 'none'; frame-ancestors 'none' - content-type: - - application/json - date: - - Tue, 13 Oct 2026 14:12:52 GMT - request-id: - - req_011CfzNdEdLZ1wu4Fxsq8qvP - server: - - cloudflare - strict-transport-security: - - max-age=31536000; includeSubDomains; preload - traceresponse: - - 00-d0a5bd5418c4cc2f2b40b4e274a63013-867d0f8cc56d92eb-01 - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-robots-tag: - - none - status: - code: 200 - message: OK -version: 1 diff --git a/py/src/braintrust/integrations/anthropic/test_anthropic.py b/py/src/braintrust/integrations/anthropic/test_anthropic.py index 3c03794c8..588a5c5e5 100644 --- a/py/src/braintrust/integrations/anthropic/test_anthropic.py +++ b/py/src/braintrust/integrations/anthropic/test_anthropic.py @@ -14,11 +14,7 @@ from braintrust import Attachment, logger from braintrust.integrations.anthropic import AnthropicIntegration, wrap_anthropic from braintrust.integrations.anthropic._utils import _try_to_dict, extract_anthropic_usage -from braintrust.integrations.anthropic.tracing import ( - TracedMessageStream, - _log_message_to_span, - _normalize_anthropic_input, -) +from braintrust.integrations.anthropic.tracing import TracedMessageStream, _normalize_anthropic_input from braintrust.integrations.test_utils import verify_autoinstrument_script from braintrust.span_types import SpanTypeAttribute from braintrust.test_helpers import find_span_by_name, find_spans_by_type, init_test_logger @@ -98,16 +94,10 @@ def _skip_if_messages_parse_unsupported(): def test_wrap_anthropic_preserves_messages_parse_feature_detection(): - class MessagesWithoutParse: - pass - - class FakeAnthropic: - messages = MessagesWithoutParse() + if hasattr(_get_client().messages, "parse"): + pytest.skip("Installed anthropic SDK supports messages.parse") - class FakeAsyncAnthropic: - messages = MessagesWithoutParse() - - for client in (FakeAnthropic(), FakeAsyncAnthropic()): + for client in (_get_client(), _get_async_client()): messages = wrap_anthropic(client).messages assert not hasattr(messages, "parse") with pytest.raises(AttributeError): @@ -182,51 +172,6 @@ def memory_logger(): yield bgl -def test_log_message_to_span_includes_stop_reason_and_stop_sequence(): - span = unittest.mock.MagicMock() - message = SimpleNamespace( - role="assistant", - content=[{"type": "text", "text": "done"}], - model=MODEL, - stop_reason="stop_sequence", - stop_sequence="DONE", - stop_details=None, - usage={ - "input_tokens": 11, - "output_tokens": 7, - "cache_read_input_tokens": 0, - "cache_creation_input_tokens": 0, - "server_tool_use": { - "web_search_requests": 2, - "web_fetch_requests": 1, - }, - }, - ) - - _log_message_to_span(message, span, time_to_first_token=0.123) - - span.log.assert_called_once_with( - output={ - "role": "assistant", - "content": [{"type": "text", "text": "done"}], - "model": MODEL, - "stop_reason": "stop_sequence", - "stop_sequence": "DONE", - }, - metrics={ - "prompt_tokens": 11.0, - "completion_tokens": 7.0, - "prompt_cached_tokens": 0.0, - "prompt_cache_creation_tokens": 0.0, - "server_tool_use_web_search_requests": 2.0, - "server_tool_use_web_fetch_requests": 1.0, - "tokens": 18.0, - "time_to_first_token": 0.123, - }, - metadata={}, - ) - - class _ToDictOnly: __slots__ = ("_payload",) @@ -823,6 +768,7 @@ async def test_anthropic_messages_reasoning_tokens_metrics( assert span["metadata"]["model"] == LATEST_MODEL assert span["metadata"]["provider"] == "anthropic" assert span["metadata"]["max_tokens"] == params["max_tokens"] + assert span["metadata"].get("stream") is (True if mode == "create_stream" else None) assert span["input"] == params["messages"] assert span["output"]["role"] == "assistant" assert span["output"]["model"] == wire_model @@ -1012,40 +958,6 @@ def test_anthropic_messages_create_with_document_attachment_input(memory_logger) assert PDF_BASE64 not in str(span["input"]) -@pytest.mark.vcr -def test_anthropic_messages_create_stream_true(memory_logger): - assert not memory_logger.pop() - - client = wrap_anthropic(_get_client()) - kws = { - "model": MODEL, - "max_tokens": 300, - "messages": [{"role": "user", "content": "What is 3*4?"}], - "stream": True, - } - - start = time.time() - with client.messages.create(**kws) as out: - msgs = [m for m in out] - end = time.time() - - assert msgs # a very coarse grained check that this works - - spans = memory_logger.pop() - assert len(spans) == 1 - span = spans[0] - assert span["metadata"]["model"] == MODEL - assert span["metadata"]["provider"] == "anthropic" - assert span["metadata"]["max_tokens"] == 300 - assert span["metadata"]["stream"] == True - metrics = span["metrics"] - _assert_metrics_are_valid(metrics, start, end) - assert span["input"] == kws["messages"] - assert span["output"] - assert span["output"]["role"] == "assistant" - assert "12" in span["output"]["content"][0]["text"] - - @pytest.mark.vcr def test_anthropic_messages_create_tracks_structured_outputs_metadata(memory_logger): assert not memory_logger.pop() @@ -1175,6 +1087,7 @@ def test_anthropic_messages_model_params_inputs(memory_logger): kw.update(temperature=0.5, top_p=0.5) else: # Anthropic 1.0 removed temperature and top_p from Messages.create(). + kw["system"] = "Return just the number, then the word END." kw["stop_sequences"] = ["END"] def _with_messages_create(): @@ -1188,7 +1101,7 @@ def _with_messages_stream(): for f in [_with_messages_create, _with_messages_stream]: msg = f() - assert msg.content[0].text == "2" + assert msg.content[0].text.strip() == "2" logs = memory_logger.pop() assert len(logs) == 1 @@ -1207,6 +1120,8 @@ def _with_messages_stream(): assert log["metadata"]["top_p"] == 0.5 else: assert log["metadata"]["stop_sequences"] == ["END"] + assert msg.stop_reason == log["output"]["stop_reason"] == "stop_sequence" + assert msg.stop_sequence == log["output"]["stop_sequence"] == "END" @pytest.mark.vcr @@ -1254,41 +1169,6 @@ def test_anthropic_messages_stream_errors(memory_logger): assert span["metrics"]["end"] > 0 -@pytest.mark.vcr -def test_anthropic_messages_sync(memory_logger): - assert not memory_logger.pop() - - client = wrap_anthropic(_get_client()) - - msg_in = {"role": "user", "content": "what's 2+2?"} - - start = time.time() - msg = client.messages.create(model=MODEL, max_tokens=300, messages=[msg_in]) - end = time.time() - - text = msg.content[0].text - assert text - - # verify we generated the right spans. - logs = memory_logger.pop() - - assert len(logs) == 1 - log = logs[0] - assert "2+2" in str(log["input"]) - assert "4" in str(log["output"]) - assert log["project_id"] == PROJECT_NAME - assert log["span_id"] - assert log["root_span_id"] - attrs = log["span_attributes"] - assert attrs["type"] == "llm" - assert "anthropic" in attrs["name"] - metrics = log["metrics"] - _assert_metrics_are_valid(metrics, start, end) - assert log["metadata"]["model"] == MODEL - assert log["output"]["model"] == msg.model - assert log["output"]["stop_reason"] == msg.stop_reason - - @pytest.mark.vcr def test_anthropic_messages_sync_server_tool_spans(memory_logger): _skip_if_server_tool_content_blocks_unsupported() @@ -1683,12 +1563,12 @@ def test_auto_instrument_anthropic(self): verify_autoinstrument_script("test_auto_anthropic.py") -def _make_batch_requests(): +def _make_batch_requests(model=MODEL): return [ { "custom_id": "req-1", "params": { - "model": MODEL, + "model": model, "max_tokens": 100, "messages": [{"role": "user", "content": "What is 2+2?"}], }, @@ -1696,7 +1576,7 @@ def _make_batch_requests(): { "custom_id": "req-2", "params": { - "model": MODEL, + "model": model, "max_tokens": 100, "messages": [{"role": "user", "content": "What is 3+3?"}], }, @@ -1797,35 +1677,43 @@ def test_sync_batches_create_multi_model_metadata(self, memory_logger): class TestBatchesResultsSpans: """Tests verifying that batches.results() produces correct spans. - Mocked because the batch results API requires a completed batch, and batches - can take up to 24 hours to finish processing. + The success test creates its own small batch and polls until it ends, so the + cassette only ever contains this suite's requests. Small batches usually end + within a few minutes; polls only sleep while recording. """ + @pytest.mark.vcr @pytest.mark.asyncio # The sync case passes the batch id positionally and the async case by keyword, # covering both argument-extraction paths. - @pytest.mark.parametrize( - "is_async,batches_class,positional", - [(False, "Batches", True), (True, "AsyncBatches", False)], - ids=["sync", "async"], - ) - async def test_batches_results_produces_span(self, memory_logger, is_async, batches_class, positional): - assert not memory_logger.pop() + @pytest.mark.parametrize("is_async,positional", [(False, True), (True, False)], ids=["sync", "async"]) + async def test_batches_results_produces_span(self, memory_logger, vcr_cassette, is_async, positional): + raw_client = _get_client() + # On older SDK versions MODEL is the retired LEGACY_MODEL, whose batch requests now error. + batch = raw_client.messages.batches.create(requests=_make_batch_requests(LATEST_MODEL)) + deadline = time.time() + 15 * 60 + while batch.processing_status != "ended": + assert time.time() < deadline, f"batch {batch.id} did not end within 15 minutes" + if not vcr_cassette.write_protected: + time.sleep(10) + batch = raw_client.messages.batches.retrieve(batch.id) + batch_id = batch.id + # Drop setup spans: test_setup_creates_spans may have auto-instrumented the raw client. + memory_logger.pop() client = wrap_anthropic(_get_async_client() if is_async else _get_client()) - mock_decoder = unittest.mock.MagicMock() - with unittest.mock.patch( - f"anthropic.resources.messages.batches.{batches_class}.results", - return_value=mock_decoder, - ): - if positional: - result = client.messages.batches.results("msgbatch_abc123") - else: - result = client.messages.batches.results(message_batch_id="msgbatch_abc123") - if is_async: - result = await result + if positional: + result = client.messages.batches.results(batch_id) + else: + result = client.messages.batches.results(message_batch_id=batch_id) + if is_async: + result = await result + entries = [entry async for entry in result] + else: + entries = list(result) - assert result is mock_decoder + assert {entry.custom_id for entry in entries} == {"req-1", "req-2"} + assert any(entry.result.type == "succeeded" for entry in entries) spans = memory_logger.pop() assert len(spans) == 1 @@ -1833,7 +1721,7 @@ async def test_batches_results_produces_span(self, memory_logger, is_async, batc assert span["span_attributes"]["name"] == "anthropic.messages.batches.results" assert span["span_attributes"]["type"] == "task" assert span["metadata"]["provider"] == "anthropic" - assert span["input"]["message_batch_id"] == "msgbatch_abc123" + assert span["input"]["message_batch_id"] == batch_id assert span["output"]["type"] == "jsonl_stream" def test_sync_batches_results_logs_error_on_failure(self, memory_logger):