Skip to main content

Exporter for Anthropic Agent SDK telemetry to Respan

Project description

Respan Exporter for Anthropic Agent SDK

respan.ai | Documentation

Exporter for Anthropic Agent SDK telemetry to Respan.

Configuration

1. Install

pip install claude-agent-sdk respan-exporter-anthropic-agents

2. Set Environment Variables

Variable Required Description
RESPAN_API_KEY Yes Respan API key used for telemetry export.
RESPAN_BASE_URL No Respan base URL for telemetry export. Defaults to https://api.respan.ai.
ANTHROPIC_BASE_URL No Inference/proxy base URL used by the Anthropic SDK.
ANTHROPIC_API_KEY Usually Key used by the Anthropic SDK for inference calls.
ANTHROPIC_AUTH_TOKEN Optional Alternate auth token used by some Anthropic client flows.

Set both groups together when needed. RESPAN_* controls tracing export, while ANTHROPIC_* controls where model requests are sent.

# Tracing export (Respan telemetry)
RESPAN_API_KEY=your_respan_key
RESPAN_BASE_URL=https://api.respan.ai/api

# Inference/proxy routing (Anthropic SDK)
ANTHROPIC_BASE_URL=http://localhost:8000/api
ANTHROPIC_API_KEY=your_inference_key
ANTHROPIC_AUTH_TOKEN=your_inference_key

RESPAN_BASE_URL controls telemetry export only. The exporter automatically appends /api/v1/traces/ingest to build the full ingest endpoint.

Constructor Parameters (Optional)

All configuration can also be passed directly to the constructor.

Recommended pattern (matches the runnable examples):

exporter = RespanAnthropicAgentsExporter(
    api_key="your_respan_key",        # Optional; falls back to RESPAN_API_KEY
    base_url="https://api.respan.ai", # Optional; falls back to RESPAN_BASE_URL
)

Local gateway/proxy override:

exporter = RespanAnthropicAgentsExporter(
    api_key="your_respan_key",
    base_url="http://localhost:8000/api",
)

Resolution order:

  • api_key: constructor api_key -> RESPAN_API_KEY
  • endpoint: constructor endpoint -> derived from constructor base_url -> derived from RESPAN_BASE_URL

In normal usage you should set base_url (or RESPAN_BASE_URL) and let the exporter derive the ingest endpoint automatically. endpoint exists for internal/advanced cases and takes precedence over base_url if both are set.

Quickstart

3. Run Script

Save this as quickstart.py:

import asyncio
import os
from claude_agent_sdk import ClaudeAgentOptions
from respan_exporter_anthropic_agents.respan_anthropic_agents_exporter import (
    RespanAnthropicAgentsExporter,
)

respan_api_key = os.environ["RESPAN_API_KEY"]
respan_base_url = os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api").rstrip("/")
anthropic_base_url = os.getenv("ANTHROPIC_BASE_URL", f"{respan_base_url}/anthropic")
anthropic_api_key = os.getenv("ANTHROPIC_API_KEY", respan_api_key)

exporter = RespanAnthropicAgentsExporter(
    api_key=respan_api_key,
    base_url=respan_base_url,
)

async def main() -> None:
    options = exporter.with_options(
        options=ClaudeAgentOptions(
            allowed_tools=["Read", "Glob", "Grep"],
            permission_mode="acceptEdits",
            env={
                "ANTHROPIC_BASE_URL": anthropic_base_url,
                "ANTHROPIC_API_KEY": anthropic_api_key,
                "ANTHROPIC_AUTH_TOKEN": os.getenv("ANTHROPIC_AUTH_TOKEN", anthropic_api_key),
            },
        )
    )

    async for message in exporter.query(
        prompt="Analyze this repository and summarize architecture.",
        options=options,
    ):
        print(message)

asyncio.run(main())

Run it:

python quickstart.py

4. View Dashboard

Open:

  • https://platform.respan.ai/platform/traces

Further Reading

Runnable examples with full setup instructions:

Dev Guide

Running Tests

# Unit tests
python -m unittest tests.test_exporter -v

# Live integration test (opt-in, makes real API calls)
export RESPAN_API_KEY="your_respan_key"
export IS_REAL_GATEWAY_TESTING_ENABLED=1
python -m unittest tests.test_real_gateway_integration -v

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

respan_exporter_anthropic_agents-1.0.14.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file respan_exporter_anthropic_agents-1.0.14.tar.gz.

File metadata

File hashes

Hashes for respan_exporter_anthropic_agents-1.0.14.tar.gz
Algorithm Hash digest
SHA256 b1e914dffc260344769283397b5a2ede5d664c25c90e56f5f8c950c475842c5d
MD5 1459f3307532aabc99299b63c2395c88
BLAKE2b-256 f1a69a2673a5254401ecb25a573d829363d4f1ed84d38ca4e8ba7efc348dec9a

See more details on using hashes here.

File details

Details for the file respan_exporter_anthropic_agents-1.0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_exporter_anthropic_agents-1.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 2d062e924796372c5a7c9fad2425540f7952a68045f6aa79b0e56e4ffcb25921
MD5 56f1985dfa12df6c5b1d0ed108ac2e1b
BLAKE2b-256 5fc0563a3808e3516bf69d9ef4b0c30ac2adafed98d29cbca2d7299b16953328

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page