GuidesFramework quickstartsClaude Agent SDK

Claude Agent SDK

The Claude Agent SDK from Anthropic (claude-agent-sdk in Python, @anthropic-ai/claude-agent-sdk in TypeScript — formerly the “Claude Code SDK”) wraps Claude models plus tool use into an agent loop. Neens ingests its traces through standard OpenTelemetry with zero Neens-specific code — you point an OTLP exporter at Neens and instrument once at startup.

At a glance

LanguagePython & TypeScript
Instrumentationopeninference-instrumentation-anthropic (instruments the underlying Anthropic Messages API; community-maintained by Arize) — see the note below for the dedicated agent-SDK instrumentor and Anthropic’s native OTLP export
EndpointPOST /v1/traces (OTLP/HTTP)
AuthAuthorization: Bearer nk_live_… agent key

Instrument your agent

Install the instrumentation

The OpenInference Anthropic instrumentor hooks the Anthropic SDK’s messages client — every Claude call the agent makes becomes an OpenTelemetry LLM span.

pip install openinference-instrumentation-anthropic opentelemetry-sdk opentelemetry-exporter-otlp

This assumes you already have the agent SDK itself installed (pip install claude-agent-sdk).

Point the exporter at Neens

from openinference.instrumentation.anthropic import AnthropicInstrumentor
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
 
exporter = OTLPSpanExporter(
    endpoint="https://<your-neens-host>/v1/traces",
    headers={"Authorization": "Bearer nk_live_your_key_here"},
)
 
provider = TracerProvider()
provider.add_span_processor(BatchSpanProcessor(exporter))
trace.set_tracer_provider(provider)
 
# Instrument once, before you run your agent.
AnthropicInstrumentor().instrument()

Run your agent

Run your agent as usual — call query(...) or drive a ClaudeSDKClient. Spans export to Neens in the background.

What Neens captures

The instrumentor emits a span for every Claude model call the agent makes — model name, input/output token counts, and the prompt/response messages — plus a span for each tool use, so you see the full agent trajectory. For multi-turn agents, set a conversation/session id so Neens groups the turns into one session (see Traces & sessions).

Neens speaks standard OTLP — this is not a Neens SDK fork. Any OpenTelemetry-instrumented Claude Agent SDK app exports to Neens by pointing its exporter at the endpoint above. See Send traces for the full attribute reference, size limits, and response codes.

Two other real trace paths — Neens reads all of them. ① A dedicated agent-SDK instrumentor, openinference-instrumentation-claude-agent-sdk (also community/Arize), traces query() / ClaudeSDKClient as agent-level spans with child tool spans — install it instead of -anthropic and call ClaudeAgentSDKInstrumentor().instrument() for agent-shaped traces rather than raw LLM calls. ② The Agent SDK has a native OTLP export (it runs the Claude Code CLI, which has OpenTelemetry built in): set CLAUDE_CODE_ENABLE_TELEMETRY=1, OTEL_TRACES_EXPORTER=otlp, and CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 (trace export is beta; metrics and log events are GA), then point OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf + OTEL_EXPORTER_OTLP_ENDPOINT/OTEL_EXPORTER_OTLP_HEADERS at Neens as above — it emits claude_code.interaction, claude_code.llm_request, and claude_code.tool spans. This needs no OpenInference package, but the trace schema is beta and may change between releases. We lead with the OpenInference instrumentor for a stable, GA trace shape consistent with the other Neens quickstarts.

Verify

Open Traces in Neens; your agent runs appear within a few seconds. Continue to Traces & sessions.