Registry /
llm-agents / openai-messages-token-helper
Install & Compatibility
Where this runs
tested against v0.1.13 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 77.8MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 7.8s · import 0.000s · 78MB
77MB installed
● package 77MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
build_messages
✓ from openai_messages_token_helper import build_messages
✗ from openai_messages_token_helper import messages_to_tokens
count_tokens_for_message
✓ from openai_messages_token_helper import count_tokens_for_message
get_token_limit
✓ from openai_messages_token_helper import get_token_limit
Quick estimate tokens for a list of messages.
import os
from openai import AzureOpenAI
from openai_messages_token_helper import messages_to_tokens
client = AzureOpenAI(
api_key=os.environ.get('AZURE_OPENAI_KEY', ''),
api_version="2024-02-01",
azure_endpoint=os.environ.get('AZURE_OPENAI_ENDPOINT', '')
)
system_message = "You are a helpful assistant."
user_message = "Hello!"
tokens = messages_to_tokens([
{"role": "system", "content": system_message},
{"role": "user", "content": user_message}
], model="gpt-4")
print(f"Token count: {tokens}")
Upgrade
Version history
0.1.13latest on PyPI · released Dec 29, 2025
Audit
Dependencies
No dependency data recorded yet.