Model Management
API Keys
API Keys
API keys authenticate your HIVE Protocol account with AI providers. This guide walks you through setting up API keys for each supported provider, security best practices, and troubleshooting common issues.
Overview
┌─────────────────────────────────────────────────────────────────┐
│ API Key Architecture │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Your Application │
│ │ │
│ ▼ │
│ ┌─────────────┐ │
│ │ HIVE │ │
│ │ Protocol │ │
│ └─────────────┘ │
│ │ │
│ │ Uses your API keys │
│ │ │
│ ├──────────────┬──────────────┬──────────────┐ │
│ ▼ ▼ ▼ ▼ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ OpenAI │ │Anthropic│ │ Google │ │ Ollama │ │
│ │ API │ │ API │ │ API │ │ (Local) │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘Quick Setup
Adding API Keys in HIVE
- Navigate to Settings > Integrations
- Click on the provider you want to configure
- Enter your API key
- Click Save and Test Connection
┌─────────────────────────────────────────────────────────────────┐
│ Settings > Integrations │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ OpenAI [Connected] │ │
│ │ API Key: sk-...xxxxx [Edit] │ │
│ │ Status: Active │ │
│ │ Models: GPT-4o, GPT-4o Mini, GPT-3.5 Turbo │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Anthropic [Connected] │ │
│ │ API Key: sk-ant-...xxxxx [Edit] │ │
│ │ Status: Active │ │
│ │ Models: Claude Sonnet 4, Claude 3.5, Claude Haiku │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Google AI [Not Setup] │ │
│ │ API Key: Not configured [Setup] │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘OpenAI Setup
Step 1: Create an OpenAI Account
- Go to platform.openai.com
- Click "Sign Up" and create an account
- Verify your email address
- Add a payment method (required for API access)
Step 2: Generate API Key
- Navigate to platform.openai.com/api-keys
- Click "Create new secret key"
- Give your key a descriptive name (e.g., "HIVE Protocol Production")
- Copy the key immediately - it won't be shown again
┌─────────────────────────────────────────────────────────────────┐
│ OpenAI API Keys │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Create new secret key │
│ │
│ Name: HIVE Protocol Production │
│ │
│ Your secret key: │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ sk-proj-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ [!] Copy this key now. You won't see it again! │
│ │
│ [Create secret key] │
└─────────────────────────────────────────────────────────────────┘Step 3: Configure Usage Limits
Protect against unexpected costs:
- Go to platform.openai.com/account/limits
- Set monthly usage limits
- Configure email alerts
Recommended settings:
Monthly budget limit: $100 (adjust based on your needs)
Alert threshold: 80% of limit
Hard limit action: Pause requestsStep 4: Add to HIVE Protocol
- In HIVE, go to Settings > Integrations > OpenAI
- Paste your API key
- Click Test Connection
- Verify available models appear
OpenAI Key Format
Standard key: sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Project key: sk-proj-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Service account: sk-svcacct-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxOpenAI Troubleshooting
| Error | Cause | Solution |
|---|---|---|
| Invalid API key | Key typo or revoked | Regenerate key from OpenAI dashboard |
| Rate limit exceeded | Too many requests | Wait and retry, or upgrade plan |
| Insufficient quota | No credits remaining | Add payment method or increase limit |
| Model not found | Model access not granted | Request access in OpenAI dashboard |
Anthropic Setup
Step 1: Create an Anthropic Account
- Go to console.anthropic.com
- Click "Sign Up" and create an account
- Complete email verification
- Add billing information
Step 2: Generate API Key
- Navigate to console.anthropic.com/settings/keys
- Click "Create Key"
- Name your key (e.g., "HIVE Protocol")
- Copy the key immediately
┌─────────────────────────────────────────────────────────────────┐
│ Anthropic Console - API Keys │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Create API Key │
│ │
│ Key name: HIVE Protocol Production │
│ │
│ Workspace: Default │
│ │
│ Your API key: │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ sk-ant-api03-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ [!] Save this key securely - you won't see it again │
│ │
│ [Create Key] │
└─────────────────────────────────────────────────────────────────┘Step 3: Configure Workspace Settings
- Set up spending limits in console.anthropic.com/settings/limits
- Configure team access if needed
- Enable usage alerts
Step 4: Add to HIVE Protocol
- In HIVE, go to Settings > Integrations > Anthropic
- Paste your API key
- Click Test Connection
- Verify Claude models are available
Anthropic Key Format
Standard key: sk-ant-api03-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxAnthropic Troubleshooting
| Error | Cause | Solution |
|---|---|---|
| authentication_error | Invalid key | Check key format, regenerate if needed |
| rate_limit_error | Too many requests | Implement backoff, wait and retry |
| overloaded_error | API under high load | Retry after brief delay |
| invalid_request_error | Malformed request | Check model name and parameters |
Google AI Setup
Step 1: Create Google Cloud Account
- Go to aistudio.google.com
- Sign in with your Google account
- Accept terms of service
Step 2: Get API Key
- Navigate to aistudio.google.com/app/apikey
- Click "Create API key"
- Select or create a Google Cloud project
- Copy the generated key
┌─────────────────────────────────────────────────────────────────┐
│ Google AI Studio - API Keys │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Create API key │
│ │
│ Project: My HIVE Project │
│ │
│ Your API key: │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ AIzaSyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ [Copy] [Done] │
└─────────────────────────────────────────────────────────────────┘Step 3: Enable Gemini API
- Go to Google Cloud Console
- Select your project
- Navigate to APIs & Services > Library
- Search for "Generative Language API"
- Click "Enable"
Step 4: Add to HIVE Protocol
- In HIVE, go to Settings > Integrations > Google AI
- Paste your API key
- Click Test Connection
- Verify Gemini models are available
Google AI Key Format
API key: AIzaSyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxGoogle AI Troubleshooting
| Error | Cause | Solution |
|---|---|---|
| API key not valid | Key incorrect or expired | Regenerate in AI Studio |
| PERMISSION_DENIED | API not enabled | Enable Generative Language API |
| RESOURCE_EXHAUSTED | Quota exceeded | Wait or request quota increase |
| INVALID_ARGUMENT | Wrong model name | Check model ID spelling |
Security Best Practices
Key Management
DO:
- Use separate keys for development and production
- Rotate keys regularly (every 90 days recommended)
- Set up billing alerts and limits
- Use project-specific keys when available
- Monitor usage regularly
DON'T:
- Share keys across multiple applications
- Commit keys to version control
- Include keys in client-side code
- Share keys via email or chat
- Use the same key for all environmentsEnvironment Separation
Create separate API keys for each environment:
Production:
OpenAI: sk-proj-prod-xxxx
Anthropic: sk-ant-prod-xxxx
Google: AIzaSy-prod-xxxx
Staging:
OpenAI: sk-proj-stag-xxxx
Anthropic: sk-ant-stag-xxxx
Google: AIzaSy-stag-xxxx
Development:
OpenAI: sk-proj-dev-xxxx
Anthropic: sk-ant-dev-xxxx
Google: AIzaSy-dev-xxxxAccess Control
Limit who can access and manage API keys:
Roles and Access:
Admin:
- Create/delete keys
- View all keys
- Modify limits
Developer:
- View masked keys
- Test connections
- Monitor usage
Viewer:
- View connection status onlySetting Up Spending Limits
OpenAI
1. Go to: platform.openai.com/account/limits
2. Set "Monthly budget limit"
3. Set "Notification threshold" (e.g., 80%)
4. Save changesAnthropic
1. Go to: console.anthropic.com/settings/limits
2. Set "Monthly spend limit"
3. Configure alerts
4. Save settingsGoogle AI
1. Go to: console.cloud.google.com/billing
2. Set budget alerts
3. Configure quotas per API
4. Enable email notificationsTesting Your Keys
Quick Test
After adding keys, verify they work:
┌─────────────────────────────────────────────────────────────────┐
│ Test Connection │
├─────────────────────────────────────────────────────────────────┤
│ │
│ OpenAI [Test] --> [OK] Connected, 4 models available │
│ Anthropic [Test] --> [OK] Connected, 4 models available │
│ Google AI [Test] --> [OK] Connected, 2 models available │
│ │
│ All providers connected successfully! │
│ │
└─────────────────────────────────────────────────────────────────┘Manual Verification
Test each provider with a simple request:
// Test OpenAI
const openaiResponse = await fetch('https://api.openai.com/v1/models', {
headers: { 'Authorization': 'Bearer YOUR_OPENAI_KEY' }
});
// Test Anthropic
const anthropicResponse = await fetch('https://api.anthropic.com/v1/messages', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_ANTHROPIC_KEY',
'anthropic-version': '2023-06-01',
'content-type': 'application/json'
},
body: JSON.stringify({
model: 'claude-3-haiku-20240307',
max_tokens: 10,
messages: [{ role: 'user', content: 'Hi' }]
})
});Multiple Keys Setup
For high-volume usage, configure multiple keys for load balancing:
openai_keys:
- name: "Primary"
key: "sk-proj-primary-xxxx"
weight: 50
- name: "Secondary"
key: "sk-proj-secondary-xxxx"
weight: 50
load_balancing:
strategy: "round-robin"
failover: trueKey Rotation
Rotate your keys regularly for security:
Rotation Steps
- Generate new key in provider dashboard
- Add new key to HIVE Protocol
- Test new key connection
- Remove old key from HIVE
- Revoke old key in provider dashboard
Rotation Schedule
| Environment | Rotation Frequency |
|---|---|
| Production | Every 90 days |
| Staging | Every 60 days |
| Development | Every 30 days |
Common Issues
"Invalid API Key"
Causes:
1. Key was copy-pasted incorrectly (spaces, newlines)
2. Key was revoked or expired
3. Key format doesn't match provider
Solutions:
1. Re-copy key carefully, ensure no extra characters
2. Generate a new key from provider dashboard
3. Verify key prefix matches expected format:
- OpenAI: sk-proj-xxx or sk-xxx
- Anthropic: sk-ant-xxx
- Google: AIzaSy-xxx"Rate Limit Exceeded"
Causes:
1. Too many requests per minute
2. Too many tokens per day
3. Free tier limits reached
Solutions:
1. Implement request queuing and backoff
2. Upgrade to paid tier
3. Distribute load across multiple keys
4. Use caching to reduce API calls"Insufficient Credits"
Causes:
1. Prepaid credits exhausted
2. Payment method failed
3. Account suspended
Solutions:
1. Add credits or update payment method
2. Verify billing information is current
3. Contact provider support if account issuesRelated Documentation
- [Supported Models](/docs/models/supported-models): Complete model reference
- [Local Models](/docs/models/local-models): Run models without API keys
- [Usage & Costs](/docs/models/usage-tracking): Monitor your spending