Track costs and monitor usage for Anthropic’s Claude API by routing your requests through LLM Ops. This guide shows you how to integrate using Python, JavaScript, or cURL.
Security Guarantee: LLM Ops does not store your API keys, request prompts, or response content in the analytics database—only metadata needed for cost analytics. The proxy must forward request bodies to Anthropic to complete the call; optional operational logging may exist in your deployment environment.
Point the Anthropic SDK at the LLM Ops API host (do not append /v1—the SDK adds /v1/messages itself). For raw HTTP (cURL), use the full path https://api.llm-ops.cloudidr.com/v1/messages.
Original API host:https://api.anthropic.com
LLM Ops API host (SDK base_url / baseURL):https://api.llm-ops.cloudidr.com
from anthropic import Anthropic# Initialize client with LLM Ops proxy (no /v1 — SDK appends /v1/messages)client = Anthropic( api_key="sk-ant-...", # Your Anthropic API key base_url="https://api.llm-ops.cloudidr.com", default_headers={ "X-Cloudidr-Key": "trk_..." # Required for cost tracking })# Make API call - costs are automatically trackedmessage = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[ {"role": "user", "content": "What is the capital of France?"} ])print(message.content[0].text)
from anthropic import Anthropicclient = Anthropic( api_key="sk-ant-...", base_url="https://api.llm-ops.cloudidr.com", default_headers={ "X-Cloudidr-Key": "trk_...", "X-Agent": "streaming-bot" })# Streaming is fully supportedwith client.messages.stream( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[ {"role": "user", "content": "Write a short poem about AI"} ]) as stream: for text in stream.text_stream: print(text, end="", flush=True)
import Anthropic from '@anthropic-ai/sdk';// Initialize client with LLM Ops proxy (no /v1 — SDK appends /v1/messages)const client = new Anthropic({ apiKey: 'sk-ant-...', // Your Anthropic API key baseURL: 'https://api.llm-ops.cloudidr.com', defaultHeaders: { 'X-Cloudidr-Key': 'trk_...' // Required for cost tracking }});// Make API call - costs are automatically trackedconst message = await client.messages.create({ model: 'claude-sonnet-4-20250514', max_tokens: 1024, messages: [ { role: 'user', content: 'What is the capital of France?' } ]});console.log(message.content[0].text);