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.

Installation

pip install respan-exporter-anthropic-agents

Quickstart

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

exporter = RespanAnthropicAgentsExporter()

async def main() -> None:
    options = exporter.with_options(
        options=ClaudeAgentOptions(
            allowed_tools=["Read", "Glob", "Grep"],
            permission_mode="acceptEdits",
        )
    )

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

asyncio.run(main())

Configuration

Environment Variables

Variable Required Description
RESPAN_API_KEY Yes Your Respan API key.
RESPAN_BASE_URL No Base URL for all Respan services. Defaults to https://api.respan.ai.

RESPAN_BASE_URL is the single base URL that controls where telemetry is exported. The exporter automatically appends /api/v1/traces/ingest to build the full endpoint.

Tracing vs Inference URLs (Important)

There are two independent URL planes:

  • Tracing export URL (Respan telemetry ingest): controlled by exporter base_url / RESPAN_BASE_URL.
  • Inference/proxy URL (where Claude requests are sent): controlled by Anthropic SDK env/options such as ANTHROPIC_BASE_URL.

Using Respan tracing + Respan gateway together:

from claude_agent_sdk import ClaudeAgentOptions
from respan_exporter_anthropic_agents import RespanAnthropicAgentsExporter

api_key = "your_respan_key"
respan_base_url = "https://api.respan.ai/api"

exporter = RespanAnthropicAgentsExporter(
    api_key=api_key,
    base_url=respan_base_url,  # tracing export
)

options = ClaudeAgentOptions(
    env={
        "ANTHROPIC_BASE_URL": f"{respan_base_url.rstrip('/')}/anthropic",  # inference proxy
        "ANTHROPIC_API_KEY": api_key,
        "ANTHROPIC_AUTH_TOKEN": api_key,
    }
)

Constructor Parameters

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.

Examples

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.12.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.12.tar.gz.

File metadata

File hashes

Hashes for respan_exporter_anthropic_agents-1.0.12.tar.gz
Algorithm Hash digest
SHA256 44add3420af0408608262e2d2d0e0266e11f776e6a66bba0e91c9cea3bb0d0fb
MD5 e379fef835a4c91f0646b2f948914603
BLAKE2b-256 99873b010032fb44b702ca53723aba52a26a2c00839e1f6fe7fbc65d2a5edd84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for respan_exporter_anthropic_agents-1.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 92aa9c9ddb670aad22f3c89139d45a94fd1a6cec5733b549771a0475f87d82d5
MD5 dee23dc316aa676e2c4c97e21f9b4e66
BLAKE2b-256 1a142538d91c14296a10bb0de75cc488c698a20cc73371a14769cbd76fe4575d

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