openrouter-usage-analytics
Skill by jeremylongshore
Tracks OpenRouter API usage, cost, and latency, and stores the metrics in a local sqlite database. Built for developers who build usage dashboards, optimize spend, or report on AI usage.
Install openrouter-usage-analytics
Built from the published package, never by AI.
git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace /tmp/tons-of-skills-marketplace && mkdir -p ~/.claude/skills && cp -r /tmp/tons-of-skills-marketplace/skills/.curated/openrouter-usage-analytics ~/.claude/skills/openrouter-usage-analyticsRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
Step-by-step: install openrouter-usage-analytics in Claude Code
git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace /tmp/tons-of-skills-marketplace && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/tons-of-skills-marketplace/skills/.curated/openrouter-usage-analytics ~/.gemini/antigravity-cli/skills/openrouter-usage-analyticsAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install openrouter-usage-analytics in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
The openrouter-usage-analytics skill tracks OpenRouter API usage, cost, and latency for AI applications. Its tracked_completion function times each completion, fetches the exact total_cost from the OpenRouter generation endpoint, and logs the result as JSON. Metrics are saved to a local sqlite database with indexes, which supports queries for daily cost, cost by model, top users by spend, hourly request patterns, and a 30-day cost trend.
The skill also checks remaining credits through the auth key endpoint using curl and jq. It can generate a weekly text report with totals and the top five models by cost. The enterprise notes cover retention, aggregating raw rows after 30 days, and alerts when daily cost exceeds twice the historical average. It is aimed at developers building spend dashboards and teams reporting on AI usage.
Written from the project's SKILL.md and checked against it.
What it can do
- tracked_completionMakes a completion call and captures timing, tokens, exact cost, and model used.
- init_analytics_dbCreates the openrouter_analytics.db sqlite metrics table with indexes.
- store_metricSaves each metric and ignores duplicate generation IDs.
- Analytics queriesProvides SQL for daily cost, cost by model, top users, hourly pattern, and 30-day trend.
- Credit balance monitoringReports credits used, credit limit, and remaining credits with curl and jq.
- weekly_reportBuilds a text report with request count, total cost, latency, tokens, and top models.
What you need
- OpenRouter API key exported as OPENROUTER_API_KEY
- Python 3.8+ with the OpenAI SDK and requests
- sqlite3 (Python standard library)
- curl and jq for the credit balance snippet
Try asking
- Track the cost and latency of this completion call with tracked_completion
- Show me the cost by model for the last 7 days from my analytics database
- Generate my weekly OpenRouter usage report with the top 5 models by cost
Good to know
- If the generation endpoint fetch fails, the cost is recorded as 0.0.
- The daily_burn_rate field in the credit snippet is a placeholder that points to the analytics database.
- The 30-day aggregation and 2x cost alert are recommendations in the enterprise notes, not built-in features.
Security check
B- Allowed to use Write, Edit without limitsIn
SKILL.md
Checked automatically: skills/.curated/openrouter-usage-analytics/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
Allowed tools: ReadWriteEditGrepBash(python3:*)Bash(curl:*)Bash(jq:*)
Alternatives to openrouter-usage-analytics
All alternatives →Guides an assistant through the Kaggle CLI, covering competitions, datasets, notebooks, models, benchmarks, authentication and quota. It is for people who use the kaggle command-line tool.
Generates Python code that uses BigQuery DataFrames (BigFrames) for data processing, analysis and machine learning on BigQuery. It is meant for Python data tasks, and the source says to use bigquery-basics for SQL-first workflows.
Discovers connected data sources and proposes loading options when a workspace lacks the data a question needs. Suited to users who want to connect database, warehouse or cloud sources from the chat.
Guides developers through enabling the Data Manager API, setting up Application Default Credentials, and installing its client libraries. Built for developers who are getting started with the API and need local environment and access setup.
Guides authoring and validating Apache Airflow DAGs for Managed Service for Apache Airflow (MSAA), formerly Cloud Composer. Built for developers who create or extend Airflow DAGs in these environments.
Extracts structured JSON data from over 40 websites, including Amazon, LinkedIn, Instagram, TikTok, Facebook and YouTube. Built on Bright Data's Web Data APIs, it returns product details, profiles, reviews, posts and comments from a URL.
Compare with kaggle-cli, bigquery-bigframes or data-loading
openrouter-usage-analytics: common questions
How is the cost of each request measured?
The skill fetches the total_cost from the OpenRouter generation endpoint for each request. The source says not to estimate cost from token counts.
Are duplicate metrics stored twice?
The generation_id column is unique and inserts use INSERT OR IGNORE, so retried requests do not create duplicate rows.
Where is the usage data stored?
Metrics are stored in a local sqlite file named openrouter_analytics.db.
How do I install openrouter-usage-analytics?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is openrouter-usage-analytics free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is openrouter-usage-analytics safe to use?
It scores 76 of 100. Grades: maintenance A, licence A, quality A. Security check: grade B (allowed to use write, edit without limits). Review the code before you install. How grades work.
What are alternatives to openrouter-usage-analytics?
Similar skills: kaggle-cli, bigquery-bigframes, data-loading, data-manager-api-setup.
