Anthropic / Claude coverage

Three paths to bring every Claude call at your company under Trefur. Pick one — or layer them. The Admin API connector covers the long tail (workspaces, members, keys, daily usage, audit events) without code changes; the proxy + SDK paths give you full content scanning where you can deploy them.

Anthropic does NOT support OAuth for the Admin API. The connector authenticates with a scoped admin key (sk-ant-admin01-…). Functionally that's a service-account equivalent — same trust model, no per-user grant layer. Anthropic has hinted at scoped admin keys on the roadmap; we will add per-capability narrowing the moment they ship. Until then, treat the admin key like any high-privilege service credential: store it in your secret manager, rotate it on cadence, and audit which Trefur operators can read it.

Choose your path

Trade-off summary. None of these mutually exclude each other — most production deployments run all three.

PathSetup effortLatencyWhat we seeUser attributionBest for
Admin API connectorAdmin API key (no OAuth)15 min poll cadenceMetadata only (no prompt/completion text)principal email via workspace_membersInventory + discovery — every key, every workspace, every member, daily cost
Anthropic API proxyAPI key + base_url swapReal-timeFull prompt + completion + tool callsX-Observe-Agent-Key header (or default key)Runtime visibility + PII redaction + cost attribution
SDK patch (in-process)pip install + one importReal-timeSame as proxy + framework chain contextResolved from the SDK's observe key configMulti-framework agents (LangChain, LlamaIndex, custom)

Path 1 — Admin API connector

The CISO mints an Anthropic Admin API key in the Console once and pastes it into Trefur. Every 15 minutes Trefur polls the 5 Admin API surfaces, records each Claude API key as an observed agent, attributes daily token + cost roll-ups to a principal email via the workspace_members map, and writes audit events (member.invited, api_key.created, api_key.rotated, etc.) into the activity record with canonical event types.

# 1. Mint an Admin API key in the Anthropic Console:
#    Settings → API Keys → "Create Key" → role: Admin
#    The key prefix will be sk-ant-admin01-...
#
# 2. Trefur stores the key in its AES-256-GCM credential vault.
#    Paste it under Settings → Integrations → Anthropic Admin.
#
# 3. The connector pulls 5 surfaces every 15 minutes:
#    GET /v1/organizations/{org_id}/audit_logs
#    GET /v1/organizations/{org_id}/usage_report/messages
#    GET /v1/organizations/{org_id}/workspaces
#    GET /v1/organizations/{org_id}/workspace_members
#    GET /v1/organizations/{org_id}/api_keys
#
# 4. Per call, we capture:
#    - workspace_id           -> tenant-scope inventory
#    - api_key_id + name      -> recorded as observed agents
#    - principal email        -> resolved via workspace_members
#    - daily token + cost     -> aggregate per (api_key, model, day)
#    - audit events           -> mapped to canonical event types
#                                (team_member_invited, agent_key_minted, etc.)

Requires an Anthropic Enterprise or Teams plan. The Admin API does not include prompt or completion text — Anthropic doesn't expose them at all. For per-call content scanning, layer the proxy or SDK path on top.

Path 2 — Anthropic API proxy (local collector)

Run the trefur collector and point your applications at its LLM proxy on http://localhost:9091. The path prefix /proxy/api.anthropic.com/… tells the collector which upstream to forward to, so it proxies every request to api.anthropic.com and captures the full prompt + completion. Streaming SSE calls are passed through chunk-by-chunk while we tee the content into the telemetry pipeline.

cURL

# Point your Claude-using application at the local collector's LLM proxy.
# The collector runs on http://localhost:9091 by default; the path prefix
# /proxy/<provider-host>/ tells it which upstream to forward to.
# (Change localhost:9091 to your collector's address if it runs elsewhere.)

# Drop-in swap for https://api.anthropic.com
curl http://localhost:9091/proxy/api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "X-Observe-Agent-Key: trf_obs_REPLACE_ME" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Summarize Q3 sales."}]
  }'

# Streaming (SSE) calls work the same way — chunks pass through while
# Trefur tees the content into the telemetry pipeline.

Drop-in SDK swap

# Python SDK — point base_url at the collector's LLM proxy:
import anthropic
client = anthropic.Anthropic(
    api_key="$ANTHROPIC_API_KEY",
    base_url="http://localhost:9091/proxy/api.anthropic.com",
)

# Node.js SDK:
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY!,
  baseURL: "http://localhost:9091/proxy/api.anthropic.com",
});

Path 3 — SDK patch (in-process)

The Trefur SDK monkey-patches anthropic (Python) or @anthropic-ai/sdk (Node) so calls go through Anthropic directly while telemetry is captured in-process. Same content visibility as the proxy, plus framework-level context like LangChain chain id, agent role, and tool — surfaced as trefur.tool.name attributes via the OpenTelemetry conventions.

# In-process SDK patching captures framework-level context
# (LangChain chain id, agent role, tool calls, etc.) on top of the raw
# request/response that the proxy already sees.
#
# pip install trefur-observe anthropic

import os
import anthropic
from trefur_observe import TrefurObserve, patch_anthropic

# Initialise the observe client once at startup.
observe = TrefurObserve.init(api_key=os.environ["TREFUR_API_KEY"])
# Patch the Anthropic SDK so every call is wrapped.
patch_anthropic(observe)

client = anthropic.Anthropic()
resp = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Summarize Q3 sales."}],
)

PII redaction is enabled by default

Both the proxy and the SDK paths route prompt and completion payloads through the collector's redaction pipeline before export. Built-in patterns cover email, SSN, credit card, IBAN, API keys, JWT, and phone numbers — replaced with typed placeholders ([EMAIL], [SSN], etc.). Configure the redaction level per credential, per observe key, or per tenant default in Settings → Security inside the app.

To install an SDK, see the Python or JavaScript SDK references. To run the collector LLM proxy, see collector inputs.