Framework guide
Anthropic
Record Anthropic Messages API calls as SupaTrace events from Python.
Python SDK: Beta. JavaScript SDK: Coming soon. pip install supatrace==0.1.0 (alpha, Python 3.10+). The JavaScript package is not published to npm. See SDK availability.
Record a call in source mode Beta
Source mode is the default. It makes no network request. The SDK checks your events against the server's batch rules and writes one file to a local spool for you to review. The example records the model name and token counts, not the prompt or reply.
pip install supatrace==0.1.0import datetime
import supatrace
import anthropic
trace = supatrace.init(service="support-bot", spool="./spool")
now = lambda: datetime.datetime.now(datetime.timezone.utc).isoformat()
started = now()
reply = anthropic.Anthropic().messages.create(model="YOUR_MODEL", max_tokens=256, messages=[{"role": "user", "content": "Say hello."}])
result = trace.batch([
{"id": "req-1", "time": started, "kind": "request", "name": "messages", "data": {"model": "YOUR_MODEL"}},
{"id": "res-1", "time": now(), "kind": "response", "name": "messages", "data": {"input_tokens": reply.usage.input_tokens, "output_tokens": reply.usage.output_tokens}},
])
print(result["report"]["valid"], result["report"]["path"])From Node, use the same trace.batch pattern as the OpenAI Node example. The JavaScript SDK has no automatic Anthropic instrumentation.
Review, then upload
Read the spooled file. Remove anything you do not want stored. Then upload it as shown in the quickstart. Batch limits apply.
Automatic spans over OTLP Beta
With mode="otlp" the Python SDK registers the opentelemetry-instrumentation-anthropic instrumentor when it is installed and exports spans to SUPATRACE_OTLP_ENDPOINT + /v1/traces, authenticated with your write key. Framework instrumentation has local tests but no hosted acceptance proof. For a first trace, use a stock exporter from the OpenTelemetry guide.
pip install "opentelemetry-sdk>=1.27" "opentelemetry-exporter-otlp-proto-http>=1.27" opentelemetry-instrumentation-anthropic
export SUPATRACE_OTLP_ENDPOINT="https://supatrace.dev" # SupaTrace SDK OTLP mode (Python Beta; JavaScript source only)
export SUPATRACE_API_KEY="YOUR_WRITE_KEY"import supatrace
trace = supatrace.init(service="support-bot", mode="otlp", instruments=["anthropic"])
print(trace.capture["sending"], trace.capture["instrumented"], trace.capture["skipped"])Nothing is sent unless the endpoint, the key and the OpenTelemetry packages are all present. When one is missing, trace.capture["skipped"] says which. Prompt and response content is not captured unless you pass capture_content=True or set SUPATRACE_CAPTURE_CONTENT=1.