← All docs

Anthropic SDK

Wrap the Anthropic client. Every Claude message and tool-use block is captured.

Wrap the Anthropic SDK with Cisora to capture every Claude message, tool_use block, and computer-use action.

Install

npm install @cisora/sdk @anthropic-ai/sdk

Quickstart

import Anthropic from '@anthropic-ai/sdk';
import { wrapAnthropic } from '@cisora/sdk/anthropic';

const anthropic = wrapAnthropic(new Anthropic(), {
  apiKey: process.env.CISORA_API_KEY!,
  agentName: 'review-agent',
});

const msg = await anthropic.messages.create({
  model: 'claude-sonnet-4-5',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Summarize PR #42' }],
});

What gets captured

  • Model name and full message history
  • Response content (text blocks + tool_use blocks)
  • Input + output tokens with extended-thinking budget separated
  • tool_use blocks captured as nested actions in the same trace
  • Streaming aggregated and captured on stream close
  • Cache hit ratio when prompt caching is used

Notes

Prompt caching savings tracked

Cisora computes the cost delta from cached input tokens so you can prove ROI on prompt caching to your team.

AWS Bedrock + Vertex

For Bedrock or Vertex deployments of Claude, see the Bedrock guide — same SDK, slightly different setup.

Next steps

Alternative approach

Use the Gateway instead

Point your Anthropic client at the Cisora gateway. Same API, same streaming — enforcement happens in the request path, not optionally in the SDK.

import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  apiKey: process.env.CISORA_API_KEY!,   // your Cisora key
  baseURL: 'https://cisora.io/api/gateway/anthropic',
});

// Identical API — streaming, tool use, computer use all work
const msg = await client.messages.create({
  model: 'claude-opus-4-5',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Hello' }],
});
Gateway setup guide →