anthropicsdktokenusagelogger

Instrument Anthropic API calls using the Anthropic TypeScript SDK to log per-request token usage, latency, and cost. Wrap anthropic.messages.create to capture usage.input_tokens, usage.output_tokens, and timing information from responses, and write structured logs to AWS CloudWatch Logs using the AWS SDK v3 CloudWatchLogsClient.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "anthropicsdktokenusagelogger" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-1e11598aa584dbb73e1d9c48504c862b3005dc170031a3785c10766fc14a5556. Verify the upstream source and version against https://skillhub.cn/skills/user_3c6cb52e/anthropic-sdk-token-usage-logger before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Instrument Anthropic API calls using the Anthropic TypeScript SDK to log per-request token usage, latency, and cost. Wrap anthropic.messages.create to capture usage.input_tokens, usage.output_tokens, and timing information from responses, and write structured logs to AWS CloudWatch Logs using the AWS SDK v3 CloudWatchLogsClient.

0 Downloads

Introduction source: third_party · user_3c6cb52e · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: "Anthropic SDK Token Usage Logger"
slug: "anthropic-sdk-token-usage-logger"
version: "1.0.0"
displayName: "Anthropic SDK Token Usage Logger"
summary: "使用Anthropic TypeScript SDK对Anthropic API调用进行instrumentation,以记录每个请求的token使用量、延迟和成本。封装anthropic.messages.create方法以捕获API响应中的usage.input_tokens、usage.output_tokens和时间信息。通过AWS SDK v3 CloudWatchLogsClient将结构化日志写入CloudWatch Logs。"
license: "MIT"
description: "使用Anthropic TypeScript SDK对Anthropic API调用进行instrumentation,以记录每个请求的token使用量、延迟和成本。封装anthropic.messages.create方法以捕获API响应中的usage.input_tokens、usage.output_tokens和时间信息。通过AWS SDK v3 CloudWatchLogsClient将结构化日志写入CloudWatch Logs。"
github_stars: 1883
verification: "security_reviewed"
source: "https://github.com/1991513ccie-png/skills"
author: "1991513ccie-png"
category: "Library & API Reference"
framework: "Claude Code"
tool_ecosystem:
  github_repo: "1991513ccie-png/skills"
  github_stars: 1883
  npm_package: "@anthropic-ai/sdk"
  npm_weekly_downloads: 14518427

Anthropic SDK Token Usage Logger

使用Anthropic TypeScript SDK对Anthropic API调用进行instrumentation,以记录每个请求的token使用量、延迟和成本。封装anthropic.messages.create方法以捕获API响应中的usage.input_tokens、usage.output_tokens和时间信息。通过AWS SDK v3 CloudWatchLogsClient将结构化日志写入CloudWatch Logs。

安装

使用与您的环境匹配的上游安装或设置路径:

  • npm install @anthropic-ai/sdk

上游的要求和注意事项:

  • Node.js 18+

基本用法或入门说明:

文档

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

  • 解决API调用成本监控的实际痛点
  • 面向开发者群体的实用工具
  • 具有明确的使用场景和受众
Trigger Precision85/100

Highlights

  • 功能描述完整准确
  • 触发词覆盖合理,边界清晰
Structure and Standards65/100

Areas to improve

  • 缺少详细使用示例 Reported severity: Minor

    文档中缺少具体的代码示例和使用步骤说明

    Recommendation: 添加详细的代码示例,展示如何初始化和使用token usage logger

  • 缺少步骤划分 Reported severity: Minor

    文档结构较为简单,缺少清晰的步骤划分和Phase说明

    Recommendation: 按照安装、配置、使用等步骤重新组织文档结构

Highlights

  • frontmatter完整规范
  • 基本结构清晰
Execution Reliability60/100

Areas to improve

  • 缺少AWS凭证配置说明 Reported severity: Major

    使用CloudWatch Logs需要AWS凭证配置,但文档中未提及

    Recommendation: 添加AWS凭证配置说明,包括环境变量设置或IAM角色配置

  • 缺少异常处理机制说明 Reported severity: Major

    未说明网络错误、API限流等异常情况的处理方式

    Recommendation: 添加异常处理说明和重试机制配置

Highlights

  • 工具来源明确
  • 基本参数说明正确
Evidence Verifiability (mean of the first four)71/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

  • Install or fetch external dependencies

    Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.

    Mentioned in main document · lines 29
Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • github.com
  • platform.claude.com
  • raw.githubusercontent.com

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.