Quickstart

Get running with The Token Company SDK in 2 minutes.

1. Install the SDK

pip install the-token-company

2. Get your API key

Token Company is currently invite-only. Get in touch and we'll set you up.

3. Compress your first prompt

from thetokencompany import TheTokenCompany

client = TheTokenCompany(api_key="ttc-...")

result = client.compress(
"Your long prompt text that needs compression for optimal token usage.",
aggressiveness=0.2,
)

print(f"Compressed: {result.output}")
print(f"Tokens saved: {result.tokens_saved}")
print(f"Compression ratio: {result.compression_ratio:.1f}x")

Response

result.output              # str: compressed text
result.output_tokens # int: tokens after compression
result.input_tokens # int: tokens before compression
result.tokens_saved # int: tokens removed
result.compression_ratio # float: e.g. 3.2x
outputstrrequired
The compressed text, ready to send to any LLM.
output_tokensintrequired
Token count after compression.
input_tokensintrequired
Token count of the original input.
tokens_savedintrequired
Number of tokens removed.
compression_ratiofloatrequired
Ratio of original to compressed tokens (e.g. 3.2x).

Async support

from thetokencompany import AsyncTheTokenCompany

async with AsyncTheTokenCompany(api_key="ttc-...") as client:
result = await client.compress("Your text here...")
print(result.output)

Next steps