Anthropic with LangSpend

← Back to Home

Track Anthropic Claude API costs with zero-code attribution

Anthropic Claude Integration

Learn how to track Anthropic Claude API costs with LangSpend. Works with Claude-4.5 Opus, Sonnet, and Haiku models and all the other Anthropic models.

Installation

Install required packages

terminal

Basic Setup

Wrap your Anthropic client

anthropic.ts

Claude Messages

Claude 4 Opus Example with Customer & Feature Tracking

💡 Custom Metadata: Use the meta property in customer and feature objects to pass any custom properties for advanced tracking and analytics.

claude-chat.ts

Streaming Responses

Streaming Example with Tracking

claude-stream.ts