Skip to main content

Your friendly token counting pal for OpenAI, Anthropic, and Google LLM models. Simple, accurate, fast.

Project description

token-count

A simple, practical Python package for counting tokens across OpenAI, Anthropic, and Google (Gemini) models using their official tokenizers and APIs.

Features

  • OpenAI: Local, offline token counting via tiktoken (official tokenizer)
  • Anthropic: Official messages.count_tokens API
  • Google (Gemini): Official models.countTokens via google-genai SDK
  • Provider-agnostic message format
  • Robust model name handling with fallbacks
  • Optional dependencies for each provider

Installation

# Basic installation (OpenAI support only)
pip install token-count

# With Anthropic support
pip install 'token-count[anthropic]'

# With Google support  
pip install 'token-count[google]'

# With all providers
pip install 'token-count[anthropic,google]'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tokenpal-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tokenpal-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file tokenpal-0.1.0.tar.gz.

File metadata

  • Download URL: tokenpal-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for tokenpal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4a3beabcec232ebb6b1ab22b322b92dba0768bb8ffc4c5b001ca87df1f4785b0
MD5 1febfc32680a701078570f72a70214f5
BLAKE2b-256 4c57fc9ffdaf98ebc5b26e9320e72d0fabf2997cf8a60eb0861daca645b45ec0

See more details on using hashes here.

File details

Details for the file tokenpal-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tokenpal-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for tokenpal-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b445352706d30524a21df38a1785803a90a3b98a7ca171d9019603b605a72cde
MD5 6ab2bd0707aa6702981aeb6e20ca83fd
BLAKE2b-256 79333b6bae36ddc6f841ca2a878360db68879ca0891a29e031d5246fb81f0085

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page