# The Token Company — instructions for AI agents

> Prompt compression API. Removes low-signal tokens from LLM inputs before they reach the model, cutting token cost and latency without changing the answer.

Base URL: `https://api.thetokencompany.com`
OpenAPI: [https://thetokencompany.com/openapi.json](https://thetokencompany.com/openapi.json)
Docs: [https://thetokencompany.com/docs](https://thetokencompany.com/docs)

## When to use this

Reach for The Token Company when you are about to send a long, low-density prompt to an LLM and you are paying per token:

- **Long context you did not write.** Web pages you scraped, PDFs and reports you extracted, search results, retrieved RAG chunks. These are mostly boilerplate; compression typically removes 10-50% with no measurable accuracy loss.
- **Conversation history you resend every turn.** Agent scratchpads, chat histories, tool-call transcripts — compress the history block before you resend it.
- **Meeting transcripts and call recordings.** Verbatim speech is the highest-redundancy text there is.
- **You are hitting a context window limit.** Compression fits more source material into the same window rather than making you truncate or chunk.
- **Time-to-first-token matters.** A shorter prompt reaches first token faster; at 50% reduction that has measured up to 49% faster TTFT across nine frontier models.

## When not to use this

- **Code you intend to execute or edit.** Compressed code is still readable for understanding a repository, but it is no longer compilable. Never put it in an edit-and-run loop.
- **Strictly structured payloads.** JSON schemas, SQL, config files. Use `protect_json`, or leave them out of the compressed span.
- **Short prompts.** Under a few hundred tokens the round trip costs more than it saves.
- **Content that must survive character-exact.** Wrap it in `<ttc_safe>` tags so compression skips it.

## How to call it

Compress one input, then send the result to whatever LLM you were going to use anyway:

```bash
curl -X POST https://api.thetokencompany.com/v1/compress \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TTC_API_KEY" \
  -d '{
    "model": "bear-2",
    "input": "Your long text to compress goes here...",
    "compression_settings": {"aggressiveness": 0.1}
  }'
```

The response carries `output` (the compressed text), `output_tokens`, and `original_input_tokens`.

Choosing `aggressiveness`: use **0.05-0.2** for text the model must answer questions about, and **0.5-0.8** for background context and history where exact wording matters less. Start low and raise it while watching your eval.

## Operations available

| Operation | Method and path | Use it for |
|---|---|---|
| `compressText` | `POST /v1/compress` | One string, document, or JSON blob |

Request fields: `model` (required), `input` (required), `compression_settings.aggressiveness`, and `app_id` for per-application usage tracking. The response carries `output`, `output_tokens`, and `original_input_tokens`.

Full typed schemas are in the [OpenAPI 3.1 document](https://thetokencompany.com/openapi.json). The Python and TypeScript SDKs wrap this endpoint and add convenience fields of their own — see the [quickstart](https://thetokencompany.com/docs/quickstart).

## Authentication

`Authorization: Bearer ttc-...`. Keys are issued per team — request one at [https://thetokencompany.com/contact](https://thetokencompany.com/contact).

## Guarantees worth knowing

- **Deterministic.** The same input and settings always produce the same output, so prompt caches stay valid.
- **Delete-only.** Nothing is summarized, paraphrased, or generated. No new information is ever introduced.
- **Fails open.** If compression is unavailable the API returns your original input unchanged with an `error` field set, so a failure never breaks the calling flow.

## SDKs

- Python: `pip install the-token-company`
- TypeScript: `npm install the-token-company`

## More

- [llms.txt](https://thetokencompany.com/llms.txt) — site index for LLMs
- [llms-full.txt](https://thetokencompany.com/llms-full.txt) — long form, with models, pricing, and benchmarks
- [Full documentation as plain text](https://thetokencompany.com/docs/llms.txt)
- [Data retention](https://thetokencompany.com/docs/data-retention) — zero-data-retention option
