Tokoscope wraps your existing LLM client in two lines and gives you full token visibility, automatic compression, semantic caching, and cost attribution — with zero infrastructure changes.
The fastest way to get started:
// 1. Install // npm install tokoscope // 2. Wrap your client import OpenAI from 'openai' import { wrap } from 'tokoscope' const client = wrap(new OpenAI(), { apiKey: 'ts_live_...' }) // 3. Use exactly as before const res = await client.chat.completions.create({ model: 'gpt-4o', messages: [{ role: 'user', content: 'Hello' }] })
That's it. Every API call is now tracked automatically. Visit your dashboard to see live data.
npm install tokoscope # or yarn add tokoscope
pip install tokoscope
Get your API key from app.tokoscope.com/settings. It starts with ts_live_.
Store it as an environment variable — never hardcode it in your source:
TOKOSCOPE_API_KEY=ts_live_...
const client = wrap(new OpenAI(), { apiKey: process.env.TOKOSCOPE_API_KEY })
import OpenAI from 'openai' import { wrap } from 'tokoscope' const client = wrap(new OpenAI(), { apiKey: process.env.TOKOSCOPE_API_KEY, userId: 'user_123' // optional }) const res = await client.chat.completions.create({ model: 'gpt-4o', messages: [{ role: 'user', content: 'Hello' }] })
import Anthropic from '@anthropic-ai/sdk' import { wrap } from 'tokoscope' const client = wrap(new Anthropic(), { apiKey: process.env.TOKOSCOPE_API_KEY }) const res = await client.messages.create({ model: 'claude-sonnet-4-6', max_tokens: 1024, messages: [{ role: 'user', content: 'Hello' }] })
import { GoogleGenerativeAI } from '@google/generative-ai' import { wrap } from 'tokoscope' const genAI = wrap(new GoogleGenerativeAI(process.env.GEMINI_KEY), { apiKey: process.env.TOKOSCOPE_API_KEY }) const model = genAI.getGenerativeModel({ model: 'gemini-2.5-flash' }) const result = await model.generateContent('Hello')
Pass a userId to attribute token usage to individual end users of your app. Users appear in the Users tab with individual token usage, cost, and waste scores.
const client = wrap(new OpenAI(), { apiKey: process.env.TOKOSCOPE_API_KEY, userId: currentUser.id // any string identifier })
Tokoscope automatically caches responses using two layers:
Cache TTL is 7 days. Clear cache anytime from Settings.
⚡ Tokoscope cache hit [semantic (89.3% match)] — saved 93 tokens ($0.000049)
Prompts with a waste score above 30% are automatically compressed before being tracked. The compressed version is stored alongside the original and visible in the Prompts tab.
Compression uses Claude Haiku and typically reduces prompt length by 40–90% without changing model behavior.
Streaming responses are supported for OpenAI. Set stream: true (or stream=True in Python) as usual — Tokoscope passes every chunk through unchanged and tracks token usage once the stream completes.
const stream = await client.chat.completions.create({ model: 'gpt-4o', messages: [{ role: 'user', content: 'Hello' }], stream: true }) for await (const chunk of stream) { process.stdout.write(chunk.choices[0]?.delta?.content || '') } // Tracking fires automatically once the stream ends
Set a monthly spend threshold in Settings. When your spend crosses the threshold, Tokoscope sends an email alert automatically. Alerts fire once per calendar month.
| Option | Type | Required | Description |
|---|---|---|---|
| apiKey | string | Yes | Your Tokoscope API key from Settings |
| userId | string | No | End-user ID for per-user attribution |
Python uses snake_case: api_key and user_id.
| Provider | Model | Input (per 1K tokens) | Output (per 1K tokens) |
|---|---|---|---|
| openai | gpt-4o | $0.005 | $0.015 |
| openai | gpt-4o-mini | $0.00015 | $0.0006 |
| openai | gpt-4-turbo | $0.01 | $0.03 |
| anthropic | claude-opus-4-6 | $0.015 | $0.075 |
| anthropic | claude-sonnet-4-6 | $0.003 | $0.015 |
| anthropic | claude-haiku-4-5 | $0.00025 | $0.00125 |
| gemini | gemini-2.5-flash | $0.0001 | $0.0004 |
| gemini | gemini-2.5-pro | $0.00125 | $0.01 |
| gemini | gemini-1.5-flash | $0.000075 | $0.0003 |
| gemini | gemini-1.5-pro | $0.00125 | $0.005 |
The Tokoscope VS Code extension lets you see token counts, waste scores, and cost estimates for any LLM prompt directly in your editor — without leaving VS Code.
# 1. Open Command Palette Cmd+Shift+P (Mac) / Ctrl+Shift+P (Windows) # 2. Run Tokoscope: Set API Key # 3. Paste your key from app.tokoscope.com/settings ts_live_...
Tokoscope is available as a VS Code extension. See token counts, waste scores, and cost estimates for any prompt or file — without leaving your editor.
Tokoscope in the VS Code Extensions panel, or install from the marketplace:1. Cmd+Shift+P → Tokoscope: Set API Key 2. Enter your key from app.tokoscope.com/settings 3. Done — token counts appear in the status bar
| Command | Description |
|---|---|
| Tokoscope: Analyze Current File | Full file analysis with waste score and suggestions |
| Tokoscope: Analyze Selected Text | Analyze highlighted text only |
| Tokoscope: Set API Key | Save your Tokoscope API key |
| Tokoscope: Open Dashboard | Open app.tokoscope.com/dashboard |