Skip to content
Back to skills

Anthropic Sdk Token Usage Logger

ASecurity

Instruments Anthropic API calls to log token usage, latency, and cost per request using the Anthropic TypeScript SDK. Wraps the anthropic.messages.create method to capture usage.input_tokens, usage.output_tokens, and timing from the API response. Writes structured logs to CloudWatch Logs via the AWS SDK v3 CloudWatchLogsClient.

  • 36 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added June 2, 2026
ai-agentstypescriptgonodeawsgitapisecuritydocumentation

Works with

  • claude code
  • cli
  • api

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned June 2, 2026

npx -y skills add agentskillexchange/skills --skill anthropic-sdk-token-usage-logger --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Anthropic Sdk Token Usage Logger?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Anthropic Sdk Token Usage Logger
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/agentskillexchange-anthropic-sdk-token-usage-logger/badge)](https://www.skillsdirectory.com/skills/agentskillexchange-anthropic-sdk-token-usage-logger)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: "Anthropic SDK Token Usage Logger"
slug: "anthropic-sdk-token-usage-logger"
description: "Instruments Anthropic API calls to log token usage, latency, and cost per request using the Anthropic TypeScript SDK. Wraps the anthropic.messages.create method to capture usage.input_tokens, usage.output_tokens, and timing from the API response. Writes structured logs to CloudWatch Logs via the AWS SDK v3 CloudWatchLogsClient."
github_stars: 1883
verification: "security_reviewed"
source: "https://github.com/anthropics/anthropic-sdk-typescript"
author: "Anthropic"
category: "Library & API Reference"
framework: "Claude Code"
tool_ecosystem:
  github_repo: "anthropics/anthropic-sdk-typescript"
  github_stars: 1883
  npm_package: "@anthropic-ai/sdk"
  npm_weekly_downloads: 14518427
---

# Anthropic SDK Token Usage Logger

Instruments Anthropic API calls to log token usage, latency, and cost per request using the Anthropic TypeScript SDK. Wraps the anthropic.messages.create method to capture usage.input_tokens, usage.output_tokens, and timing from the API response. Writes structured logs to CloudWatch Logs via the AWS SDK v3 CloudWatchLogsClient.

## Installation

Use the upstream install or setup path that matches your environment:
- npm install @anthropic-ai/sdk

Requirements and caveats from upstream:
- Node.js 18+

Basic usage or getting-started notes:
- sh
- js
- import Anthropic from '@anthropic-ai/sdk';

- Source: https://github.com/anthropics/anthropic-sdk-typescript
- Extracted from upstream docs: https://raw.githubusercontent.com/anthropics/anthropic-sdk-typescript/HEAD/README.md

## Documentation

- https://platform.claude.com/docs/en/api/sdks/typescript

## Source

- [Agent Skill Exchange](https://agentskillexchange.com/skills/anthropic-sdk-token-usage-logger/)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…