Skip to main content

AnoSys SDK for Anthropic

Automatically capture and send Anthropic (Claude) API calls to AnoSys for monitoring, analytics, and observability.

Features

  • Native Instrumentation - Uses the OpenTelemetry spans the Anthropic SDK emits itself; no third-party instrumentor
  • Streaming Support - messages.stream() and stream=True calls are captured with final usage
  • OpenTelemetry Semantic Conventions - Follows Gen AI standards, same columns as the OpenAI integration
  • Prompt caching and thinking - Cache read/write tokens and available extended-thinking content are tracked

Installation

Requires Python 3.10 or later.

pip install anosys-sdk-anthropic

Requires anthropic>=2.0.0.

Quick Start

import os
import anthropic
from anosys_sdk_anthropic import AnosysAnthropicLogger

os.environ["ANTHROPIC_API_KEY"] = "your-anthropic-key"
os.environ["ANOSYS_API_KEY"] = "your-anosys-key"

# Initialize (do once at startup, before creating clients)
AnosysAnthropicLogger()

# Use Anthropic normally - instrumented calls are logged
client = anthropic.Anthropic()

message = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    system="You are a helpful assistant.",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(message.content[0].text)

Options

AnosysAnthropicLogger(
    get_user_context=lambda: {"session_id": "abc", "token": "user-token"},
    capture_content=True,       # record prompts and completions (default)
    use_batch_processor=False,  # BatchSpanProcessor instead of SimpleSpanProcessor
)

capture_content sets ANTHROPIC_OPEN_TELEMETRY_TRACES_CONTENT_MODE=content when it is not already set. The SDK reads it when a client is constructed, so create clients after the logger. A client given its own open_telemetry option uses that option instead, and the SDK treats it as complete: open_telemetry={"tracer_provider": provider} alone silently switches the client to metadata-only. When you need to pass an option, start from get_anthropic_open_telemetry_options(), which keeps the active provider and your capture_content choice:

from anosys_sdk_anthropic import get_anthropic_open_telemetry_options

client = anthropic.Anthropic(open_telemetry={**get_anthropic_open_telemetry_options(), "conversation_id": "abc"})

If your application already registers an OpenTelemetry TracerProvider, the logger attaches to it. It sends the Anthropic SDK's spans plus any GenAI spans your code creates around them (spans with a gen_ai.operation.name, such as an agent loop or tool calls, as in the support-copilot notebook); other spans on the provider are skipped.

What Data is Captured?

Following OpenTelemetry Gen AI standards:

  • gen_ai.system / gen_ai.provider.name - Always "anthropic"
  • gen_ai.request.model, gen_ai.request.max_tokens, gen_ai.request.stop_sequences
  • gen_ai.response.model, gen_ai.response.id, gen_ai.response.finish_reasons (stop reason)
  • gen_ai.usage.input_tokens (including cached tokens), gen_ai.usage.output_tokens, gen_ai.usage.total_tokens
  • Prompt cache tokens (cvn4 read, cvn5 write) and extended thinking (cvb3)
  • System instructions, input and output messages
  • Timestamps, duration, errors

Records are tagged cvs200 = "AnthropicTelemetry". See MAPPINGS.md for the column map.

Environment Variables

Variable Required Description
ANOSYS_API_KEY Yes Your AnoSys API key
ANTHROPIC_API_KEY Yes Your Anthropic API key

License

Apache 2.0

Content controls

See the content-controls reference for encryption coverage, default columns, size limits, and limitations. Encryption is opt-in and applies to selected string fields; it does not encrypt the complete record.

Collection follows one level for every AnoSys SDK: ANOSYS_COLLECTION_LEVEL=full (default), metadata (no prompts, completions or tool data) or off, a project .anosys file can only lower it, and ANOSYS_DISABLE=1 stops all sending. Without an API key nothing is sent. Telemetry is sent in the background and never delays your calls. See the data-collection policy.

Metadata

Release files for anosys-sdk-anthropic 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anosys-sdk-anthropic 1.1.0
File Size Uploaded Provenance Actions
anosys_sdk_anthropic-1.1.0.tar.gz 19.7 kB Without provenance Details for anosys_sdk_anthropic-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for anosys-sdk-anthropic 1.1.0
File Interpreter ABI Platform Actions
anosys_sdk_anthropic-1.1.0-py3-none-any.whl Python 3 none any Details for anosys_sdk_anthropic-1.1.0-py3-none-any.whl

Total release size: 36.7 kB

Release files / anosys_sdk_anthropic-1.1.0.tar.gz

Download URL anosys_sdk_anthropic-1.1.0.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ebdbb01d53568b02c2a267a21078b625aef3d6d0dcfd830d5cb220bd80b8e13d
BLAKE2b-256 checksum
How to use checksums
f4c90842fd52d3ec3af16a14f8b1c44affa567af4cb21dbe2b9882959ce62874
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / anosys_sdk_anthropic-1.1.0-py3-none-any.whl

Download URL anosys_sdk_anthropic-1.1.0-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed4940c31a6b584e7b03b1d126fc5d0820bdf74d8fdc87c6f9e136742e24117d
BLAKE2b-256 checksum
How to use checksums
9a38b05c743c0365ec1e28ab6be42c5a104796f23089a922ca8b52f905cebdac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for anosys-sdk-anthropic 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page