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)
# Optional: set only if you use a custom proxy/gateway base URL
# ANTHROPIC_BASE_URL=https://your-anthropic-base-url
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. In normal usage, instantiate RespanAnthropicAgentsExporter() with no arguments and configure via environment variables. ANTHROPIC_BASE_URL is optional. If you use a gateway/proxy, set it to that gateway's Anthropic-compatible base URL.

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"]
anthropic_base_url = os.getenv("ANTHROPIC_BASE_URL")
anthropic_api_key = os.getenv("ANTHROPIC_API_KEY", respan_api_key)
anthropic_auth_token = os.getenv("ANTHROPIC_AUTH_TOKEN", anthropic_api_key)

exporter = RespanAnthropicAgentsExporter()

async def main() -> None:
    anthropic_env = {
        "ANTHROPIC_API_KEY": anthropic_api_key,
        "ANTHROPIC_AUTH_TOKEN": anthropic_auth_token,
    }
    if anthropic_base_url:
        anthropic_env["ANTHROPIC_BASE_URL"] = anthropic_base_url

    options = exporter.with_options(
        options=ClaudeAgentOptions(
            allowed_tools=["Read", "Glob", "Grep"],
            permission_mode="acceptEdits",
            env=anthropic_env,
        )
    )

    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.15.tar.gz (9.9 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.15.tar.gz.

File metadata

File hashes

Hashes for respan_exporter_anthropic_agents-1.0.15.tar.gz
Algorithm Hash digest
SHA256 3af27aa19d5f75b2afd0087ffb0744aa80665921e7484d62a7dbcd722ed0039e
MD5 8d229a5afe7f28531341280b8d3d020d
BLAKE2b-256 c47b8eb2af43256d1fd55c395d10b09ddbb6c2b1de18231b4af7f4f9d50c3a3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for respan_exporter_anthropic_agents-1.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 5a99338c6c251dadbe2eb07d987ba486a50946361eab54bd24125fcca8e8aecb
MD5 65a4bc3ad632466352f05fb5fcd28c0d
BLAKE2b-256 ffa110e244f09bdc4a73c059f46a49cb40b54bb55d3c21681ed8ab053d6491ff

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