Anthropic Node.js
Official Anthropic SDK for Node.js and TypeScript
TypeScripteasy
The Anthropic Node.js SDK provides access to Claude models. Decyra's proxy captures all Anthropic API calls, enabling observability and control over your Claude interactions.
Prerequisites
- Decyra account with API key
- Node.js 18+ installed
- @anthropic-ai/sdk package installed
Installation
npm install @anthropic-ai/sdk @decyra/sdk
Integration
Wrap the fetch function to route through Decyra:
import Anthropic from '@anthropic-ai/sdk';
import { wrapFetch } from '@decyra/sdk';
const customFetch = wrapFetch(fetch, {
baseURL: 'https://proxy.decyra.com',
apiKey: process.env.DECYRA_API_KEY!,
});
const anthropic = new Anthropic({
apiKey: process.env.DECYRA_API_KEY!,
fetch: customFetch,
});
Use the client for messages:
const message = await anthropic.messages.create({
model: 'claude-3-opus-20240229',
max_tokens: 1024,
messages: [
{ role: 'user', content: 'Explain the theory of relativity' }
],
});
console.log(message.content[0].text);
What Gets Captured
| Field | Description |
|---|---|
| Model | Claude model identifier |
| Max Tokens | Maximum tokens in response |
| Messages | Array of conversation messages |
| Prompt Hash | Hash of the input prompt |
| Response Time | Time for API call |
| Token Usage | Input/output token counts |
| Cost | Estimated cost per request |
| Stop Sequences | Stop sequence configuration |
Verify
Check your Decyra dashboard to see Anthropic API calls in the traces view. Each message creation will appear with full details.