Skills Development OpenRouter Cost and Usage Tracker

OpenRouter Cost and Usage Tracker

v20261029
cost-openrouter
Query real OpenRouter spend via API: key limit and usage today/week/month, billed cost of a single generation by id, and account credits. Requires user confirmation before any network call; never exposes API keys.
Get Skill
111 downloads
Overview

Cost OpenRouter

Network skill. Ask the user before running it, and run it only with their yes.

node ${CLAUDE_PLUGIN_ROOT}/scripts/openrouter.mjs key --yes
node ${CLAUDE_PLUGIN_ROOT}/scripts/openrouter.mjs generation gen-abc123 --yes
node ${CLAUDE_PLUGIN_ROOT}/scripts/openrouter.mjs credits --yes

Rules

  • Without --yes the script prints the call it would make and sends nothing.
  • The key comes from OPENROUTER_API_KEY (credits: OPENROUTER_MANAGEMENT_KEY). A key the user stored as the plugin option openrouterApiKey arrives as OPENROUTER_API_KEY too: the plugin's SessionStart hook puts it there for this session's commands when the variable is not already set (ADR-506). Never ask the user to paste a key, never print, log or write one.
  • OpenRouter's usage.cost / total_cost is authoritative; do not recompute it from list prices.
  • credits needs a management key (a normal key returns 403). A fresh generation can 404 briefly: retry.
  • BYOK rows carry the 5% OpenRouter fee in usage, the provider's charge in upstream_inference_cost: show both, labelled.
  • Fallback and openrouter/auto can change the billed model: report model and provider_name as returned.
Info
Category Development
Name cost-openrouter
Version v20261029
Size 1.53KB
Updated At 2026-10-30
Language