Skip to content

feat: OpenRouter provider integration — API key management, usage tracking, and account UI#740

Open
EnesDemir143 wants to merge 9 commits into
jlcodes99:mainfrom
EnesDemir143:feat/openrouter-integration
Open

feat: OpenRouter provider integration — API key management, usage tracking, and account UI#740
EnesDemir143 wants to merge 9 commits into
jlcodes99:mainfrom
EnesDemir143:feat/openrouter-integration

Conversation

@EnesDemir143
Copy link
Copy Markdown

Summary

Adds full OpenRouter provider integration to Cockpit Tools — manage your OpenRouter API keys, track usage/spending, and browse available models — all within the app.

Features

Core

  • API key management — Add, delete, refresh, tag, and inject OpenRouter API keys
  • Usage tracking — Fetches real-time usage data from /api/v1/key (total spent, daily/weekly/monthly breakdown, remaining credits)
  • Model browser — Browse 300+ available models from /api/v1/models with pricing and context info
  • Management key support — Check credits via /credits endpoint (management keys only)

UI

  • Accounts page with grid/list views, search, pagination, tag editing, privacy mode
  • Usage cards showing Total Usage, Daily/Weekly/Monthly spend breakdown (OpenCode-style quota layout)
  • Models tab with free/paid indicators, context length, pricing
  • Dashboard integration — OpenRouter account count shown in dashboard

Technical

  • Rust backend — 13 Tauri commands, HTTP client for OpenRouter API, encrypted key storage
  • TypeScript types — OpenRouterAccount, OpenRouterModel, helper functions
  • Zustand state store — useOpenrouterAccountStore using createProviderAccountStore factory
  • Full platform registration — Sidebar nav, routes, native macOS menu, i18n (en/zh-CN)

Testing

  • npm run typecheck ✅
  • cargo check ✅

- Define OpenRouterAccount interface with key_type, usage, limits
- Define OpenRouterModel, OpenRouterUsage, OpenRouterCreditsInfo
- Add helper functions: display email, plan badge, usage percent, credits
- Service layer with invoke wrappers for all Rust commands
- Zustand store using createProviderAccountStore factory
- Covers: CRUD, refresh, inject, credits, models, activity
- Add 'openrouter' to PlatformId, Page, ALL_PLATFORM_IDS, PLATFORM_PAGE_MAP
- Add OpenRouter icon component and SVG asset
- Add OpenRouterAccountsPage with accounts list, add/edit/delete, models tab
- Add route rendering, store import, and navigation entries
- Handle quota alerts and tray navigation
- Models: OpenRouterAccount, key types, credit info, model pricing
- Commands: list, add, delete, import/export, refresh, inject, credits, models
- Module: encrypted account CRUD, API key validation via /key endpoint
- Register all modules and wire up commands in lib.rs
- Add OpenRouter icon to macOS ProviderIconView.swift
- Register OpenRouter in tray module and tray_layout
- Add build_openrouter_display_info for tray display
- Add build_openrouter_cards for macOS native menu
- Add i18n keys for en.json and zh-CN.json (nav, tabs, usage, credits, models)
- Fix QuickSettingsType, ProviderCurrentPlatform, DashboardPage stats
- Add openrouter adapters to dataTransferService and accountTransferService
- Redesign quota section with OpenCode-style layout
- Add proper OpenRouter logo SVG icon
- Remove custom budget feature
- Clean up unused code
- Improve account card UI to match project patterns
- Replace placeholder SVG with actual OpenRouter brand PNG logo
- Update native macOS menu to use PNG instead of SVG
- Match Qoder's pattern for icon handling
Copy link
Copy Markdown
Author

@EnesDemir143 EnesDemir143 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be good. OpenRouter is very important now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants