Skip to main content
This integration is only for Agent tracing. If you are looking for the Anthropic integration with the AI gateway, please see the Anthropic integration.
Give us a star on GitHub!
The Anthropic Agent SDK enables you to build agentic workflows powered by Claude. Keywords AI provides an exporter that automatically captures and sends traces from the Anthropic Agent SDK to Keywords AI for monitoring, debugging, and optimization.

Quickstart

Install the Anthropic Agent SDK and the Keywords AI exporter, then configure the exporter to send traces to Keywords AI.

Prerequisites

pip install respan-exporter-anthropic-agents
Set up your environment variables:
.env
RESPAN_API_KEY=YOUR_KEYWORDSAI_API_KEY
RESPAN_BASE_URL=https://api.keywordsai.co
VariableRequiredDescription
RESPAN_API_KEYYesYour Keywords AI API key
RESPAN_BASE_URLNoBase URL for Keywords AI. Defaults to https://api.keywordsai.co. The exporter automatically appends /api/v1/traces/ingest to build the full endpoint.
If you are on the enterprise platform, please use your enterprise endpoint as the base URL.

Hello World example

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

All configuration can also be passed directly to the constructor, which takes priority over environment variables:
exporter = RespanAnthropicAgentsExporter(
    api_key="your_keywordsai_key",          # Overrides RESPAN_API_KEY
    base_url="https://api.keywordsai.co",   # Overrides RESPAN_BASE_URL
    endpoint="https://custom/ingest",       # Full endpoint URL (overrides base_url)
    timeout_seconds=15,
    max_retries=3,
    base_delay_seconds=1.0,
    max_delay_seconds=30.0,
)