Anthropic Tokenizer Typescript
Description
[](https://npmjs.org/package/@anthropic-ai/tokenizer)
Installation
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open the source below and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
README
Anthropic TypeScript Tokenizer
[](https://npmjs.org/package/@anthropic-ai/tokenizer)
⚠️ This package can be used to count tokens for Anthropic's older models. As of the Claude 3 models, this algorithm is no longer accurate, but can be used as a very rough approximation. We suggest that you rely on `usage` in the response body wherever possible.
Installation
npm install --save @anthropic-ai/tokenizer
# or
yarn add @anthropic-ai/tokenizer
Usage
import { countTokens } from '@anthropic-ai/tokenizer';
function main() {
const text = 'hello world!';
const tokens = countTokens(text);
console.log(`'${text}' is ${tokens} tokens`);
}
main();
Status
This package is in beta. Its internals and interfaces are not stable and subject to change without a major semver bump; please reach out if you rely on any undocumented behavior.
We are keen for your feedback; please email us at [support@anthropic.com](mailto:support@anthropic.com) or open an issue with questions, bugs, or suggestions.
Requirements
The following runtimes are supported:
- Node.js version 12 or higher.
- Deno v1.28.0 or higher (experimental).
Use
import { countTokens } from "npm:@anthropic-ai/tokenizer".
If you are interested in other runtime environments, please open or upvote an issue on GitHub.
Related Skills
Agency Agents
A complete AI agency at your fingertips - From frontend wizards to Reddit community ninjas, from whimsy inject
AI Firecrawl
🔥 The API to search, scrape, and interact with the web for AI
AI Artifacts Builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web tech
AI CrewAI
Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewA
AI TrendRadar
⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的
AI mem0
| Universal memory layer for AI Agents | 51341 | 221 | 1 |
AI