No description
Find a file
Beck da41aed234 feat(openrouter): realtime analytics source with today's data and key names
Replace the activity endpoint with POST /api/v1/analytics/query, which
returns today's partial-day data, a model dimension, and api_key_id key
names. Fixes: today missing from 7d/30d views, models like Luna dropped
from the cost chart (lower COST_THRESHOLD to $0.01), and API Keys view
showing 'unknown'.

Also fixes the 30d window truncation (endpoint honors time_range not
timeRange) and renders empty days in the chart, and spreads the OpenRouter/
Anthropic chart palettes so stacked segments are visually distinct.
2026-08-15 17:36:56 +01:00
.github/workflows fix yaml 2025-11-08 22:40:30 -08:00
src feat(openrouter): realtime analytics source with today's data and key names 2026-08-15 17:36:56 +01:00
.gitignore for cost chart, add threshold of $1 per day to reduce noise 2025-11-10 12:09:01 -08:00
Cargo.lock chore: release v0.1.5 2025-12-07 22:11:06 +00:00
Cargo.toml chore: release v0.1.5 2025-12-07 22:11:06 +00:00
CHANGELOG.md feat(openrouter): realtime analytics source with today's data and key names 2026-08-15 17:36:56 +01:00
LICENSE Initial commit 2025-11-06 15:17:38 -08:00
README.md feat(openrouter): realtime analytics source with today's data and key names 2026-08-15 17:36:56 +01:00
release-plz.toml release-plz workflow 2025-11-08 22:39:07 -08:00

   __                __          __                         
  |  \              |  \        |  \                        
 _| $$_     ______  | $$   __  _| $$_     ______    ______  
|   $$ \   /      \ | $$  /  \|   $$ \   /      \  /      \ 
 \$$$$$$  |  $$$$$$\| $$_/  $$ \$$$$$$  |  $$$$$$\|  $$$$$$\
  | $$ __ | $$  | $$| $$   $$   | $$ __ | $$  | $$| $$  | $$
  | $$|  \| $$__/ $$| $$$$$$\   | $$|  \| $$__/ $$| $$__/ $$
   \$$  $$ \$$    $$| $$  \$$\   \$$  $$ \$$    $$| $$    $$
    \$$$$   \$$$$$$  \$$   \$$    \$$$$   \$$$$$$ | $$$$$$$ 
                                                  | $$      
                                                  | $$      
                                                   \$$      

htop but for llm tokens

License: MIT Built With Ratatui

Made with VHS

toktop is a terminal-based dashboard for OpenAI, Anthropic and OpenRouter token usage and costs. It allows user (admin of their openai, anthropic and openrouter accounts) to monitor their usage inside terminal without constantly jumping into different websites.

Installation

cargo install toktop --locked

Usage

# 1. Set Environment Variables
export OPENAI_ADMIN_KEY="your-openai-key"
export ANTHROPIC_ADMIN_KEY="your-anthropic-key"
export OPENROUTER_API_KEY="your-openrouter-key"
toktop

# 2. Use env file
toktop -e .env

# 3. Don't set env var, toktop will prompt for api key
toktop

Hotkeys

  • ←/→ - Switch between options columns (Provider, Metrics, Date Range, Group By)
  • ↑/↓ - Choosing options
  • h/l - Scrolling charts if scroll bar is present
  • r - Refresh data
  • q - Quit the application

API Keys

OPENAI

It requires $OPENAI_ADMIN_KEY from https://platform.openai.com/settings/organization/admin-keys with READ permission to Management API Scope and Usage API Scope.

It tracks two data:

  1. Cost: GET /v1/organization/costs
  2. Usage:
    • GET v1/organization/usage/completions
    • GET v1/organization/usage/embeddings
    • GET v1/organization/usage/images

To group by API Keys, it also needs read access to the following endpoint:

  1. Get project ids: GET v1/organization/projects
  2. Get api key names from projects: GET v1/organization/projects/{project_id}/api_keys

ANTHROPIC

It requires $ANTHROPIC_ADMIN_KEY from https://console.anthropic.com/settings/admin-keys.

It tracks two data:

  1. Cost: GET /v1/organizations/cost_report
  2. Usage: GET /v1/organizations/usage_report/messages

OPENROUTER

It requires $OPENROUTER_API_KEY, which must be an API Management key (not a regular API key), from https://openrouter.ai/settings/management-keys. Regular sk-or-v1-... keys cannot access the analytics endpoint this tool uses. Management keys are for administrative operations only (they cannot make inference requests), and can be scoped to read-only access.

It tracks two data from a single endpoint:

  1. Cost: POST /api/v1/analytics/query (per-day USD cost, grouped by model and API key)
  2. Usage: POST /api/v1/analytics/query (per-day prompt/completion/reasoning tokens and request counts, grouped by model and API key)

OpenRouter usage comes from POST /api/v1/analytics/query, which returns per-day cost, prompt/completion/reasoning tokens, and request counts grouped by model and API key, including the current day.

Others

I would love to track my other LLM spends from Gemini and Cursor as well. Unfortunately, Cursor Admin API requires enterprise plan, which I don't have at the moment. Gemini does not seem to expose usage/cost in API in the same manner.