This is a demonstration project that shows how to implement Claude's token counting functionality using the Anthropic API.
Note: This is for demonstration purposes only.
This project provides a simple web interface to count tokens using Claude's token counting API. It allows you to:
- Input text and see the token count in real-time
- View token counting history
- Support for both text input and file upload
- Install dependencies using pnpm:
pnpm install
- Set up environment variables:
# Copy the example environment file
cp .env.example .env
# Edit .env and add your Anthropic API key
- Run the development server:
pnpm dev
This project utilizes Anthropic's beta Token Counting API, which is documented in their official Token counting (beta) page. This beta API provides accurate token counting that matches Claude's internal tokenization process.