HIVE

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

  1. Navigate to Settings > Integrations
  2. Click on the provider you want to configure
  3. Enter your API key
  4. 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

  1. Go to platform.openai.com
  2. Click "Sign Up" and create an account
  3. Verify your email address
  4. Add a payment method (required for API access)

Step 2: Generate API Key

  1. Navigate to platform.openai.com/api-keys
  2. Click "Create new secret key"
  3. Give your key a descriptive name (e.g., "HIVE Protocol Production")
  4. 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:

  1. Go to platform.openai.com/account/limits
  2. Set monthly usage limits
  3. Configure email alerts

Recommended settings:

Monthly budget limit: $100 (adjust based on your needs)
Alert threshold: 80% of limit
Hard limit action: Pause requests

Step 4: Add to HIVE Protocol

  1. In HIVE, go to Settings > Integrations > OpenAI
  2. Paste your API key
  3. Click Test Connection
  4. Verify available models appear

OpenAI Key Format

Standard key:    sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Project key:     sk-proj-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Service account: sk-svcacct-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

OpenAI Troubleshooting

ErrorCauseSolution
Invalid API keyKey typo or revokedRegenerate key from OpenAI dashboard
Rate limit exceededToo many requestsWait and retry, or upgrade plan
Insufficient quotaNo credits remainingAdd payment method or increase limit
Model not foundModel access not grantedRequest access in OpenAI dashboard

Anthropic Setup

Step 1: Create an Anthropic Account

  1. Go to console.anthropic.com
  2. Click "Sign Up" and create an account
  3. Complete email verification
  4. Add billing information

Step 2: Generate API Key

  1. Navigate to console.anthropic.com/settings/keys
  2. Click "Create Key"
  3. Name your key (e.g., "HIVE Protocol")
  4. 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

  1. Set up spending limits in console.anthropic.com/settings/limits
  2. Configure team access if needed
  3. Enable usage alerts

Step 4: Add to HIVE Protocol

  1. In HIVE, go to Settings > Integrations > Anthropic
  2. Paste your API key
  3. Click Test Connection
  4. Verify Claude models are available

Anthropic Key Format

Standard key: sk-ant-api03-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Anthropic Troubleshooting

ErrorCauseSolution
authentication_errorInvalid keyCheck key format, regenerate if needed
rate_limit_errorToo many requestsImplement backoff, wait and retry
overloaded_errorAPI under high loadRetry after brief delay
invalid_request_errorMalformed requestCheck model name and parameters

Google AI Setup

Step 1: Create Google Cloud Account

  1. Go to aistudio.google.com
  2. Sign in with your Google account
  3. Accept terms of service

Step 2: Get API Key

  1. Navigate to aistudio.google.com/app/apikey
  2. Click "Create API key"
  3. Select or create a Google Cloud project
  4. 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

  1. Go to Google Cloud Console
  2. Select your project
  3. Navigate to APIs & Services > Library
  4. Search for "Generative Language API"
  5. Click "Enable"

Step 4: Add to HIVE Protocol

  1. In HIVE, go to Settings > Integrations > Google AI
  2. Paste your API key
  3. Click Test Connection
  4. Verify Gemini models are available

Google AI Key Format

API key: AIzaSyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Google AI Troubleshooting

ErrorCauseSolution
API key not validKey incorrect or expiredRegenerate in AI Studio
PERMISSION_DENIEDAPI not enabledEnable Generative Language API
RESOURCE_EXHAUSTEDQuota exceededWait or request quota increase
INVALID_ARGUMENTWrong model nameCheck 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 environments

Environment 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-xxxx

Access 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 only

Setting 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 changes

Anthropic

1. Go to: console.anthropic.com/settings/limits
2. Set "Monthly spend limit"
3. Configure alerts
4. Save settings

Google AI

1. Go to: console.cloud.google.com/billing
2. Set budget alerts
3. Configure quotas per API
4. Enable email notifications

Testing 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: true

Key Rotation

Rotate your keys regularly for security:

Rotation Steps

  1. Generate new key in provider dashboard
  2. Add new key to HIVE Protocol
  3. Test new key connection
  4. Remove old key from HIVE
  5. Revoke old key in provider dashboard

Rotation Schedule

EnvironmentRotation Frequency
ProductionEvery 90 days
StagingEvery 60 days
DevelopmentEvery 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 issues
  • [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

Cookie Preferences

We use cookies to enhance your experience, analyze site traffic, and for marketing purposes. By clicking "Accept All", you consent to our use of cookies. Read our Privacy Policy for more information.