Add new AI usage providers to the OpenUsage TUI dashboard.
Installation
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Add new AI usage providers to the OpenUsage TUI dashboard.
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 like PROVIDER_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 via gh)
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)
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.
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)
package <provider_id>
import"github.com/janekbaraniewski/openusage/internal/core"funcdashboardWidget() core.DashboardWidget {
cfg := core.DefaultDashboardWidget()
cfg.ColorRole = core.DashboardColorRole<Color>
// Gauge priority — which metrics show as gauge bars in the tile (need Limit+Remaining or Limit+Used)
cfg.GaugePriority = []string{
"credit_balance", "spend_limit", "rpm", "tpm",
}
cfg.GaugeMaxLines = 2// Compact rows — summary pills shown in the tile (2-3 rows, 3-5 segments each)
cfg.CompactRows = []core.DashboardCompactRow{
{Label: "Credits", Keys: []string{"credit_balance", "plan_spend", "monthly_spend"}, MaxSegments: 4},
{Label: "Usage", Keys: []string{"rpm", "tpm", "rpd", "tpd"}, MaxSegments: 4},
{Label: "Activity", Keys: []string{"messages_today", "sessions_today", "requests_today"}, MaxSegments: 4},
}
// Metric label overrides for the detail panel
cfg.MetricLabelOverrides["custom_metric"] = "Custom Metric Label"// Compact label overrides for tile pills (keep very short: 3-6 chars)
cfg.CompactMetricLabelOverrides["custom_metric"] = "short"// Hide noisy metrics from the tile
cfg.HideMetricPrefixes = append(cfg.HideMetricPrefixes, "model_")
cfg.SuppressZeroMetricKeys = []string{"some_usually_zero_metric"}
// Raw groups — metadata sections in the detail panel
cfg.RawGroups = append(cfg.RawGroups, core.DashboardRawGroup{
Label: "API Key Info",
Keys: []string{"key_name", "key_type", "expires_at"},
})
return cfg
}
3.3 Widget design principles
Gauges: Only metrics with both Limit and Remaining (or Limit and Used) render as gauge bars. Put the most meaningful resource-constraint metric first in GaugePriority.
Compact rows: The tile shows 2-3 rows of compact pills. Design rows covering Credits/Spending, Rate Limits/Usage, and Activity/Tokens.
Color: Choose a color role that doesn't clash with neighboring providers (see the map in Phase 0 Q9).
Detail panel: The default sections (Usage, Spending, Tokens, Activity) work for most providers. Customize DetailWidget.Sections only if the provider has a unique data layout.
Phase 4 — Register the Provider
4.1 Add to registry
Edit internal/providers/registry.go — import the new package and add <provider_id>.New() to the AllProviders() slice.
4.2 Add auto-detection (if applicable)
For API key providers
Edit internal/detect/detect.go — add to the envKeyMapping slice:
Add a detect<ProviderName>(result *Result) function that uses findBinary(), checks config dirs, and calls addAccount(). Then call it from AutoDetect().
4.3 Add example config
Update configs/example_settings.json — add an account entry to the accounts array: