A comprehensive web-based dashboard for monitoring and managing API keys across multiple providers (OpenAI, Anthropic, Brave Search) with real-time usage tracking, cost analysis, and multi-account organization.
- Account Organization: Group API keys by email/organization
- Hierarchical Structure: Organize keys within accounts for better management
- Account Metadata: Track names, organizations, and contact information
- Multi-Provider Support: OpenAI, Anthropic, and Brave Search APIs
- Key Type Detection: Automatically detect admin vs project keys
- Secure Storage: SQLite database with masked key display
- Key Associations: Link project keys to admin keys for better organization
- Live Usage Data: Fetch real usage statistics from OpenAI's Usage API
- Cost Tracking: Monitor spending across all your API keys
- Token Analytics: Track input/output token consumption
- Request Metrics: Monitor API call frequency and patterns
- Masked Display: API keys are masked in the interface by default
- Secure Storage: Full keys stored securely in local SQLite database
- Copy Protection: Show/hide functionality with secure copying
- Local Deployment: All data stays on your machine
- Responsive Design: Works on desktop, tablet, and mobile
- Tabbed Navigation: Clean interface with accounts, keys, and usage tabs
- Real-time Updates: Live data refresh without page reload
- Error Handling: Detailed error messages with actionable solutions
- Python 3.8 or higher
- pip package manager
-
Clone the repository
git clone https://github.com/yourusername/api-usage-dashboard.git cd api-usage-dashboard -
Create a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install flask flask-cors requests
-
Run the dashboard
python dashboard.py
-
Open your browser Navigate to
http://localhost:5000
- Navigate to the Accounts tab
- Click "Add New Account"
- Fill in your details:
- Email address (required)
- Name (optional)
- Organization (optional)
- Save the account
- Go to the API Keys tab
- Click "Add New API Key"
- Select an account from the dropdown
- Enter key details:
- Name: Descriptive name (e.g., "OpenAI Production Key", "Brave Development", "Grok DD/MM/YY", etc.)
- API Key: Your actual API key
- Admin Association: For project keys, link to an admin key
- Test the key (optional but recommended)
- Save the key
- Switch to the Usage Dashboard tab
- Select your time range (7, 30, or 90 days)
- Click "Refresh Data" to fetch latest usage statistics
- View metrics:
- Total cost across all keys
- Request counts and token usage
- Individual key performance
- Error diagnostics and solutions
| Provider | Key Format | Features |
|---|---|---|
| OpenAI | sk-proj-* (Project)sk-admin-* (Admin) |
β
Usage tracking β Cost monitoring β Token analytics |
| Anthropic | sk-ant-* |
β
Key validation β Usage API (not available) |
| Brave Search | BSA* |
β
Key validation β Basic usage (if available) |
- Admin Keys (
sk-admin-*): High-privilege keys with organization-wide access - Project Keys (
sk-proj-*): Scoped to specific projects, can be linked to admin keys - Legacy Keys (
sk-*): Older OpenAI format, treated as project keys
The dashboard uses SQLite with two main tables:
-- Accounts table
CREATE TABLE accounts (
id INTEGER PRIMARY KEY,
email TEXT UNIQUE NOT NULL,
name TEXT,
organization_name TEXT,
created_at TIMESTAMP,
updated_at TIMESTAMP
);
-- API Keys table
CREATE TABLE api_keys (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
full_key TEXT NOT NULL,
masked_key TEXT NOT NULL,
key_type TEXT DEFAULT 'project',
provider TEXT DEFAULT 'openai',
account_id INTEGER REFERENCES accounts(id),
admin_key_id INTEGER REFERENCES api_keys(id),
created_at TIMESTAMP,
updated_at TIMESTAMP
);The dashboard provides a REST API for programmatic access:
GET /api/accounts- List all accountsPOST /api/accounts- Create new accountPUT /api/accounts/{id}- Update accountDELETE /api/accounts/{id}- Delete account
GET /api/keys- List all keys (masked)POST /api/keys- Add new keyPUT /api/keys/{id}- Update keyDELETE /api/keys/{id}- Delete keyGET /api/keys/{id}/full- Get full key (for copying)POST /api/keys/{id}/test- Test key validity
GET /api/usage?days={n}- Fetch usage data for all admin keys
Cause: Your API key doesn't have the required permissions for the Usage API.
Solutions:
- Create a new API key with "All" permissions in OpenAI dashboard
- Ensure your role is "Owner" or "Admin" in the organization
- Contact OpenAI support to request Usage API access (it's restricted)
Cause: Invalid or expired API key.
Solutions:
- Check if the API key is correctly copied (no extra spaces)
- Verify the key hasn't been revoked in your provider's dashboard
- Ensure billing is enabled on your account
Cause: Most API keys cannot access usage monitoring endpoints.
Solutions:
- Usage API access is highly restricted by OpenAI
- Use OpenAI's web dashboard for official usage monitoring
- This dashboard is still useful for key organization and testing
Enable debug output by running:
python dashboard.pyCheck the console output for detailed error messages and API responses.
We welcome contributions! Here's how to get started:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Make your changes
- Add tests (if applicable)
- Commit your changes
git commit -m 'Add amazing feature' - Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
For development, you might want to enable additional debugging:
app.run(debug=True, host='0.0.0.0', port=5000)This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for providing the Usage API
- Flask for the excellent web framework
- SQLite for reliable local data storage
- Contributors who help improve this project
- Issues: GitHub Issues
- Discussions: GitHub Discussions
β If this project helps you manage your API keys better, please consider giving it a star!