janekbaraniewski/openusage/openusage-provider
Claude Code and agent skill by janekbaraniewski/openusage
- community
Checking that the SKILL.md file is still in the repository.
Add new AI usage providers to the OpenUsage TUI dashboard.
Install
npx vskill@latest install janekbaraniewski/openusage/openusage-providerSKILL.md
OpenUsage Provider Skill
Invocation: When a user asks to add, create, or implement a new AI provider to OpenUsage.
You are implementing a new AI usage/quota provider for the OpenUsage TUI dashboard. This is a multi-step process. Follow every step precisely.
Phase 0 — Quiz the User (MANDATORY)
Before writing any code, you MUST gather all of the following information. Ask these questions conversationally but DO NOT proceed until every answer is obtained. If the user doesn't know an answer, research it yourself (check the provider's docs, API reference, etc).
Questions to ask:
- Provider name & ID
- What is the human-readable name? (e.g. "OpenAI", "DeepSeek", "Gemini CLI")
- What should the snake_case provider ID be? (e.g.
openai,deep_seek,gemini_cli)
- Authentication method — which of these applies?
api_key— user sets an env var likePROVIDER_API_KEY(most common for API providers)oauth— OAuth flow with stored credentials (e.g. Gemini CLI)cli— shells out to a CLI binary (e.g. GitHub Copilot viagh)local— reads local files/databases (e.g. Claude Code stats)token— extracted from local storage (e.g. Cursor IDE token from SQLite)
- If API key auth: What is the env var name? (e.g.
XAI_API_KEY)
- Data source — how do we get usage data?
- HTTP API with rate-limit headers (probe a lightweight endpoint like
/v1/models) - Dedicated usage/balance REST endpoint (e.g. DeepSeek
/user/balance) - Local files (stats JSON, session files, SQLite databases)
- CLI subprocess output
- Combination of the above
- What metrics are available? Try to identify:
- Rate limits: RPM, TPM, RPD, TPD (from headers or API)
- Spending: balance, credits, daily/weekly/monthly spend
- Usage: messages, tokens (input/output/reasoning), sessions, tool calls
- Account metadata: plan name, email, org, billing cycle
- API documentation URL — link to the provider's rate-limit or usage docs
- Base URL — the API base (e.g.
https://api.openai.com/v1)
- Probe model (if using header probing) — a cheap/default model to use for the probe request (e.g.
gpt-4.1-mini)
- Color role for the dashboard tile — pick one that doesn't conflict with existing providers:
green(OpenAI),peach(Anthropic),lavender(Cursor),blue(Gemini CLI)sky(DeepSeek),teal(xAI),yellow(Groq),sapphire(Mistral)rosewater(OpenRouter),maroon(Copilot),flamingo(Codex),auto(Claude Code)
- Does the provider support per-model usage breakdowns? (for the Analytics tab)
Phase 1 — Research
Before coding, look up the provider's API docs to understand:
- Exact HTTP endpoints, methods, headers
- Response JSON schemas
- Rate-limit header names and formats
- Any balance/credits/usage endpoints
- Authentication header format (
Bearer,x-api-key, etc.) - Error response codes and their meaning (401, 403, 429)
Document your findings in a brief summary before proceeding.
Phase 2 — Create the Provider Package
2.1 Directory structure
Create internal/providers/<provider_id>/ with these files:
2.2 Provider implementation (<provider_id>.go)
The provider MUST:
- Define a `Provider` struct that embeds
providerbase.Base:
- Implement a `New()` constructor that registers the
ProviderSpec:
- Implement the `Fetch()` method — this is the core data collection logic.
Key rules for Fetch():
- First param is
context.Context— pass it to all HTTP requests viahttp.NewRequestWithContext - Second param is
core.AccountConfig— useacct.ResolveAPIKey()for API key,acct.BaseURLfor custom base URL,acct.Binaryfor CLI path - Return
(core.UsageSnapshot, error) - For auth failures: return a valid snapshot with
Status: core.StatusAuthanderr == nil - For rate limiting: return snapshot with
Status: core.StatusLimitedanderr == nil - For fatal errors (network failure, bad request): return
(core.UsageSnapshot{}, err) - Always prefix error messages with provider name:
fmt.Errorf("<provider_id>: creating request: %w", err) - Initialize all maps:
Metrics: make(map[string]core.Metric),Resets: make(map[string]time.Time), etc.
Pattern A: HTTP header probing (simplest — for providers that expose rate-limit headers)
Pattern B: REST API + balance endpoint (like DeepSeek)
Split into helper methods: fetchBalance(), fetchRateLimits(), etc. Parse JSON responses into core.Metric entries. Use snap.SetAttribute("key", "value") for account metadata.
Pattern C: Local file readers (like Claude Code, Codex)
Read from known paths using acct.Binary or acct.ExtraData["config_dir"]. Parse JSON/SQLite data. Populate metrics from parsed data.
2.3 Metric keys — naming conventions
| Category | Key pattern | Unit | Window | Examples | |
|---|---|---|---|---|---|
| Rate limits | rpm, tpm, rpd, tpd | requests/tokens | 1m/1d | rpm, tpm | |
| Spending | total_cost_usd, today_api_cost, 7d_api_cost, monthly_spend | USD | current/today/7d/month | credit_balance | |
| Credits | credit_balance, credits, plan_spend | USD/credits | current | credit_balance | |
| Usage counts | messages_today, sessions_today, tool_calls_today | messages/sessions/calls | today | messages_today | |
| Token counts | tokens_today, input_tokens, output_tokens | tokens | varies | today_input_tokens | |
| Plan | plan_percent_used, spend_limit | %/USD | varies | plan_percent_used | |
| Per-model | model_<model_name>_<metric> | varies | varies | model_gpt4_cost |
2.4 Attribute keys — naming conventions
Use snap.SetAttribute() for metadata displayed in the details panel:
| Key | Description | Example value | |
|---|---|---|---|
account_email | Account email | user@example.com | |
account_name | Account/key name | My API Key | |
plan_name | Plan tier name | Pro, Free, Team | |
plan_type | Plan type | prepaid, postpaid | |
billing_cycle_start | Billing period start | 2025-01-01 | |
billing_cycle_end | Billing period end | 2025-02-01 | |
cli_version | Tool version | 1.2.3 | |
auth_type | How auth was resolved | api_key, oauth |
2.5 ModelUsage records (for Analytics tab)
If the provider returns per-model breakdowns, populate snap.ModelUsage:
2.6 DailySeries (for Analytics charts)
If the provider has historical daily data, populate snap.DailySeries:
Phase 3 — Dashboard Widget Configuration
3.1 When to use defaults vs custom widget
- Use defaults (via
providerbase.DefaultDashboard(providerbase.WithColorRole(...))) for simple header-probing providers with just RPM/TPM. - Create `widget.go` when the provider has rich metrics (credits, spending, activity, per-model data).
3.2 Custom widget (widget.go)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingdocs/skills/openusage-provider/SKILL.md
Popularity
- Repository stars
- 228
- Repository forks
- 29
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/janekbaraniewski/openusage/openusage-provider)