diff --git a/.agents/skills/sdk-integrations/SKILL.md b/.agents/skills/sdk-integrations/SKILL.md index 1f4ed1172..45de794e2 100644 --- a/.agents/skills/sdk-integrations/SKILL.md +++ b/.agents/skills/sdk-integrations/SKILL.md @@ -88,6 +88,7 @@ Declarative setup on the `BaseIntegration` subclass: `name`, `import_names`, `pa - Instrumentation failures (extraction, normalization) must never raise into the user's call path. But do not wrap `span.log(...)` / `span.set_attributes(...)` in try/except — they are boundary-safe. - Treat provider inputs/results/events/headers as untrusted. Don't mutate third-party objects. - Only instrument AI-generation-relevant ops (LLM calls, embeddings, tool exec, media gen, agent runs). +- Explicit provider batch tracing helpers (`start__batch_trace`, `complete__batch_trace`, etc.) MUST be exported from `braintrust.integrations.` (not re-exported from top-level `py/src/braintrust/__init__.py`). - Do not over-serialize. `span.log` already runs `bt_safe_deep_copy` (pydantic, dataclasses, attachments). Log readable dicts/lists/scalars and materialized attachments; no JSON dumps/loads or recursive conversion in tracing code. - Every `llm` span has `metadata.model` and `metadata.provider` (whose pricing applies, not the framework name). - Before writing a usage mapper in a framework integration, check the underlying provider's `tracing.py` for a compatible parser. Reuse it when the payload shape matches, and verify reported usage details against the recording. For example, the OpenAI parser maps Responses `cache_write_tokens` to `prompt_cache_creation_tokens`. diff --git a/py/src/braintrust/integrations/anthropic/__init__.py b/py/src/braintrust/integrations/anthropic/__init__.py index 26b36ba82..59c0e7c7e 100644 --- a/py/src/braintrust/integrations/anthropic/__init__.py +++ b/py/src/braintrust/integrations/anthropic/__init__.py @@ -1,5 +1,10 @@ import warnings +from .batch import ( + complete_anthropic_batch_trace, + complete_anthropic_batch_trace_async, + start_anthropic_batch_trace, +) from .integration import AnthropicIntegration from .tracing import _wrap_anthropic @@ -18,6 +23,9 @@ def wrap_anthropic_client(client): __all__ = [ "AnthropicIntegration", + "complete_anthropic_batch_trace", + "complete_anthropic_batch_trace_async", + "start_anthropic_batch_trace", "wrap_anthropic", "wrap_anthropic_client", ] diff --git a/py/src/braintrust/integrations/anthropic/batch.py b/py/src/braintrust/integrations/anthropic/batch.py new file mode 100644 index 000000000..06e74fab9 --- /dev/null +++ b/py/src/braintrust/integrations/anthropic/batch.py @@ -0,0 +1,732 @@ +"""Explicit, spec-compliant batch tracing helpers for Anthropic Message Batches. + +These helpers never call Anthropic APIs, never poll, and never fetch results. +The caller owns all provider API calls and passes the resulting batch objects, +input requests, and result entries or JSONL streams to Braintrust. +""" + +import hashlib +import io +import json +import logging +import math +import tempfile +import time +import uuid +from collections.abc import AsyncIterable, Iterable, Mapping +from datetime import datetime, timezone +from typing import Any + +from braintrust._instrumentation import provider_content_allowed +from braintrust.bt_json import bt_dumps +from braintrust.integrations.anthropic._utils import _try_to_dict, extract_anthropic_usage +from braintrust.integrations.anthropic.tracing import ( + _INSTRUMENTATION, + _get_input_from_kwargs, + _get_metadata_from_kwargs, + _message_output, + _usage_served_service_tier, +) +from braintrust.integrations.utils import _service_tier_metadata +from braintrust.logger import ( + NOOP_SPAN, + SpanInternalOptions, + get_span_parent_object, + start_span, + update_span, +) +from braintrust.span_identifier_v4 import SpanComponentsV4 +from braintrust.span_types import SpanTypeAttribute +from braintrust.util import is_numeric + + +log = logging.getLogger(__name__) + +_CONTEXT_VERSION = 1 +_BATCH_SPAN_NAME = "anthropic.batch" +_CHILD_SPAN_NAME = "anthropic.messages.create" +_VALID_RESULT_TYPES = frozenset({"succeeded", "errored", "canceled", "expired"}) +_REQUEST_COUNT_FIELDS = ("processing", "succeeded", "errored", "canceled", "expired") + + +def _get_field(obj: Any, name: str, default: Any = None) -> Any: + if isinstance(obj, Mapping): + return obj.get(name, default) + return getattr(obj, name, default) + + +def _deterministic_digest(*parts: str) -> bytes: + hasher = hashlib.sha256() + for part in parts: + encoded = part.encode("utf-8") + hasher.update(len(encoded).to_bytes(8, "big")) + hasher.update(encoded) + return hasher.digest() + + +def _digest_uuid(digest: bytes) -> str: + return str(uuid.UUID(bytes=digest[:16], version=4)) + + +def _digest_hex(digest: bytes, num_bytes: int) -> str: + return digest[:num_bytes].hex() + + +def _request_ids_digest(custom_ids: Iterable[str]) -> str: + return _deterministic_digest(*sorted(custom_ids)).hex() + + +def _parse_timestamp(value: Any) -> float | None: + if value is None or isinstance(value, bool): + return None + if isinstance(value, datetime): + dt = value if value.tzinfo is not None else value.replace(tzinfo=timezone.utc) + ts = dt.timestamp() + return ts if math.isfinite(ts) else None + if isinstance(value, (int, float)): + ts = float(value) + return ts if math.isfinite(ts) else None + if isinstance(value, str): + text = value.strip() + if not text: + return None + try: + if text.endswith("Z"): + text = text[:-1] + "+00:00" + dt = datetime.fromisoformat(text) + if dt.tzinfo is None: + dt = dt.replace(tzinfo=timezone.utc) + ts = dt.timestamp() + return ts if math.isfinite(ts) else None + except ValueError: + return None + return None + + +def _extract_request_counts(batch: Any) -> dict[str, int] | None: + raw_counts = _get_field(batch, "request_counts") + if raw_counts is None: + return None + counts: dict[str, int] = {} + for field in _REQUEST_COUNT_FIELDS: + val = _get_field(raw_counts, field) + if isinstance(val, int) and not isinstance(val, bool) and val >= 0: + counts[field] = val + return counts or None + + +def _iter_jsonl_lines(stream: Iterable[str | bytes]) -> Iterable[Any]: + for raw_line in stream: + if isinstance(raw_line, (bytes, bytearray, memoryview)): + line = bytes(raw_line).decode("utf-8").strip() + elif isinstance(raw_line, str): + line = raw_line.strip() + else: + raise TypeError(f"Unsupported JSONL line type: {type(raw_line).__name__}") + if not line: + continue + yield json.loads(line) + + +def _iter_records(source: Any) -> Iterable[Any]: + if isinstance(source, str): + yield from _iter_jsonl_lines(io.StringIO(source)) + return + if isinstance(source, (bytes, bytearray, memoryview)): + yield from _iter_jsonl_lines(io.TextIOWrapper(io.BytesIO(bytes(source)), encoding="utf-8")) + return + if isinstance(source, io.IOBase): + yield from _iter_jsonl_lines(source) + return + if isinstance(source, Iterable) and not isinstance(source, Mapping): + for item in source: + if isinstance(item, str): + stripped = item.strip() + if not stripped: + continue + yield json.loads(stripped) + elif isinstance(item, (bytes, bytearray, memoryview)): + stripped = bytes(item).decode("utf-8").strip() + if not stripped: + continue + yield json.loads(stripped) + else: + yield item + return + raise TypeError(f"Unsupported Anthropic batch record source: {type(source).__name__}") + + +async def _aiter_records(source: Any) -> AsyncIterable[Any]: + if isinstance(source, AsyncIterable): + async for item in source: + if isinstance(item, str): + stripped = item.strip() + if not stripped: + continue + yield json.loads(stripped) + elif isinstance(item, (bytes, bytearray, memoryview)): + stripped = bytes(item).decode("utf-8").strip() + if not stripped: + continue + yield json.loads(stripped) + else: + yield item + return + for item in _iter_records(source): + yield item + + +def _strip_propagated_event(slug: str) -> str: + components = SpanComponentsV4.from_str(slug) + return SpanComponentsV4( + object_type=components.object_type, + object_id=components.object_id, + compute_object_metadata_args=components.compute_object_metadata_args, + row_id=components.row_id, + span_id=components.span_id, + root_span_id=components.root_span_id, + ).to_str() + + +def _task_ids(batch_id: str) -> tuple[str, str, str]: + digest = _deterministic_digest("anthropic:batch", batch_id) + return _digest_uuid(digest), _digest_hex(digest, 8), _digest_hex(digest, 16) + + +def _child_ids(batch_id: str, custom_id: str) -> tuple[str, str]: + digest = _deterministic_digest("anthropic:batch:request", batch_id, custom_id) + return _digest_uuid(digest), _digest_hex(digest, 8) + + +def _child_slug(task_components: SpanComponentsV4, batch_id: str, custom_id: str) -> str: + row_id, span_id = _child_ids(batch_id, custom_id) + return SpanComponentsV4( + object_type=task_components.object_type, + object_id=task_components.object_id, + compute_object_metadata_args=task_components.compute_object_metadata_args, + row_id=row_id, + span_id=span_id, + root_span_id=task_components.root_span_id, + ).to_str() + + +def _extract_error_message(error_obj: Any, default: str) -> str: + if error_obj is None: + return default + if isinstance(error_obj, str): + return error_obj or default + inner = _get_field(error_obj, "error") + target = inner if inner is not None else error_obj + err_type = _get_field(target, "type") + err_msg = _get_field(target, "message") + if isinstance(err_type, str) and err_type and isinstance(err_msg, str) and err_msg: + return f"{err_type}: {err_msg}" + if isinstance(err_msg, str) and err_msg: + return err_msg + if isinstance(err_type, str) and err_type: + return err_type + return default + + +def _build_succeeded_update(message: Any, end_time: float) -> dict[str, Any]: + usage = _get_field(message, "usage") + metrics, metadata = extract_anthropic_usage(usage) + served_service_tier = _usage_served_service_tier(usage) + if served_service_tier is not None: + metadata["served_service_tier"] = served_service_tier + + model = _get_field(message, "model") + if isinstance(model, str) and model: + metadata["model"] = model + + diagnostics = _get_field(message, "diagnostics") + cache_miss_reason = _get_field(diagnostics, "cache_miss_reason") if diagnostics is not None else None + reason_type = _get_field(cache_miss_reason, "type") if cache_miss_reason is not None else None + if reason_type is not None: + metadata["cache_miss_reason"] = reason_type + cache_missed_input_tokens = ( + _get_field(cache_miss_reason, "cache_missed_input_tokens") if cache_miss_reason is not None else None + ) + if is_numeric(cache_missed_input_tokens): + metadata["cache_missed_input_tokens"] = cache_missed_input_tokens + + metrics["end"] = end_time + output = _message_output(message) + event: dict[str, Any] = {"metrics": metrics} + if output is not None: + event["output"] = output + if metadata: + event["metadata"] = metadata + return event + + +def _parse_context(context: str, expected_batch_id: str) -> dict[str, Any] | None: + if not isinstance(context, str) or not context: + return None + try: + parsed = json.loads(context) + except (TypeError, ValueError): + return None + if not isinstance(parsed, dict): + return None + if parsed.get("version") != _CONTEXT_VERSION: + return None + if parsed.get("batch_id") != expected_batch_id: + return None + + start_time = parsed.get("start_time") + if not isinstance(start_time, (int, float)) or isinstance(start_time, bool) or not math.isfinite(start_time): + return None + + request_count = parsed.get("request_count") + if not isinstance(request_count, int) or isinstance(request_count, bool) or request_count <= 0: + return None + + digest = parsed.get("request_ids_digest") + if not isinstance(digest, str) or len(digest) != 64: + return None + try: + bytes.fromhex(digest) + except ValueError: + return None + + task_slug = parsed.get("task") + if not isinstance(task_slug, str) or not task_slug: + return None + try: + task_components = SpanComponentsV4.from_str(task_slug) + except Exception: + return None + + expected_row_id, expected_span_id, _ = _task_ids(expected_batch_id) + if ( + task_components.row_id != expected_row_id + or task_components.span_id != expected_span_id + or not task_components.root_span_id + ): + return None + + return { + "batch_id": expected_batch_id, + "task_slug": task_slug, + "task_components": task_components, + "start_time": float(start_time), + "request_count": request_count, + "request_ids_digest": digest, + } + + +def _start_batch_trace_impl(batch: Any, requests: Any) -> tuple[str, set[str]] | None: + batch_id = _get_field(batch, "id") + if not isinstance(batch_id, str) or not batch_id: + log.debug("Anthropic batch trace skipped: missing batch id") + return None + + parent = get_span_parent_object() + if parent == NOOP_SPAN: + return None + parent_slug = parent.to_str() if isinstance(parent, SpanComponentsV4) else parent.export() + if not parent_slug: + return None + + parent_components = SpanComponentsV4.from_str(parent_slug) + start_time = _parse_timestamp(_get_field(batch, "created_at")) + if start_time is None: + start_time = time.time() + + task_row_id, task_span_id, task_root_span_id = _task_ids(batch_id) + task_metadata: dict[str, Any] = { + "provider": "anthropic", + "batch_id": batch_id, + } + processing_status = _get_field(batch, "processing_status") + if isinstance(processing_status, str) and processing_status: + task_metadata["processing_status"] = processing_status + request_counts = _extract_request_counts(batch) + if request_counts is not None: + task_metadata["request_counts"] = request_counts + + task_internal: SpanInternalOptions = { + "initial_span_write_as_merge": True, + "span_id": task_span_id, + "instrumentation": _INSTRUMENTATION, + } + if not parent_components.span_id: + task_internal["root_span_id"] = task_root_span_id + + task_span = start_span( + name=_BATCH_SPAN_NAME, + parent=parent_slug, + start_time=start_time, + set_current=False, + type=SpanTypeAttribute.TASK, + internal=task_internal, + id=task_row_id, + metadata=task_metadata, + ) + if task_span == NOOP_SPAN: + return None + + task_slug = task_span.export() + seen_ids: set[str] = set() + + for request in _iter_records(requests): + custom_id = _get_field(request, "custom_id") + if not isinstance(custom_id, str) or not custom_id or custom_id in seen_ids: + raise ValueError("Invalid or duplicate custom_id in Anthropic batch requests") + + raw_params = _get_field(request, "params") + params = _try_to_dict(raw_params) + if not isinstance(params, dict) or not isinstance(params.get("model"), str) or not params["model"]: + raise ValueError(f"Invalid params in Anthropic batch request {custom_id!r}") + + child_row_id, child_span_id = _child_ids(batch_id, custom_id) + child_input = _get_input_from_kwargs(params) + child_metadata = _get_metadata_from_kwargs(params) + child_metadata.update(_service_tier_metadata(requested=params.get("service_tier"))) + child_metadata["batch_id"] = batch_id + child_metadata["custom_id"] = custom_id + + start_span( + name=_CHILD_SPAN_NAME, + parent=task_slug, + start_time=start_time, + set_current=False, + type=SpanTypeAttribute.LLM, + internal={ + "initial_span_write_as_merge": True, + "span_id": child_span_id, + "instrumentation": _INSTRUMENTATION, + }, + id=child_row_id, + input=child_input, + metadata=child_metadata, + ) + seen_ids.add(custom_id) + + if not seen_ids: + raise ValueError("Anthropic batch requests must not be empty") + + context_payload = { + "version": _CONTEXT_VERSION, + "batch_id": batch_id, + "task": _strip_propagated_event(task_slug), + "start_time": start_time, + "request_count": len(seen_ids), + "request_ids_digest": _request_ids_digest(seen_ids), + } + return json.dumps(context_payload, separators=(",", ":")), seen_ids + + +def _prepare_completion( + batch: Any, + context: str | None, + requests: Any | None, +) -> tuple[dict[str, Any], set[str] | None, float] | None: + batch_id = _get_field(batch, "id") + if not isinstance(batch_id, str) or not batch_id: + log.debug("Anthropic batch completion skipped: missing batch id") + return None + + processing_status = _get_field(batch, "processing_status") + if processing_status != "ended": + return None + + known_ids: set[str] | None = None + parsed: dict[str, Any] | None = None + if context is not None: + parsed = _parse_context(context, batch_id) + if parsed is None: + log.debug("Invalid or mismatched Anthropic batch trace context for batch %s", batch_id) + if requests is None: + return None + + if parsed is None: + if requests is None: + log.debug("Anthropic batch completion skipped: neither valid context nor requests provided") + return None + started = _start_batch_trace_impl(batch, requests) + if started is None: + return None + created_context, known_ids = started + parsed = _parse_context(created_context, batch_id) + if parsed is None: + return None + + ended_at = _parse_timestamp(_get_field(batch, "ended_at")) + end_time = max(parsed["start_time"], ended_at if ended_at is not None else time.time()) + return parsed, known_ids, end_time + + +def _apply_provider_privacy(event: dict[str, Any]) -> dict[str, Any]: + policy = provider_content_allowed.get() + if policy is None or policy(): + return event + redacted = {k: v for k, v in event.items() if k not in ("input", "output", "error")} + metadata = redacted.get("metadata") + if isinstance(metadata, dict): + redacted["metadata"] = {k: metadata[k] for k in ("model", "provider") if k in metadata} + return redacted + + +def _build_child_update_event( + entry: Any, + *, + batch_id: str, + task_components: SpanComponentsV4, + end_time: float, + seen_ids: set[str], + known_ids: set[str] | None, + expected_count: int, +) -> tuple[str, dict[str, Any]] | None: + custom_id = _get_field(entry, "custom_id") + if not isinstance(custom_id, str) or not custom_id: + log.debug("Anthropic batch completion paused: malformed result missing custom_id") + return None + if custom_id in seen_ids: + log.debug("Anthropic batch completion paused: duplicate custom_id %r", custom_id) + return None + if known_ids is not None and custom_id not in known_ids: + log.debug("Anthropic batch completion paused: unknown custom_id %r", custom_id) + return None + if len(seen_ids) >= expected_count: + log.debug("Anthropic batch completion paused: result count exceeds started request count (%d)", expected_count) + return None + + result = _get_field(entry, "result") + result_type = _get_field(result, "type") + if result_type not in _VALID_RESULT_TYPES: + log.debug("Anthropic batch completion paused: invalid result type %r for %r", result_type, custom_id) + return None + + exported = _child_slug(task_components, batch_id, custom_id) + if result_type == "succeeded": + message = _get_field(result, "message") + if message is None: + log.debug("Anthropic batch completion paused: missing message for succeeded result %r", custom_id) + return None + event = _build_succeeded_update(message, end_time) + elif result_type == "errored": + error_msg = _extract_error_message(_get_field(result, "error"), "Anthropic batch request errored") + event = {"error": error_msg, "metrics": {"end": end_time}} + elif result_type == "canceled": + event = {"error": "Anthropic batch request canceled", "metrics": {"end": end_time}} + else: + event = {"error": "Anthropic batch request expired", "metrics": {"end": end_time}} + + seen_ids.add(custom_id) + return exported, _apply_provider_privacy(event) + + +_SPOOL_MAX_BYTES = 1024 * 1024 + + +def _finalize_task_span( + batch: Any, + parsed: dict[str, Any], + seen_ids: set[str], + end_time: float, + staged_updates: "tempfile.SpooledTemporaryFile[str] | None" = None, +) -> None: + if len(seen_ids) != parsed["request_count"] or _request_ids_digest(seen_ids) != parsed["request_ids_digest"]: + log.debug( + "Anthropic batch %s results incomplete or mismatched (%d/%d); leaving task pending", + parsed["batch_id"], + len(seen_ids), + parsed["request_count"], + ) + return + + request_counts = _extract_request_counts(batch) + if request_counts is not None: + if request_counts.get("processing", 0) != 0: + log.debug("Anthropic batch %s still has processing requests; leaving task pending", parsed["batch_id"]) + return + total = sum(request_counts.get(k, 0) for k in ("succeeded", "errored", "canceled", "expired")) + if total != parsed["request_count"]: + log.debug( + "Anthropic batch %s request_counts total (%d) != started count (%d); leaving task pending", + parsed["batch_id"], + total, + parsed["request_count"], + ) + return + + if staged_updates is not None: + staged_updates.seek(0) + for line in staged_updates: + exported, child_event = json.loads(line) + update_span(exported=exported, **child_event) + + task_metadata: dict[str, Any] = { + "provider": "anthropic", + "batch_id": parsed["batch_id"], + "processing_status": "ended", + } + if request_counts is not None: + task_metadata["request_counts"] = request_counts + + task_error: str | None = None + if request_counts is not None and request_counts.get("succeeded", 0) == 0: + if ( + request_counts.get("canceled", 0) > 0 + and request_counts.get("errored", 0) == 0 + and request_counts.get("expired", 0) == 0 + ): + task_error = "Anthropic batch canceled" + elif ( + request_counts.get("expired", 0) > 0 + and request_counts.get("errored", 0) == 0 + and request_counts.get("canceled", 0) == 0 + ): + task_error = "Anthropic batch expired" + + event: dict[str, Any] = { + "metrics": {"end": end_time}, + "metadata": task_metadata, + } + if task_error is not None: + event["error"] = task_error + update_span(exported=parsed["task_slug"], **_apply_provider_privacy(event)) + + +def start_anthropic_batch_trace( + *, + batch: Any, + requests: Any, +) -> str | None: + """Start pending Braintrust spans after Anthropic accepts a Message Batch. + + Does not call Anthropic APIs. Creates one pending ``anthropic.batch`` task + span and one pending ``anthropic.messages.create`` child LLM span per + request. Persist the returned opaque context string with the batch and pass + it to :func:`complete_anthropic_batch_trace` (or + :func:`complete_anthropic_batch_trace_async`) when results are collected, + including from another process. + + Flush the logger before handing off work to another process. + """ + try: + started = _start_batch_trace_impl(batch, requests) + return started[0] if started is not None else None + except Exception as e: + log.debug("Could not start Anthropic batch trace: %s", e) + return None + + +def complete_anthropic_batch_trace( + *, + batch: Any, + results: Any | None = None, + context: str | None = None, + requests: Any | None = None, +) -> None: + """Complete a Braintrust Anthropic Message Batch trace with collected results. + + Does not poll Anthropic or fetch results. Accepts already-obtained result + entries as a sync iterable (such as ``client.messages.batches.results(...)`` + or a list of result objects/dicts), a JSONL string/bytes payload, or a + file-like stream. + + Non-terminal batches and batches with incomplete or mismatched results + remain pending and retryable. Repeating completion with the same context + and results updates the same spans idempotently. + + If submission was not traced, omit ``context`` and supply ``requests`` to + capture the entire batch in collect-only mode under the active parent. + """ + try: + prepared = _prepare_completion(batch, context, requests) + if prepared is None: + return + parsed, known_ids, end_time = prepared + if results is None: + log.debug("Anthropic batch %s has no results supplied; leaving task pending", parsed["batch_id"]) + return + + seen_ids: set[str] = set() + staged_updates = ( + tempfile.SpooledTemporaryFile(max_size=_SPOOL_MAX_BYTES, mode="w+", encoding="utf-8") + if known_ids is None + else None + ) + try: + for entry in _iter_records(results): + built = _build_child_update_event( + entry, + batch_id=parsed["batch_id"], + task_components=parsed["task_components"], + end_time=end_time, + seen_ids=seen_ids, + known_ids=known_ids, + expected_count=parsed["request_count"], + ) + if built is None: + return + exported, child_event = built + if staged_updates is not None: + staged_updates.write(bt_dumps([exported, child_event], separators=(",", ":")) + "\n") + else: + update_span(exported=exported, **child_event) + + _finalize_task_span(batch, parsed, seen_ids, end_time, staged_updates=staged_updates) + finally: + if staged_updates is not None: + staged_updates.close() + except Exception as e: + log.debug("Could not complete Anthropic batch trace: %s", e) + + +async def complete_anthropic_batch_trace_async( + *, + batch: Any, + results: Any | None = None, + context: str | None = None, + requests: Any | None = None, +) -> None: + """Async variant of :func:`complete_anthropic_batch_trace` for async result streams. + + Streams an ``AsyncIterable`` (such as ``await async_client.messages.batches.results(...)``) + incrementally without buffering all results in memory. Also accepts any + sync iterable, JSONL string/bytes payload, or file-like stream. + """ + try: + prepared = _prepare_completion(batch, context, requests) + if prepared is None: + return + parsed, known_ids, end_time = prepared + if results is None: + log.debug("Anthropic batch %s has no results supplied; leaving task pending", parsed["batch_id"]) + return + + seen_ids: set[str] = set() + staged_updates = ( + tempfile.SpooledTemporaryFile(max_size=_SPOOL_MAX_BYTES, mode="w+", encoding="utf-8") + if known_ids is None + else None + ) + try: + async for entry in _aiter_records(results): + built = _build_child_update_event( + entry, + batch_id=parsed["batch_id"], + task_components=parsed["task_components"], + end_time=end_time, + seen_ids=seen_ids, + known_ids=known_ids, + expected_count=parsed["request_count"], + ) + if built is None: + return + exported, child_event = built + if staged_updates is not None: + staged_updates.write(bt_dumps([exported, child_event], separators=(",", ":")) + "\n") + else: + update_span(exported=exported, **child_event) + + _finalize_task_span(batch, parsed, seen_ids, end_time, staged_updates=staged_updates) + finally: + if staged_updates is not None: + staged_updates.close() + except Exception as e: + log.debug("Could not complete Anthropic batch trace: %s", e) diff --git a/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestAnthropicBatchTracing.test_canceled_batch_outcome.yaml b/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestAnthropicBatchTracing.test_canceled_batch_outcome.yaml new file mode 100644 index 000000000..6407b20e0 --- /dev/null +++ b/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestAnthropicBatchTracing.test_canceled_batch_outcome.yaml @@ -0,0 +1,822 @@ +interactions: +- request: + body: '{"requests":[{"custom_id":"req-1","params":{"model":"claude-haiku-5-5","max_tokens":100,"messages":[{"role":"user","content":"What + is 2+2?"}]}},{"custom_id":"req-2","params":{"model":"claude-haiku-5-5","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: + - '276' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_012y4fXnntP5NyrmE7LdUrCB","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-11-27T20:58:36.630830+00:00","expires_at":"2026-11-28T20:58:36.630830+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: + - a6140d48de854e7c-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:36 GMT + request-id: + - req_011ChU6xxCPP2DM7jMgPA7JL + server: + - cloudflare + server-timing: + - x-originResponse;dur=319 + 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-length: + - '0' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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/msgbatch_012y4fXnntP5NyrmE7LdUrCB/cancel + response: + body: + string: '{"id":"msgbatch_012y4fXnntP5NyrmE7LdUrCB","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:58:36.630830+00:00","expires_at":"2026-11-28T20:58:36.630830+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:36.907957+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d4b5b4b4e7c-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:36 GMT + request-id: + - req_011ChU6xyxJKAFf7R35vMUR1 + server: + - cloudflare + server-timing: + - x-originResponse;dur=206 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_012y4fXnntP5NyrmE7LdUrCB + response: + body: + string: '{"id":"msgbatch_012y4fXnntP5NyrmE7LdUrCB","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:58:36.630830+00:00","expires_at":"2026-11-28T20:58:36.630830+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:36.907957+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d6c6e1cdd76-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:42 GMT + request-id: + - req_011ChU6yNY77jvbW2if5Hi37 + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=76 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_012y4fXnntP5NyrmE7LdUrCB + response: + body: + string: '{"id":"msgbatch_012y4fXnntP5NyrmE7LdUrCB","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:58:36.630830+00:00","expires_at":"2026-11-28T20:58:36.630830+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:36.907957+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d8cbfd4ad76-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:47 GMT + request-id: + - req_011ChU6ykdeFjoyUqTjmHe3S + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=78 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_012y4fXnntP5NyrmE7LdUrCB + response: + body: + string: '{"id":"msgbatch_012y4fXnntP5NyrmE7LdUrCB","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:58:36.630830+00:00","expires_at":"2026-11-28T20:58:36.630830+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:36.907957+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140dad1ba75d68-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:52 GMT + request-id: + - req_011ChU6z8nPy2G3x8FWZmfHf + 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 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_012y4fXnntP5NyrmE7LdUrCB + response: + body: + string: '{"id":"msgbatch_012y4fXnntP5NyrmE7LdUrCB","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:58:36.630830+00:00","expires_at":"2026-11-28T20:58:36.630830+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:36.907957+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140dcd9856efc9-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:57 GMT + request-id: + - req_011ChU6zX27rLoZkA62nppGh + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=85 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_012y4fXnntP5NyrmE7LdUrCB + response: + body: + string: '{"id":"msgbatch_012y4fXnntP5NyrmE7LdUrCB","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:58:36.630830+00:00","expires_at":"2026-11-28T20:58:36.630830+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:36.907957+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140dee08a0c4ac-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:59:02 GMT + request-id: + - req_011ChU6zuD7DVh5RW3gU823x + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=89 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_012y4fXnntP5NyrmE7LdUrCB + response: + body: + string: '{"id":"msgbatch_012y4fXnntP5NyrmE7LdUrCB","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":0,"errored":0,"canceled":2,"expired":0},"ended_at":"2026-11-27T20:59:06.814790+00:00","created_at":"2026-11-27T20:58:36.630830+00:00","expires_at":"2026-11-28T20:58:36.630830+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:36.907957+00:00","results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_012y4fXnntP5NyrmE7LdUrCB/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140e0e7cb76c24-PDX + connection: + - keep-alive + content-length: + - '500' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:59:08 GMT + request-id: + - req_011ChU71HPr3SDQGAQeeMUpy + server: + - cloudflare + server-timing: + - x-originResponse;dur=64 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_012y4fXnntP5NyrmE7LdUrCB + response: + body: + string: '{"id":"msgbatch_012y4fXnntP5NyrmE7LdUrCB","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":0,"errored":0,"canceled":2,"expired":0},"ended_at":"2026-11-27T20:59:06.814790+00:00","created_at":"2026-11-27T20:58:36.630830+00:00","expires_at":"2026-11-28T20:58:36.630830+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:36.907957+00:00","results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_012y4fXnntP5NyrmE7LdUrCB/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140e0f5fbd6c24-PDX + connection: + - keep-alive + content-length: + - '500' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:59:08 GMT + request-id: + - req_011ChU71JDi3DWoPSTaKhdss + 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/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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_012y4fXnntP5NyrmE7LdUrCB/results + response: + body: + string: '{"custom_id":"req-2","result":{"type":"canceled"}} + + {"custom_id":"req-1","result":{"type":"canceled"}} + + ' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140e10fcab6c24-PDX + connection: + - keep-alive + content-disposition: + - attachment; filename*=utf-8''msgbatch_012y4fXnntP5NyrmE7LdUrCB_results.jsonl + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/x-jsonl + date: + - Fri, 27 Nov 2026 20:59:08 GMT + request-id: + - req_011ChU71K5YnFrqmoYi6VmnQ + server: + - cloudflare + server-timing: + - x-originResponse;dur=150 + 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/TestAnthropicBatchTracing.test_errored_batch_outcome.yaml b/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestAnthropicBatchTracing.test_errored_batch_outcome.yaml new file mode 100644 index 000000000..c32d591c2 --- /dev/null +++ b/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestAnthropicBatchTracing.test_errored_batch_outcome.yaml @@ -0,0 +1,1316 @@ +interactions: +- request: + body: '{"requests":[{"custom_id":"req-ok","params":{"model":"claude-haiku-5-5","max_tokens":32,"messages":[{"role":"user","content":"Reply + with OK."}]}},{"custom_id":"req-err","params":{"model":"claude-nonexistent-batch-test","max_tokens":16,"messages":[{"role":"user","content":"hi"}]}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '282' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.48.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3","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-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+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: + - '499997' + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140b9f4b047b78-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:28 GMT + request-id: + - req_011ChU6sw8VrNTxPdUJsyPRS + server: + - cloudflare + server-timing: + - x-originResponse;dur=232 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","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-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140bc09fc2ef34-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:33 GMT + request-id: + - req_011ChU6tKtiS9rT93US8uKCR + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=74 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","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-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140be0ecf4c8da-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:38 GMT + request-id: + - req_011ChU6thyWUcBcEfpzPwdeU + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","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-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140c0148439935-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:44 GMT + request-id: + - req_011ChU6u6AkR1UJJedaG5f55 + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=91 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","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-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140c21bf90de1d-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:49 GMT + request-id: + - req_011ChU6uUQDfxmf66kqeAUve + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=80 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","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-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140c422844ff15-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:54 GMT + request-id: + - req_011ChU6urVWGRDNyHGfGim91 + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=99 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","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-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140c629b598b90-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:59 GMT + request-id: + - req_011ChU6vEhyuUYtp5ismiaAd + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=91 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","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-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140c830a42acc8-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:04 GMT + request-id: + - req_011ChU6vctDuhpMmVpyTY9Lp + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=87 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","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-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140ca37b9edabf-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:09 GMT + request-id: + - req_011ChU6w14UD4Kwtho5uYTTC + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=90 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","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-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140cc3ddf728b9-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:15 GMT + request-id: + - req_011ChU6wPCVLVZs5oBjeuG1o + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=76 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","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-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140ce42c5d11c8-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:20 GMT + request-id: + - req_011ChU6wmLzwtmgmtZiaLR8M + retry-after: + - '10' + 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/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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","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-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d0498c45ddf-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:25 GMT + request-id: + - req_011ChU6x9XVPGMpxthcWEYoU + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=78 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","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-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d24f931efce-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:30 GMT + request-id: + - req_011ChU6xXdWyD37SBXLnK777 + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=85 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":1,"errored":1,"canceled":0,"expired":0},"ended_at":"2026-11-27T20:58:34.269947+00:00","created_at":"2026-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01JdvAthqM7Sm1jZXhWeKUy3/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d45498458c2-PDX + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:35 GMT + request-id: + - req_011ChU6xun2ktupucqCbT3Cn + server: + - cloudflare + server-timing: + - x-originResponse;dur=82 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3 + response: + body: + string: '{"id":"msgbatch_01JdvAthqM7Sm1jZXhWeKUy3","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":1,"errored":1,"canceled":0,"expired":0},"ended_at":"2026-11-27T20:58:34.269947+00:00","created_at":"2026-11-27T20:57:28.456617+00:00","expires_at":"2026-11-28T20:57:28.456617+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01JdvAthqM7Sm1jZXhWeKUy3/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d464b0a58c2-PDX + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:36 GMT + request-id: + - req_011ChU6xvRUTVavpWthHKNuF + server: + - cloudflare + server-timing: + - x-originResponse;dur=83 + 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: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + 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_01JdvAthqM7Sm1jZXhWeKUy3/results + response: + body: + string: '{"custom_id":"req-err","result":{"type":"errored","error":{"type":"error","error":{"details":null,"type":"not_found_error","message":"model: + claude-nonexistent-batch-test"},"request_id":null}}} + + {"custom_id":"req-ok","result":{"type":"succeeded","message":{"model":"claude-haiku-5-5","id":"msg_011ChU6uqqpTcoGfeV4xdXHY","type":"message","role":"assistant","content":[{"type":"text","text":"OK"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":15,"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,"output_tokens_details":{"thinking_tokens":0},"service_tier":"batch","inference_geo":"global","speed":"standard"},"diagnostics":null}}} + + ' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d474d3d58c2-PDX + connection: + - keep-alive + content-disposition: + - attachment; filename*=utf-8''msgbatch_01JdvAthqM7Sm1jZXhWeKUy3_results.jsonl + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/x-jsonl + date: + - Fri, 27 Nov 2026 20:58:36 GMT + request-id: + - req_011ChU6xw8e7LtoSFVLbjC9u + server: + - cloudflare + server-timing: + - x-originResponse;dur=139 + 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/TestBatchesCreateSpans.test_sync_batches_create_logs_error_on_failure.yaml b/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestBatchesCreateSpans.test_sync_batches_create_logs_error_on_failure.yaml deleted file mode 100644 index 927d8cc05..000000000 --- a/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestBatchesCreateSpans.test_sync_batches_create_logs_error_on_failure.yaml +++ /dev/null @@ -1,88 +0,0 @@ -interactions: -- request: - body: '{"requests":[]}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate, zstd - Connection: - - keep-alive - Content-Length: - - '15' - Content-Type: - - application/json - Host: - - api.anthropic.com - User-Agent: - - Anthropic/Python 0.84.0 - X-Stainless-Arch: - - arm64 - X-Stainless-Async: - - 'false' - X-Stainless-Lang: - - python - X-Stainless-OS: - - MacOS - X-Stainless-Package-Version: - - 0.84.0 - X-Stainless-Runtime: - - CPython - X-Stainless-Runtime-Version: - - 3.13.3 - anthropic-version: - - '2023-06-01' - x-stainless-read-timeout: - - '600' - x-stainless-retry-count: - - '0' - x-stainless-timeout: - - NOT_GIVEN - method: POST - uri: https://api.anthropic.com/v1/messages/batches - response: - body: - string: '{"type":"error","error":{"type":"invalid_request_error","message":"requests: - List should have at least 1 item after validation, not 0"},"request_id":"req_011CZNFHwZ7YMN9zyDPHXbmQ"}' - headers: - CF-RAY: - - 9e172a012bf5963f-SJC - Connection: - - keep-alive - Content-Security-Policy: - - default-src 'none'; frame-ancestors 'none' - Content-Type: - - application/json - Date: - - Tue, 24 Mar 2026 16:48:33 GMT - Server: - - cloudflare - Transfer-Encoding: - - chunked - X-Robots-Tag: - - none - anthropic-organization-id: - - 27796668-7351-40ac-acc4-024aee8995a5 - cf-cache-status: - - DYNAMIC - content-length: - - '180' - request-id: - - req_011CZNFHwZ7YMN9zyDPHXbmQ - server-timing: - - x-originResponse;dur=67 - set-cookie: - - _cfuvid=wf8HdCMhs1UcbQutpPzsJc1I_lzHbLbPsQj6EA0sl4s-1774370913.461001-1.0.1.1-wD9j9Vl_k5M7qG3MI7A3pbi6Q52GLfngLxFm_kctpPo; - HttpOnly; SameSite=None; Secure; Path=/; Domain=api.anthropic.com - strict-transport-security: - - max-age=31536000; includeSubDomains; preload - vary: - - Accept-Encoding - x-envoy-upstream-service-time: - - '65' - x-should-retry: - - 'false' - status: - code: 400 - message: Bad Request -version: 1 diff --git a/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestBatchesCreateSpans.test_sync_batches_create_multi_model_metadata.yaml b/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestBatchesCreateSpans.test_sync_batches_create_multi_model_metadata.yaml deleted file mode 100644 index 22e7482d3..000000000 --- a/py/src/braintrust/integrations/anthropic/cassettes/0.48.0/TestBatchesCreateSpans.test_sync_batches_create_multi_model_metadata.yaml +++ /dev/null @@ -1,86 +0,0 @@ -interactions: -- request: - body: '{"requests":[{"custom_id":"req-1","params":{"model":"claude-haiku-5-5","max_tokens":100,"messages":[{"role":"user","content":"Hi"}]}},{"custom_id":"req-2","params":{"model":"claude-sonnet-5-5","max_tokens":100,"messages":[{"role":"user","content":"Hello"}]}}]}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate - anthropic-version: - - '2023-06-01' - connection: - - keep-alive - content-length: - - '260' - 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_012wVJMg5WJtsQ4qEuUuBS2A","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-11-10T16:23:48.642562+00:00","expires_at":"2026-11-11T16:23:48.642562+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: - - a586675d1faaab48-YYZ - connection: - - keep-alive - content-length: - - '361' - content-security-policy: - - default-src 'none'; frame-ancestors 'none' - content-type: - - application/json - date: - - Tue, 10 Nov 2026 16:23:48 GMT - request-id: - - req_011CguZFxqhrjYfuEADAKoeL - server: - - cloudflare - server-timing: - - x-originResponse;dur=626 - 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/1.17.0/TestAnthropicBatchTracing.test_canceled_batch_outcome.yaml b/py/src/braintrust/integrations/anthropic/cassettes/1.17.0/TestAnthropicBatchTracing.test_canceled_batch_outcome.yaml new file mode 100644 index 000000000..a298beb6b --- /dev/null +++ b/py/src/braintrust/integrations/anthropic/cassettes/1.17.0/TestAnthropicBatchTracing.test_canceled_batch_outcome.yaml @@ -0,0 +1,886 @@ +interactions: +- request: + body: '{"requests":[{"custom_id":"req-1","params":{"model":"claude-haiku-5-5","max_tokens":100,"messages":[{"role":"user","content":"What + is 2+2?"}]}},{"custom_id":"req-2","params":{"model":"claude-haiku-5-5","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: + - '276' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01CQxkFfKvkVynaC6KVMEMs5","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-11-27T20:58:34.210301+00:00","expires_at":"2026-11-28T20:58:34.210301+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: + - '499997' + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d3a4e534e7c-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:34 GMT + request-id: + - req_011ChU6xnFLx5Xc81jd5taYd + server: + - cloudflare + server-timing: + - x-originResponse;dur=228 + 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 + content-length: + - '0' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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/msgbatch_01CQxkFfKvkVynaC6KVMEMs5/cancel + response: + body: + string: '{"id":"msgbatch_01CQxkFfKvkVynaC6KVMEMs5","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:58:34.210301+00:00","expires_at":"2026-11-28T20:58:34.210301+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:34.403129+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d3c2b874e7c-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:34 GMT + request-id: + - req_011ChU6xoXzP22CAKGjLmCKK + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01CQxkFfKvkVynaC6KVMEMs5 + response: + body: + string: '{"id":"msgbatch_01CQxkFfKvkVynaC6KVMEMs5","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:58:34.210301+00:00","expires_at":"2026-11-28T20:58:34.210301+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:34.403129+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d5ccf611a0b-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:39 GMT + request-id: + - req_011ChU6yBpgG4vv8zmkdhzXb + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=84 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01CQxkFfKvkVynaC6KVMEMs5 + response: + body: + string: '{"id":"msgbatch_01CQxkFfKvkVynaC6KVMEMs5","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:58:34.210301+00:00","expires_at":"2026-11-28T20:58:34.210301+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:34.403129+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d7d1d039811-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:44 GMT + request-id: + - req_011ChU6yZygctaA4Lz7wtTYF + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=81 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01CQxkFfKvkVynaC6KVMEMs5 + response: + body: + string: '{"id":"msgbatch_01CQxkFfKvkVynaC6KVMEMs5","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:58:34.210301+00:00","expires_at":"2026-11-28T20:58:34.210301+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:34.403129+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d9d89615135-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:49 GMT + request-id: + - req_011ChU6yx7TR65qA3pYkjLem + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=59 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01CQxkFfKvkVynaC6KVMEMs5 + response: + body: + string: '{"id":"msgbatch_01CQxkFfKvkVynaC6KVMEMs5","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:58:34.210301+00:00","expires_at":"2026-11-28T20:58:34.210301+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:34.403129+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140dbdbcada509-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:55 GMT + request-id: + - req_011ChU6zLBVpruDMhHFhFany + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=85 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01CQxkFfKvkVynaC6KVMEMs5 + response: + body: + string: '{"id":"msgbatch_01CQxkFfKvkVynaC6KVMEMs5","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:58:34.210301+00:00","expires_at":"2026-11-28T20:58:34.210301+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:34.403129+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140dde1e0def6f-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:59:00 GMT + request-id: + - req_011ChU6ziLFtLMuq5niF8hda + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=72 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01CQxkFfKvkVynaC6KVMEMs5 + response: + body: + string: '{"id":"msgbatch_01CQxkFfKvkVynaC6KVMEMs5","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:58:34.210301+00:00","expires_at":"2026-11-28T20:58:34.210301+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:34.403129+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140dfe7ba9efbe-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:59:05 GMT + request-id: + - req_011ChU716SXyop2gcDtZfHgh + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=81 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01CQxkFfKvkVynaC6KVMEMs5 + response: + body: + string: '{"id":"msgbatch_01CQxkFfKvkVynaC6KVMEMs5","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":0,"errored":0,"canceled":2,"expired":0},"ended_at":"2026-11-27T20:59:07.630133+00:00","created_at":"2026-11-27T20:58:34.210301+00:00","expires_at":"2026-11-28T20:58:34.210301+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:34.403129+00:00","results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01CQxkFfKvkVynaC6KVMEMs5/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140e1ecc6fb1c2-PDX + connection: + - keep-alive + content-length: + - '500' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:59:10 GMT + request-id: + - req_011ChU71UZZJgeUKpWQ291rQ + server: + - cloudflare + server-timing: + - x-originResponse;dur=90 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01CQxkFfKvkVynaC6KVMEMs5 + response: + body: + string: '{"id":"msgbatch_01CQxkFfKvkVynaC6KVMEMs5","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":0,"errored":0,"canceled":2,"expired":0},"ended_at":"2026-11-27T20:59:07.630133+00:00","created_at":"2026-11-27T20:58:34.210301+00:00","expires_at":"2026-11-28T20:58:34.210301+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:58:34.403129+00:00","results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01CQxkFfKvkVynaC6KVMEMs5/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140e1fdf3cb1c2-PDX + connection: + - keep-alive + content-length: + - '500' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:59:10 GMT + request-id: + - req_011ChU71VHTtmo7H7B4zER9D + server: + - cloudflare + server-timing: + - x-originResponse;dur=74 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01CQxkFfKvkVynaC6KVMEMs5/results + response: + body: + string: '{"custom_id":"req-2","result":{"type":"canceled"}} + + {"custom_id":"req-1","result":{"type":"canceled"}} + + ' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140e20daf3b1c2-PDX + connection: + - keep-alive + content-disposition: + - attachment; filename*=utf-8''msgbatch_01CQxkFfKvkVynaC6KVMEMs5_results.jsonl + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/x-jsonl + date: + - Fri, 27 Nov 2026 20:59:11 GMT + request-id: + - req_011ChU71Vxtv6X5jPmtd96Qh + 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 +version: 1 diff --git a/py/src/braintrust/integrations/anthropic/cassettes/1.17.0/TestAnthropicBatchTracing.test_errored_batch_outcome.yaml b/py/src/braintrust/integrations/anthropic/cassettes/1.17.0/TestAnthropicBatchTracing.test_errored_batch_outcome.yaml new file mode 100644 index 000000000..ea6067fc5 --- /dev/null +++ b/py/src/braintrust/integrations/anthropic/cassettes/1.17.0/TestAnthropicBatchTracing.test_errored_batch_outcome.yaml @@ -0,0 +1,1446 @@ +interactions: +- request: + body: '{"requests":[{"custom_id":"req-ok","params":{"model":"claude-haiku-5-5","max_tokens":32,"messages":[{"role":"user","content":"Reply + with OK."}]}},{"custom_id":"req-err","params":{"model":"claude-nonexistent-batch-test","max_tokens":16,"messages":[{"role":"user","content":"hi"}]}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '282' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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: + - a6140b4f9826c54c-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:15 GMT + request-id: + - req_011ChU6rzZMKVwp3cS2AmnZg + server: + - cloudflare + server-timing: + - x-originResponse;dur=212 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140b70c9154598-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:20 GMT + request-id: + - req_011ChU6sPG6gJmvSeHYufwJt + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=87 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140b912cf8dd76-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:26 GMT + request-id: + - req_011ChU6smQc88EZeYv9sFSiM + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=89 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140bb18b92a32d-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:31 GMT + request-id: + - req_011ChU6t9caq1TfQgyJjGXLg + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=117 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140bd21deefefd-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:36 GMT + request-id: + - req_011ChU6tXqovDbgeWsDnRjoM + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=120 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140bf2aee8ff17-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:41 GMT + request-id: + - req_011ChU6tv7kmRhP51wJWXvem + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=94 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140c130f855ec1-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:46 GMT + request-id: + - req_011ChU6uJHFuch8V96o36yBq + 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, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140c338c8e9790-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:52 GMT + request-id: + - req_011ChU6ugUVgDiF7hKVVN9KS + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140c53fec423a3-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:57 GMT + request-id: + - req_011ChU6v4hy6KamRuBZdX2Pi + 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, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140c7469e65f03-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:02 GMT + request-id: + - req_011ChU6vSuCcvU25WCEc4iwv + 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, zstd + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 1.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140c94de4ddab7-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:07 GMT + request-id: + - req_011ChU6vq2yDcchwXWFX4igq + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=96 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140cb53857ad76-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:12 GMT + request-id: + - req_011ChU6wDHvp8i6mJG7qTGSw + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=90 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140cd5aaea5135-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:18 GMT + request-id: + - req_011ChU6wbQD2HskNVh71JYSC + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=82 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140cf5feb6dfd2-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:23 GMT + request-id: + - req_011ChU6wyV11YoEDef6JbUTG + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=101 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","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-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d166bae147f-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:28 GMT + request-id: + - req_011ChU6xMgEMd9EW8BrzeDGw + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=77 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":1,"errored":1,"canceled":0,"expired":0},"ended_at":"2026-11-27T20:58:32.620536+00:00","created_at":"2026-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01MX275WrZGZaj7AxyXXkNeu/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d36bb9b5135-PDX + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:33 GMT + request-id: + - req_011ChU6xjoW5FtSAYpHS7G3K + server: + - cloudflare + server-timing: + - x-originResponse;dur=91 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu + response: + body: + string: '{"id":"msgbatch_01MX275WrZGZaj7AxyXXkNeu","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":1,"errored":1,"canceled":0,"expired":0},"ended_at":"2026-11-27T20:58:32.620536+00:00","created_at":"2026-11-27T20:57:15.681765+00:00","expires_at":"2026-11-28T20:57:15.681765+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01MX275WrZGZaj7AxyXXkNeu/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d37ce115135-PDX + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:58:33 GMT + request-id: + - req_011ChU6xkWuw7UuTnjpiu7nq + server: + - cloudflare + server-timing: + - x-originResponse;dur=86 + 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.17.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 1.17.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_01MX275WrZGZaj7AxyXXkNeu/results + response: + body: + string: '{"custom_id":"req-err","result":{"type":"errored","error":{"type":"error","error":{"details":null,"type":"not_found_error","message":"model: + claude-nonexistent-batch-test"},"request_id":null}}} + + {"custom_id":"req-ok","result":{"type":"succeeded","message":{"model":"claude-haiku-5-5","id":"msg_011ChU6uqxGWRfWBvhc6hP2B","type":"message","role":"assistant","content":[{"type":"text","text":"OK"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":15,"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,"output_tokens_details":{"thinking_tokens":0},"service_tier":"batch","inference_geo":"global","speed":"standard"},"diagnostics":null}}} + + ' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140d38c8465135-PDX + connection: + - keep-alive + content-disposition: + - attachment; filename*=utf-8''msgbatch_01MX275WrZGZaj7AxyXXkNeu_results.jsonl + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/x-jsonl + date: + - Fri, 27 Nov 2026 20:58:33 GMT + request-id: + - req_011ChU6xmCqnD5PHfBSD8zRa + 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 +version: 1 diff --git a/py/src/braintrust/integrations/anthropic/cassettes/1.17.0/TestBatchesCreateSpans.test_sync_batches_create_logs_error_on_failure.yaml b/py/src/braintrust/integrations/anthropic/cassettes/1.17.0/TestBatchesCreateSpans.test_sync_batches_create_logs_error_on_failure.yaml deleted file mode 100644 index 1c263d9dc..000000000 --- a/py/src/braintrust/integrations/anthropic/cassettes/1.17.0/TestBatchesCreateSpans.test_sync_batches_create_logs_error_on_failure.yaml +++ /dev/null @@ -1,83 +0,0 @@ -interactions: -- request: - body: '{"requests":[]}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate, zstd - anthropic-version: - - '2023-06-01' - connection: - - keep-alive - content-length: - - '15' - content-type: - - application/json - host: - - api.anthropic.com - user-agent: - - Anthropic/Python 1.17.0 - x-stainless-arch: - - arm64 - x-stainless-async: - - 'false' - x-stainless-lang: - - python - x-stainless-os: - - MacOS - x-stainless-package-version: - - 1.17.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: '{"type":"error","error":{"type":"invalid_request_error","message":"requests: - List should have at least 1 item after validation, not 0"},"request_id":"req_011CgQs6LVQrCh3sPhZtVKTX"}' - headers: - anthropic-organization-id: - - 27796668-7351-40ac-acc4-024aee8995a5 - anthropic-workspace-id: - - wrkspc_018bFG1FgNVWqx5pthtdGTzS - cf-cache-status: - - DYNAMIC - cf-ray: - - a509878cf86e92c6-YYZ - connection: - - keep-alive - content-security-policy: - - default-src 'none'; frame-ancestors 'none' - content-type: - - application/json - date: - - Mon, 26 Oct 2026 12:40:26 GMT - request-id: - - req_011CgQs6LVQrCh3sPhZtVKTX - server: - - cloudflare - server-timing: - - x-originResponse;dur=87 - strict-transport-security: - - max-age=31536000; includeSubDomains; preload - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-robots-tag: - - none - x-should-retry: - - 'false' - status: - code: 400 - message: Bad Request -version: 1 diff --git a/py/src/braintrust/integrations/anthropic/cassettes/1.17.0/TestBatchesCreateSpans.test_sync_batches_create_multi_model_metadata.yaml b/py/src/braintrust/integrations/anthropic/cassettes/1.17.0/TestBatchesCreateSpans.test_sync_batches_create_multi_model_metadata.yaml deleted file mode 100644 index 939fe0cb5..000000000 --- a/py/src/braintrust/integrations/anthropic/cassettes/1.17.0/TestBatchesCreateSpans.test_sync_batches_create_multi_model_metadata.yaml +++ /dev/null @@ -1,86 +0,0 @@ -interactions: -- request: - body: '{"requests":[{"custom_id":"req-1","params":{"model":"claude-haiku-5-5","max_tokens":100,"messages":[{"role":"user","content":"Hi"}]}},{"custom_id":"req-2","params":{"model":"claude-sonnet-5-5","max_tokens":100,"messages":[{"role":"user","content":"Hello"}]}}]}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate, zstd - anthropic-version: - - '2023-06-01' - connection: - - keep-alive - content-length: - - '260' - content-type: - - application/json - host: - - api.anthropic.com - user-agent: - - Anthropic/Python 1.17.0 - x-stainless-arch: - - arm64 - x-stainless-async: - - 'false' - x-stainless-lang: - - python - x-stainless-os: - - MacOS - x-stainless-package-version: - - 1.17.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_01LiHSQKABJHXJCSZdoNT1fW","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-11-10T16:24:01.527447+00:00","expires_at":"2026-11-11T16:24:01.527447+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: - - '499988' - anthropic-workspace-id: - - wrkspc_018bFG1FgNVWqx5pthtdGTzS - cf-cache-status: - - DYNAMIC - cf-ray: - - a58667adff69b407-YYZ - connection: - - keep-alive - content-length: - - '361' - content-security-policy: - - default-src 'none'; frame-ancestors 'none' - content-type: - - application/json - date: - - Tue, 10 Nov 2026 16:24:01 GMT - request-id: - - req_011CguZGvAkGncpRdcwoTDfJ - server: - - cloudflare - server-timing: - - x-originResponse;dur=566 - 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/TestAnthropicBatchTracing.test_canceled_batch_outcome.yaml b/py/src/braintrust/integrations/anthropic/cassettes/latest/TestAnthropicBatchTracing.test_canceled_batch_outcome.yaml new file mode 100644 index 000000000..86b706fb4 --- /dev/null +++ b/py/src/braintrust/integrations/anthropic/cassettes/latest/TestAnthropicBatchTracing.test_canceled_batch_outcome.yaml @@ -0,0 +1,806 @@ +interactions: +- request: + body: '{"requests":[{"custom_id":"req-1","params":{"model":"claude-haiku-5-5","max_tokens":100,"messages":[{"role":"user","content":"What + is 2+2?"}]}},{"custom_id":"req-2","params":{"model":"claude-haiku-5-5","max_tokens":100,"messages":[{"role":"user","content":"What + is 3+3?"}]}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2026-10-21' + connection: + - keep-alive + content-length: + - '276' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01J8w8buhT3eaNTj5qZEwdtx","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-11-27T20:56:33.463211+00:00","expires_at":"2026-11-28T20:56:33.463211+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: + - a6140a478fe80d87-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:33 GMT + request-id: + - req_011ChU6oswA1AnL9vWC3S2Mi + server: + - cloudflare + server-timing: + - x-originResponse;dur=235 + 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: + - '2026-10-21' + connection: + - keep-alive + content-length: + - '0' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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/msgbatch_01J8w8buhT3eaNTj5qZEwdtx/cancel + response: + body: + string: '{"id":"msgbatch_01J8w8buhT3eaNTj5qZEwdtx","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:56:33.463211+00:00","expires_at":"2026-11-28T20:56:33.463211+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:56:33.621775+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140a497cc30d87-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:33 GMT + request-id: + - req_011ChU6ouFXh3cYXvUy1fMVb + server: + - cloudflare + server-timing: + - x-originResponse;dur=101 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01J8w8buhT3eaNTj5qZEwdtx + response: + body: + string: '{"id":"msgbatch_01J8w8buhT3eaNTj5qZEwdtx","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:56:33.463211+00:00","expires_at":"2026-11-28T20:56:33.463211+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:56:33.621775+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140a69effab1c2-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:38 GMT + request-id: + - req_011ChU6pHTWXHUYKWRrfiNi9 + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=111 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01J8w8buhT3eaNTj5qZEwdtx + response: + body: + string: '{"id":"msgbatch_01J8w8buhT3eaNTj5qZEwdtx","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:56:33.463211+00:00","expires_at":"2026-11-28T20:56:33.463211+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:56:33.621775+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140a8a6c66ff1a-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:44 GMT + request-id: + - req_011ChU6pfhE9ry8jGvxoJsgV + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=97 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01J8w8buhT3eaNTj5qZEwdtx + response: + body: + string: '{"id":"msgbatch_01J8w8buhT3eaNTj5qZEwdtx","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:56:33.463211+00:00","expires_at":"2026-11-28T20:56:33.463211+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:56:33.621775+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140aaadb85ef18-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:49 GMT + request-id: + - req_011ChU6q3wSXFSMwKPfaQ6ic + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=104 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01J8w8buhT3eaNTj5qZEwdtx + response: + body: + string: '{"id":"msgbatch_01J8w8buhT3eaNTj5qZEwdtx","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:56:33.463211+00:00","expires_at":"2026-11-28T20:56:33.463211+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:56:33.621775+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140acb5e8f5ec3-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:54 GMT + request-id: + - req_011ChU6qS7SJKQqRS4TnPB4w + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=86 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01J8w8buhT3eaNTj5qZEwdtx + response: + body: + string: '{"id":"msgbatch_01J8w8buhT3eaNTj5qZEwdtx","type":"message_batch","processing_status":"canceling","request_counts":{"processing":2,"succeeded":0,"errored":0,"canceled":0,"expired":0},"ended_at":null,"created_at":"2026-11-27T20:56:33.463211+00:00","expires_at":"2026-11-28T20:56:33.463211+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:56:33.621775+00:00","results_url":null}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140aebbbfacf48-PDX + connection: + - keep-alive + content-length: + - '389' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:59 GMT + request-id: + - req_011ChU6qpGh9fmaiRJxwDNqG + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=94 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01J8w8buhT3eaNTj5qZEwdtx + response: + body: + string: '{"id":"msgbatch_01J8w8buhT3eaNTj5qZEwdtx","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":0,"errored":0,"canceled":2,"expired":0},"ended_at":"2026-11-27T20:57:03.719744+00:00","created_at":"2026-11-27T20:56:33.463211+00:00","expires_at":"2026-11-28T20:56:33.463211+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:56:33.621775+00:00","results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01J8w8buhT3eaNTj5qZEwdtx/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140b0c2ba45012-PDX + connection: + - keep-alive + content-length: + - '500' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:04 GMT + request-id: + - req_011ChU6rCSSU9MidMxwpg87o + server: + - cloudflare + server-timing: + - x-originResponse;dur=91 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01J8w8buhT3eaNTj5qZEwdtx + response: + body: + string: '{"id":"msgbatch_01J8w8buhT3eaNTj5qZEwdtx","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":0,"errored":0,"canceled":2,"expired":0},"ended_at":"2026-11-27T20:57:03.719744+00:00","created_at":"2026-11-27T20:56:33.463211+00:00","expires_at":"2026-11-28T20:56:33.463211+00:00","archived_at":null,"cancel_initiated_at":"2026-11-27T20:56:33.621775+00:00","results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01J8w8buhT3eaNTj5qZEwdtx/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140b0d3e915012-PDX + connection: + - keep-alive + content-length: + - '500' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:57:04 GMT + request-id: + - req_011ChU6rDA6o9Y6Fjx6mMzJW + 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/binary + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01J8w8buhT3eaNTj5qZEwdtx/results + response: + body: + string: '{"custom_id":"req-1","result":{"type":"canceled"}} + + {"custom_id":"req-2","result":{"type":"canceled"}} + + ' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140b0e48d45012-PDX + connection: + - keep-alive + content-disposition: + - attachment; filename*=utf-8''msgbatch_01J8w8buhT3eaNTj5qZEwdtx_results.jsonl + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/x-jsonl + date: + - Fri, 27 Nov 2026 20:57:05 GMT + request-id: + - req_011ChU6rDvEsubGhj8cCTHJC + server: + - cloudflare + server-timing: + - x-originResponse;dur=182 + 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/TestAnthropicBatchTracing.test_errored_batch_outcome.yaml b/py/src/braintrust/integrations/anthropic/cassettes/latest/TestAnthropicBatchTracing.test_errored_batch_outcome.yaml new file mode 100644 index 000000000..718711e1b --- /dev/null +++ b/py/src/braintrust/integrations/anthropic/cassettes/latest/TestAnthropicBatchTracing.test_errored_batch_outcome.yaml @@ -0,0 +1,1686 @@ +interactions: +- request: + body: '{"requests":[{"custom_id":"req-ok","params":{"model":"claude-haiku-5-5","max_tokens":32,"messages":[{"role":"user","content":"Reply + with OK."}]}},{"custom_id":"req-err","params":{"model":"claude-nonexistent-batch-test","max_tokens":16,"messages":[{"role":"user","content":"hi"}]}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2026-10-21' + connection: + - keep-alive + content-length: + - '282' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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: + - a61407faaa511687-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:54:59 GMT + request-id: + - req_011ChU6gw7wmT5jw83593Ddm + server: + - cloudflare + server-timing: + - x-originResponse;dur=179 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a614081babc23016-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:55:04 GMT + request-id: + - req_011ChU6hKjjUbafXNsNL9nxt + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=97 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a614083c1c60ff19-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:55:09 GMT + request-id: + - req_011ChU6hhs1U9JRiUGnq9e5k + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=84 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a614085c7b985332-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:55:14 GMT + request-id: + - req_011ChU6i63kNW2phtU4oHWT6 + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=114 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a614087cfc3131df-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:55:20 GMT + request-id: + - req_011ChU6iUFEhQjS16jv6ZPZ9 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a614089d8f324518-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:55:25 GMT + request-id: + - req_011ChU6irWBwXPN8k6vGMtpg + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=80 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a61408bdd91b58d9-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:55:30 GMT + request-id: + - req_011ChU6jEcUFzjR2jYepKstY + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=87 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a61408de39c18e5d-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:55:35 GMT + request-id: + - req_011ChU6jckykSvnUWzrkeN1d + 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, zstd + anthropic-version: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a61408febeafff15-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:55:40 GMT + request-id: + - req_011ChU6k11SJGGBruXi9qJs7 + 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, zstd + anthropic-version: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a614091f4b130bee-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:55:45 GMT + request-id: + - req_011ChU6kPGQ3GiPD8iG8n4Dz + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=84 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a614093f99ae0055-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:55:51 GMT + request-id: + - req_011ChU6kmQQhNwZvqY7WdFrv + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=90 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a61409600bbf1561-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:55:56 GMT + request-id: + - req_011ChU6m9aQuraG8YKCJgnGh + 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, zstd + anthropic-version: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a614098078fee6e0-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:01 GMT + request-id: + - req_011ChU6mXqNHgbQCHw15UJV3 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a61409a11b315913-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:06 GMT + request-id: + - req_011ChU6mv65GpHr9cCPwYjNA + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=91 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a61409c18e121bed-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:11 GMT + request-id: + - req_011ChU6nJGpU8XP9pkyJVYLz + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=91 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a61409e20fe4c62a-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:17 GMT + request-id: + - req_011ChU6ngVniyzrDPDy4rrq7 + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=90 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140a028de35332-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:22 GMT + request-id: + - req_011ChU6o4imR9uxbLRF7NMYP + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=89 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","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-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+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 + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140a231869f896-PDX + connection: + - keep-alive + content-length: + - '361' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:27 GMT + request-id: + - req_011ChU6oT1xFe86roxvzxMCi + retry-after: + - '10' + server: + - cloudflare + server-timing: + - x-originResponse;dur=83 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":1,"errored":1,"canceled":0,"expired":0},"ended_at":"2026-11-27T20:56:31.564747+00:00","created_at":"2026-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01F4L3igF1CtRRmdHUSpq5Kp/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140a437d260055-PDX + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:32 GMT + request-id: + - req_011ChU6oq9y2YRmmRZGw8AoX + server: + - cloudflare + server-timing: + - x-originResponse;dur=96 + 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: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp + response: + body: + string: '{"id":"msgbatch_01F4L3igF1CtRRmdHUSpq5Kp","type":"message_batch","processing_status":"ended","request_counts":{"processing":0,"succeeded":1,"errored":1,"canceled":0,"expired":0},"ended_at":"2026-11-27T20:56:31.564747+00:00","created_at":"2026-11-27T20:54:59.192956+00:00","expires_at":"2026-11-28T20:54:59.192956+00:00","archived_at":null,"cancel_initiated_at":null,"results_url":"https://api.anthropic.com/v1/messages/batches/msgbatch_01F4L3igF1CtRRmdHUSpq5Kp/results"}' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140a448f570055-PDX + connection: + - keep-alive + content-length: + - '470' + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/json + date: + - Fri, 27 Nov 2026 20:56:32 GMT + request-id: + - req_011ChU6oqrtNnUTVPnppWHQu + 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/binary + accept-encoding: + - gzip, deflate, zstd + anthropic-version: + - '2026-10-21' + connection: + - keep-alive + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 2.12.0 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - Linux + x-stainless-package-version: + - 2.12.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_01F4L3igF1CtRRmdHUSpq5Kp/results + response: + body: + string: '{"custom_id":"req-ok","result":{"type":"succeeded","message":{"model":"claude-haiku-5-5","id":"msg_011ChU6ihir56zStPWtdMkXw","type":"message","role":"assistant","content":[{"type":"text","text":"OK"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":15,"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,"output_tokens_details":{"thinking_tokens":0},"service_tier":"batch","inference_geo":"global","speed":"standard"},"diagnostics":null}}} + + {"custom_id":"req-err","result":{"type":"errored","error":{"type":"error","error":{"details":null,"type":"not_found_error","message":"model: + claude-nonexistent-batch-test"},"request_id":null}}} + + ' + headers: + anthropic-organization-id: + - 27796668-7351-40ac-acc4-024aee8995a5 + anthropic-workspace-id: + - wrkspc_018bFG1FgNVWqx5pthtdGTzS + cache-control: + - private, no-store + cf-cache-status: + - DYNAMIC + cf-ray: + - a6140a4589750055-PDX + connection: + - keep-alive + content-disposition: + - attachment; filename*=utf-8''msgbatch_01F4L3igF1CtRRmdHUSpq5Kp_results.jsonl + content-security-policy: + - default-src 'none'; frame-ancestors 'none' + content-type: + - application/x-jsonl + date: + - Fri, 27 Nov 2026 20:56:33 GMT + request-id: + - req_011ChU6oraJGQYaZdCFqN935 + server: + - cloudflare + server-timing: + - x-originResponse;dur=200 + 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/TestBatchesCreateSpans.test_sync_batches_create_logs_error_on_failure.yaml b/py/src/braintrust/integrations/anthropic/cassettes/latest/TestBatchesCreateSpans.test_sync_batches_create_logs_error_on_failure.yaml deleted file mode 100644 index bd75874a0..000000000 --- a/py/src/braintrust/integrations/anthropic/cassettes/latest/TestBatchesCreateSpans.test_sync_batches_create_logs_error_on_failure.yaml +++ /dev/null @@ -1,83 +0,0 @@ -interactions: -- request: - body: '{"requests":[]}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate, zstd - anthropic-version: - - '2026-10-21' - connection: - - keep-alive - content-length: - - '15' - content-type: - - application/json - host: - - api.anthropic.com - user-agent: - - Anthropic/Python 2.14.0 - x-stainless-arch: - - arm64 - x-stainless-async: - - 'false' - x-stainless-lang: - - python - x-stainless-os: - - MacOS - x-stainless-package-version: - - 2.14.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: '{"type":"error","error":{"type":"invalid_request_error","message":"requests: - List should have at least 1 item after validation, not 0"},"request_id":"req_011ChZLGMQeSkhnSKKqcLY7P"}' - headers: - anthropic-organization-id: - - 27796668-7351-40ac-acc4-024aee8995a5 - anthropic-workspace-id: - - wrkspc_018bFG1FgNVWqx5pthtdGTzS - cf-cache-status: - - DYNAMIC - cf-ray: - - a62acf878db3de61-YYZ - connection: - - keep-alive - content-security-policy: - - default-src 'none'; frame-ancestors 'none' - content-type: - - application/json - date: - - Mon, 30 Nov 2026 15:15:59 GMT - request-id: - - req_011ChZLGMQeSkhnSKKqcLY7P - server: - - cloudflare - server-timing: - - x-originResponse;dur=94 - strict-transport-security: - - max-age=31536000; includeSubDomains; preload - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-robots-tag: - - none - x-should-retry: - - 'false' - status: - code: 400 - message: Bad Request -version: 1 diff --git a/py/src/braintrust/integrations/anthropic/cassettes/latest/TestBatchesCreateSpans.test_sync_batches_create_multi_model_metadata.yaml b/py/src/braintrust/integrations/anthropic/cassettes/latest/TestBatchesCreateSpans.test_sync_batches_create_multi_model_metadata.yaml deleted file mode 100644 index e90879895..000000000 --- a/py/src/braintrust/integrations/anthropic/cassettes/latest/TestBatchesCreateSpans.test_sync_batches_create_multi_model_metadata.yaml +++ /dev/null @@ -1,86 +0,0 @@ -interactions: -- request: - body: '{"requests":[{"custom_id":"req-1","params":{"model":"claude-haiku-5-5","max_tokens":100,"messages":[{"role":"user","content":"Hi"}]}},{"custom_id":"req-2","params":{"model":"claude-sonnet-5-5","max_tokens":100,"messages":[{"role":"user","content":"Hello"}]}}]}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate, zstd - anthropic-version: - - '2026-10-21' - connection: - - keep-alive - content-length: - - '260' - content-type: - - application/json - host: - - api.anthropic.com - user-agent: - - Anthropic/Python 2.14.0 - x-stainless-arch: - - arm64 - x-stainless-async: - - 'false' - x-stainless-lang: - - python - x-stainless-os: - - MacOS - x-stainless-package-version: - - 2.14.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_01Lughwve1xiK1UrziFjifTy","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-11-30T15:15:59.744030+00:00","expires_at":"2026-12-01T15:15:59.744030+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: - - '499990' - anthropic-workspace-id: - - wrkspc_018bFG1FgNVWqx5pthtdGTzS - cf-cache-status: - - DYNAMIC - cf-ray: - - a62acf88cc95ab34-YYZ - connection: - - keep-alive - content-length: - - '361' - content-security-policy: - - default-src 'none'; frame-ancestors 'none' - content-type: - - application/json - date: - - Mon, 30 Nov 2026 15:15:59 GMT - request-id: - - req_011ChZLGNE1JRwv7qjdcNjHe - server: - - cloudflare - server-timing: - - x-originResponse;dur=268 - 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/test_anthropic.py b/py/src/braintrust/integrations/anthropic/test_anthropic.py index a032be1ec..29bc64588 100644 --- a/py/src/braintrust/integrations/anthropic/test_anthropic.py +++ b/py/src/braintrust/integrations/anthropic/test_anthropic.py @@ -3,15 +3,25 @@ """ import inspect +import io import json import time -import unittest.mock from types import SimpleNamespace import anthropic import pytest -from braintrust import Attachment, logger -from braintrust.integrations.anthropic import AnthropicIntegration, wrap_anthropic +from braintrust import ( + Attachment, + logger, + start_span, +) +from braintrust.integrations.anthropic import ( + AnthropicIntegration, + complete_anthropic_batch_trace, + complete_anthropic_batch_trace_async, + start_anthropic_batch_trace, + wrap_anthropic, +) from braintrust.integrations.anthropic._utils import _try_to_dict, extract_anthropic_usage from braintrust.integrations.anthropic.tracing import TracedMessageStream, _normalize_anthropic_input from braintrust.integrations.test_utils import verify_autoinstrument_script @@ -1626,8 +1636,8 @@ def _make_batch_requests(model=MODEL): ] -class TestBatchesCreateSpans: - """Tests verifying that batches.create() produces correct spans.""" +class TestAnthropicBatchTracing: + """Tests for spec-compliant Anthropic batch tracing (no auto-instrumentation + explicit APIs).""" @pytest.mark.vcr @pytest.mark.asyncio @@ -1641,7 +1651,7 @@ class TestBatchesCreateSpans: ], ids=["sync", "async", "beta-sync", "beta-async"], ) - async def test_batches_create_produces_span(self, memory_logger, is_async, beta, vcr_cassette_name): + async def test_batches_create_not_auto_instrumented(self, memory_logger, is_async, beta, vcr_cassette_name): assert not memory_logger.pop() client = wrap_anthropic(_get_async_client() if is_async else _get_client()) @@ -1652,137 +1662,354 @@ async def test_batches_create_produces_span(self, memory_logger, is_async, beta, assert result.id assert result.processing_status == "in_progress" + assert memory_logger.pop() == [] - spans = memory_logger.pop() - assert len(spans) == 1 - span = spans[0] - assert span["span_attributes"]["name"] == "anthropic.messages.batches.create" - assert span["span_attributes"]["type"] == "task" - assert span["metadata"]["provider"] == "anthropic" - assert span["metadata"]["num_requests"] == 2 - assert span["metadata"]["model"] == MODEL - assert span["input"] == [{"custom_id": "req-1"}, {"custom_id": "req-2"}] - assert span["output"]["id"] == result.id - assert span["output"]["processing_status"] == "in_progress" - assert span["output"]["request_counts"]["processing"] == 2 + @pytest.mark.vcr(**({"cassette_name": "TestBatchesResultsSpans.test_batches_results_produces_span[sync]"})) + @pytest.mark.asyncio + @pytest.mark.parametrize("is_async", [False, True], ids=["sync", "async"]) + async def test_explicit_start_and_complete_batch_trace(self, memory_logger, vcr_cassette, is_async): + assert not memory_logger.pop() - @pytest.mark.vcr - def test_sync_batches_create_logs_error_on_failure(self, memory_logger): + requests = _make_batch_requests(LATEST_MODEL) + wrapped_sync = wrap_anthropic(_get_client()) + created_batch = wrapped_sync.messages.batches.create(requests=requests) + assert memory_logger.pop() == [] + + # Start explicit batch trace after Anthropic accepts the batch. + context = start_anthropic_batch_trace(batch=created_batch, requests=requests) + assert isinstance(context, str) + parsed_ctx = json.loads(context) + assert parsed_ctx["version"] == 1 + assert parsed_ctx["batch_id"] == created_batch.id + assert parsed_ctx["request_count"] == 2 + assert len(parsed_ctx["request_ids_digest"]) == 64 + # Context must not contain prompts or propagated event payloads. + assert "What is 2+2?" not in context + assert "What is 3+3?" not in context + + start_spans = memory_logger.pop() + assert len(start_spans) == 3 + task_start = find_span_by_name(start_spans, "anthropic.batch") + assert task_start is not None + assert task_start["span_attributes"]["type"] == SpanTypeAttribute.TASK.value + assert task_start["context"]["span_origin"]["instrumentation"]["name"] == "anthropic-auto" + assert task_start["metadata"]["provider"] == "anthropic" + assert task_start["metadata"]["batch_id"] == created_batch.id + assert task_start["metadata"]["processing_status"] == "in_progress" + assert "input" not in task_start + assert "output" not in task_start + assert "start" in task_start["metrics"] + assert "end" not in task_start["metrics"] + + child_starts = {s["metadata"]["custom_id"]: s for s in find_spans_by_type(start_spans, SpanTypeAttribute.LLM)} + assert set(child_starts) == {"req-1", "req-2"} + for custom_id, child in child_starts.items(): + assert child["span_attributes"]["name"] == "anthropic.messages.create" + assert child["context"]["span_origin"]["instrumentation"]["name"] == "anthropic-auto" + assert child["span_parents"] == [task_start["span_id"]] + assert child["root_span_id"] == task_start["root_span_id"] + assert child["metadata"]["provider"] == "anthropic" + assert child["metadata"]["model"] == LATEST_MODEL + assert child["metadata"]["batch_id"] == created_batch.id + assert child["metadata"]["custom_id"] == custom_id + assert isinstance(child["input"], list) and len(child["input"]) == 1 + assert "start" in child["metrics"] + assert "end" not in child["metrics"] + + # Non-terminal batch leaves task and children pending. + complete_anthropic_batch_trace(batch=created_batch, context=context) + assert memory_logger.pop() == [] + + # Poll until ended (replayed from cassette). + batch = created_batch + 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 = wrapped_sync.messages.batches.retrieve(batch.id) + assert memory_logger.pop() == [] + + # Fetch results via wrapped client (must emit zero auto spans) and stream into complete API. + if is_async: + wrapped_async = wrap_anthropic(_get_async_client()) + result_stream = await wrapped_async.messages.batches.results(message_batch_id=batch.id) + assert memory_logger.pop() == [] + recorded_entries: list[object] = [] + + async def _tee_async(stream): + async for item in stream: + recorded_entries.append(item) + yield item + + await complete_anthropic_batch_trace_async(batch=batch, results=_tee_async(result_stream), context=context) + else: + result_stream = wrapped_sync.messages.batches.results(batch.id) + assert memory_logger.pop() == [] + recorded_entries = [] + + def _tee_sync(stream): + for item in stream: + recorded_entries.append(item) + yield item + + complete_anthropic_batch_trace(batch=batch, results=_tee_sync(result_stream), context=context) + + complete_spans = memory_logger.pop() + assert len(complete_spans) == 3 + + updates_by_id = {s["id"]: s for s in complete_spans} + assert task_start["id"] in updates_by_id + task_end = updates_by_id[task_start["id"]] + assert task_end["span_id"] == task_start["span_id"] + assert task_end["root_span_id"] == task_start["root_span_id"] + assert task_end["metrics"]["end"] >= task_start["metrics"]["start"] + assert task_end["metadata"]["processing_status"] == "ended" + assert task_end["metadata"]["request_counts"]["succeeded"] == 2 + assert "error" not in task_end + + for custom_id, child_start in child_starts.items(): + child_end = updates_by_id[child_start["id"]] + assert child_end["span_id"] == child_start["span_id"] + assert child_end["root_span_id"] == child_start["root_span_id"] + assert child_end["output"]["role"] == "assistant" + assert child_end["output"]["content"] + assert child_end["metrics"]["prompt_tokens"] > 0 + assert child_end["metrics"]["completion_tokens"] > 0 + assert child_end["metrics"]["tokens"] > 0 + assert child_end["metrics"]["end"] >= child_start["metrics"]["start"] + assert child_end["metadata"]["model"] == LATEST_MODEL + + # Idempotent retry: re-completing with the same context and real recorded entries updates the exact same row/span IDs. + complete_anthropic_batch_trace(batch=batch, results=recorded_entries, context=context) + replay_spans = memory_logger.pop() + assert {s["id"] for s in replay_spans} == set(updates_by_id) + + # Streaming raw JSONL serialized from the real recorded entries also merges into the same row/span IDs. + jsonl_stream = io.StringIO("\n".join(entry.model_dump_json() for entry in recorded_entries)) + complete_anthropic_batch_trace(batch=batch, results=jsonl_stream, context=context) + jsonl_spans = memory_logger.pop() + assert {s["id"] for s in jsonl_spans} == set(updates_by_id) + + @pytest.mark.vcr(**({"cassette_name": "TestBatchesResultsSpans.test_batches_results_produces_span[sync]"})) + def test_collect_only_mode_under_active_parent(self, memory_logger, vcr_cassette): assert not memory_logger.pop() - client = wrap_anthropic(_get_client()) - # Empty requests list triggers a 400 error - with pytest.raises(Exception): - client.messages.batches.create(requests=[]) + requests = _make_batch_requests(LATEST_MODEL) + raw_client = _get_client() + batch = raw_client.messages.batches.create(requests=requests) + 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) + entries = list(raw_client.messages.batches.results(batch.id)) + memory_logger.pop() + + with start_span(name="outer-workflow") as outer: + complete_anthropic_batch_trace(batch=batch, results=entries, requests=requests) spans = memory_logger.pop() - assert len(spans) == 1 - span = spans[0] - assert span["span_attributes"]["name"] == "anthropic.messages.batches.create" - assert span["error"] + outer_span = find_span_by_name(spans, "outer-workflow") + assert outer_span is not None + task_starts = [s for s in spans if s.get("span_attributes", {}).get("name") == "anthropic.batch"] + assert len(task_starts) == 1 + task_start = task_starts[0] + assert task_start["span_parents"] == [outer_span["span_id"]] + assert task_start["root_span_id"] == outer_span["root_span_id"] + + # Both start rows and update rows are emitted for task + 2 children. + task_updates = [s for s in spans if s["id"] == task_start["id"] and "end" in s.get("metrics", {})] + assert len(task_updates) == 1 + child_starts = [s for s in spans if s.get("span_attributes", {}).get("name") == "anthropic.messages.create"] + assert len(child_starts) == 2 + for child in child_starts: + assert child["span_parents"] == [task_start["span_id"]] + assert child["root_span_id"] == outer_span["root_span_id"] + child_updates = [s for s in spans if s["id"] == child["id"] and "end" in s.get("metrics", {})] + assert len(child_updates) == 1 + assert child_updates[0]["output"]["role"] == "assistant" - @pytest.mark.vcr - def test_sync_batches_create_multi_model_metadata(self, memory_logger): - """When batch requests use different models, metadata should include 'models' list.""" + @pytest.mark.vcr(**({"cassette_name": "TestBatchesResultsSpans.test_batches_results_produces_span[sync]"})) + def test_incomplete_and_invalid_context_handling(self, memory_logger, vcr_cassette): assert not memory_logger.pop() - client = wrap_anthropic(_get_client()) + requests = _make_batch_requests(LATEST_MODEL) + raw_client = _get_client() + created_batch = raw_client.messages.batches.create(requests=requests) + context = start_anthropic_batch_trace(batch=created_batch, requests=requests) + assert context is not None + start_spans = memory_logger.pop() + task_start = find_span_by_name(start_spans, "anthropic.batch") + assert task_start is not None + + ended_batch = created_batch + deadline = time.time() + 15 * 60 + while ended_batch.processing_status != "ended": + assert time.time() < deadline, f"batch {ended_batch.id} did not end within 15 minutes" + if not vcr_cassette.write_protected: + time.sleep(10) + ended_batch = raw_client.messages.batches.retrieve(ended_batch.id) + entries = list(raw_client.messages.batches.results(ended_batch.id)) + assert len(entries) == 2 + + # Incomplete results (only 1 of 2 real recorded entries): task and children stay pending and retryable. + complete_anthropic_batch_trace(batch=ended_batch, results=entries[:1], context=context) + assert memory_logger.pop() == [] + + # Unknown custom_id in saved-context mode: writes zero stray child rows and leaves task pending. + unknown_entries = [entries[0], entries[1].model_copy(update={"custom_id": "req-unknown"})] + complete_anthropic_batch_trace(batch=ended_batch, results=unknown_entries, context=context) + assert memory_logger.pop() == [] + + # Invalid context without requests: skips tracing cleanly. + complete_anthropic_batch_trace(batch=ended_batch, results=entries, context="not-valid-json") + assert memory_logger.pop() == [] + + # Mismatched batch_id context without requests: skips tracing cleanly. + wrong_batch_context = json.dumps({**json.loads(context), "batch_id": "msgbatch_other"}) + complete_anthropic_batch_trace(batch=ended_batch, results=entries, context=wrong_batch_context) + assert memory_logger.pop() == [] + + # Provider privacy policy redacts output/error/content-bearing metadata on completion updates. + from braintrust._instrumentation import provider_content_allowed + + token = provider_content_allowed.set(lambda: False) + try: + complete_anthropic_batch_trace(batch=ended_batch, results=entries, context=context) + finally: + provider_content_allowed.reset(token) + redacted_spans = memory_logger.pop() + assert len(redacted_spans) == 3 + for span in redacted_spans: + assert "output" not in span + assert "error" not in span + if "metadata" in span: + assert set(span["metadata"]).issubset({"model", "provider"}) + + # Invalid context WITH requests: falls back to collect-only mode using the real recorded batch/results. + complete_anthropic_batch_trace(batch=ended_batch, results=entries, context="corrupt", requests=requests) + fallback_spans = memory_logger.pop() + fallback_task = find_span_by_name(fallback_spans, "anthropic.batch") + assert fallback_task is not None + assert any(s["id"] == fallback_task["id"] and "end" in s.get("metrics", {}) for s in fallback_spans) + + @pytest.mark.vcr + def test_errored_batch_outcome(self, memory_logger, vcr_cassette): + assert not memory_logger.pop() requests = [ { - "custom_id": "req-1", + "custom_id": "req-ok", "params": { - "model": MODEL, - "max_tokens": 100, - "messages": [{"role": "user", "content": "Hi"}], + "model": LATEST_MODEL, + "max_tokens": 32, + "messages": [{"role": "user", "content": "Reply with OK."}], }, }, { - "custom_id": "req-2", + "custom_id": "req-err", "params": { - "model": "claude-sonnet-5-5", - "max_tokens": 100, - "messages": [{"role": "user", "content": "Hello"}], + "model": "claude-nonexistent-batch-test", + "max_tokens": 16, + "messages": [{"role": "user", "content": "hi"}], }, }, ] - result = client.messages.batches.create(requests=requests) - assert result.id - - spans = memory_logger.pop() - assert len(spans) == 1 - span = spans[0] - assert "model" not in span["metadata"] - assert span["metadata"]["models"] == sorted([MODEL, "claude-sonnet-5-5"]) - - -class TestBatchesResultsSpans: - """Tests verifying that batches.results() produces correct spans. - - 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. - """ - - # The setup requests and JSONL payload are identical for both result - # iterators; share the latest recording to avoid submitting two batches. - @pytest.mark.vcr(**({"cassette_name": "TestBatchesResultsSpans.test_batches_results_produces_span[sync]"})) - @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,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() - batch = raw_client.messages.batches.create(requests=_make_batch_requests(LATEST_MODEL)) + client = wrap_anthropic(_get_client()) + created_batch = client.messages.batches.create(requests=requests) + assert memory_logger.pop() == [] + + context = start_anthropic_batch_trace(batch=created_batch, requests=requests) + assert context is not None + start_spans = memory_logger.pop() + task_start = find_span_by_name(start_spans, "anthropic.batch") + assert task_start is not None + child_starts = {s["metadata"]["custom_id"]: s for s in find_spans_by_type(start_spans, SpanTypeAttribute.LLM)} + assert set(child_starts) == {"req-ok", "req-err"} + + batch = created_batch 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() + time.sleep(5) + batch = client.messages.batches.retrieve(batch.id) + assert memory_logger.pop() == [] - client = wrap_anthropic(_get_async_client() if is_async else _get_client()) - 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) + result_stream = client.messages.batches.results(batch.id) + assert memory_logger.pop() == [] + complete_anthropic_batch_trace(batch=batch, results=result_stream, context=context) - assert {entry.custom_id for entry in entries} == {"req-1", "req-2"} - assert any(entry.result.type == "succeeded" for entry in entries) + updates = {s["id"]: s for s in memory_logger.pop()} + assert len(updates) == 3 - spans = memory_logger.pop() - assert len(spans) == 1 - span = spans[0] - 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"] == batch_id - assert span["output"]["type"] == "jsonl_stream" + task_end = updates[task_start["id"]] + assert task_end["metadata"]["processing_status"] == "ended" + assert task_end["metadata"]["request_counts"]["succeeded"] == 1 + assert task_end["metadata"]["request_counts"]["errored"] == 1 + assert task_end["metrics"]["end"] >= task_start["metrics"]["start"] + + ok_end = updates[child_starts["req-ok"]["id"]] + assert ok_end["output"]["role"] == "assistant" + assert ok_end["metrics"]["tokens"] > 0 + assert "error" not in ok_end + + err_end = updates[child_starts["req-err"]["id"]] + assert "not_found_error" in err_end["error"] + assert "claude-nonexistent-batch-test" in err_end["error"] + assert err_end["metrics"]["end"] >= child_starts["req-err"]["metrics"]["start"] - def test_sync_batches_results_logs_error_on_failure(self, memory_logger): + @pytest.mark.vcr + def test_canceled_batch_outcome(self, memory_logger, vcr_cassette): assert not memory_logger.pop() + requests = _make_batch_requests(LATEST_MODEL) client = wrap_anthropic(_get_client()) - with unittest.mock.patch( - "anthropic.resources.messages.batches.Batches.results", - side_effect=Exception("results fetch failed"), - ): - with pytest.raises(Exception, match="results fetch failed"): - client.messages.batches.results("msgbatch_abc123") + created_batch = client.messages.batches.create(requests=requests) + assert memory_logger.pop() == [] - spans = memory_logger.pop() - assert len(spans) == 1 - span = spans[0] - assert span["span_attributes"]["name"] == "anthropic.messages.batches.results" - assert "results fetch failed" in span["error"] + context = start_anthropic_batch_trace(batch=created_batch, requests=requests) + assert context is not None + start_spans = memory_logger.pop() + task_start = find_span_by_name(start_spans, "anthropic.batch") + assert task_start is not None + child_starts = {s["metadata"]["custom_id"]: s for s in find_spans_by_type(start_spans, SpanTypeAttribute.LLM)} + assert set(child_starts) == {"req-1", "req-2"} + + batch = client.messages.batches.cancel(created_batch.id) + assert memory_logger.pop() == [] + + 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(5) + batch = client.messages.batches.retrieve(batch.id) + assert memory_logger.pop() == [] + assert batch.request_counts.canceled >= 1 + + entries = list(client.messages.batches.results(batch.id)) + assert memory_logger.pop() == [] + complete_anthropic_batch_trace(batch=batch, results=entries, context=context) + + updates = {s["id"]: s for s in memory_logger.pop()} + assert len(updates) == 3 + + task_end = updates[task_start["id"]] + assert task_end["metadata"]["processing_status"] == "ended" + assert task_end["metadata"]["request_counts"]["canceled"] >= 1 + assert task_end["metrics"]["end"] >= task_start["metrics"]["start"] + + for entry in entries: + child_end = updates[child_starts[entry.custom_id]["id"]] + assert child_end["metrics"]["end"] >= child_starts[entry.custom_id]["metrics"]["start"] + if entry.result.type == "canceled": + assert "canceled" in child_end["error"] + elif entry.result.type == "succeeded": + assert child_end["output"]["role"] == "assistant" + assert child_end["metrics"]["tokens"] > 0 def _addition_tool(is_async): diff --git a/py/src/braintrust/integrations/anthropic/tracing.py b/py/src/braintrust/integrations/anthropic/tracing.py index 22844e224..b07e6c7d5 100644 --- a/py/src/braintrust/integrations/anthropic/tracing.py +++ b/py/src/braintrust/integrations/anthropic/tracing.py @@ -118,10 +118,6 @@ async def traced_parse(*args, **kwargs): return traced_parse return super().__getattr__(name) - @property - def batches(self): - return AsyncBatches(self.__messages.batches) - async def create(self, *args, **kwargs): if kwargs.get("stream", False): return await self.__create_with_stream_true(*args, **kwargs) @@ -215,10 +211,6 @@ def traced_parse(*args, **kwargs): return traced_parse return super().__getattr__(name) - @property - def batches(self): - return Batches(self.__messages.batches) - def stream(self, *args, **kwargs): return self.__trace_stream(self.__messages.stream, *args, **kwargs) @@ -623,70 +615,6 @@ async def stream(self, session_id, *args, **kwargs): raise -class Batches(Wrapper): - """Wrapper for sync Anthropic Messages Batches resource.""" - - def __init__(self, batches): - super().__init__(batches) - self.__batches = batches - - def create(self, *args, **kwargs): - span = _start_batch_create_span(kwargs) - try: - result = self.__batches.create(*args, **kwargs) - _log_batch_create_to_span(result, span) - return result - except Exception as e: - span.log(error=e) - raise - finally: - span.end() - - def results(self, *args, **kwargs): - span = _start_batch_results_span(args, kwargs) - try: - result = self.__batches.results(*args, **kwargs) - span.log(output={"type": "jsonl_stream"}) - return result - except Exception as e: - span.log(error=e) - raise - finally: - span.end() - - -class AsyncBatches(Wrapper): - """Wrapper for async Anthropic Messages Batches resource.""" - - def __init__(self, batches): - super().__init__(batches) - self.__batches = batches - - async def create(self, *args, **kwargs): - span = _start_batch_create_span(kwargs) - try: - result = await self.__batches.create(*args, **kwargs) - _log_batch_create_to_span(result, span) - return result - except Exception as e: - span.log(error=e) - raise - finally: - span.end() - - async def results(self, *args, **kwargs): - span = _start_batch_results_span(args, kwargs) - try: - result = await self.__batches.results(*args, **kwargs) - span.log(output={"type": "jsonl_stream"}) - return result - except Exception as e: - span.log(error=e) - raise - finally: - span.end() - - def _traced_messages_helper(messages, name): # Preserve AttributeError on versions without these helpers. getattr(messages, name) @@ -1676,57 +1604,6 @@ def _log_managed_agents_stream_to_span(events: list[dict[str, Any]], span) -> No _log_managed_agents_tool_spans(events, span) -def _start_batch_create_span(kwargs): - requests = list(kwargs.get("requests", [])) - # Extract models from the batch requests for metadata - models = set() - for req in requests: - params = req.get("params", {}) if isinstance(req, dict) else getattr(req, "params", {}) - model = params.get("model") if isinstance(params, dict) else getattr(params, "model", None) - if model: - models.add(model) - - metadata = {"provider": "anthropic", "num_requests": len(requests)} - if len(models) == 1: - metadata["model"] = next(iter(models)) - elif models: - metadata["models"] = sorted(models) - - _input = [ - {"custom_id": req.get("custom_id") if isinstance(req, dict) else getattr(req, "custom_id", None)} - for req in requests - ] - - return start_span(name="anthropic.messages.batches.create", type="task", metadata=metadata, input=_input) - - -def _log_batch_create_to_span(result, span): - output = {} - if hasattr(result, "id"): - output["id"] = result.id - if hasattr(result, "processing_status"): - output["processing_status"] = result.processing_status - if hasattr(result, "request_counts"): - rc = result.request_counts - output["request_counts"] = { - "processing": getattr(rc, "processing", 0), - "succeeded": getattr(rc, "succeeded", 0), - "errored": getattr(rc, "errored", 0), - "canceled": getattr(rc, "canceled", 0), - "expired": getattr(rc, "expired", 0), - } - - span.log(output=output) - - -def _start_batch_results_span(args, kwargs): - # message_batch_id can be passed as first positional arg or as kwarg - batch_id = args[0] if args else kwargs.get("message_batch_id") - metadata = {"provider": "anthropic"} - _input = {"message_batch_id": batch_id} - return start_span(name="anthropic.messages.batches.results", type="task", metadata=metadata, input=_input) - - def _convert_base64_source_to_attachment(block_type, source): if not isinstance(source, dict): return None @@ -1986,22 +1863,23 @@ def _log_server_tool_spans(content: Any, parent_span) -> None: def _message_output(message, *, include_parsed_output: bool = False): - content = getattr(message, "content", None) + getter = message.get if isinstance(message, dict) else lambda k, default=None: getattr(message, k, default) + content = getter("content", None) output = { k: v for k, v in { - "role": getattr(message, "role", None), + "role": getter("role", None), "content": content, - "model": getattr(message, "model", None), - "stop_reason": getattr(message, "stop_reason", None), - "stop_sequence": getattr(message, "stop_sequence", None), - "stop_details": getattr(message, "stop_details", None), + "model": getter("model", None), + "stop_reason": getter("stop_reason", None), + "stop_sequence": getter("stop_sequence", None), + "stop_details": getter("stop_details", None), }.items() if v is not None } if include_parsed_output: - parsed_output = getattr(message, "parsed_output", None) + parsed_output = getter("parsed_output", None) if parsed_output is not None: output["parsed_output"] = _normalize_anthropic_data(parsed_output)