Skip to main content

Authentication

All API requests to ModelHive require an API Key for authentication.

Getting Your API Key​

  1. Sign up at app.modelhive.ai
  2. Complete the onboarding flow
  3. Go to Dashboard → API Keys → Create New Key
  4. Set a name, budget, and optionally restrict to specific models
  5. Copy your API key — it starts with sk-
warning

Your API key is only shown once at creation time. Store it securely — it cannot be retrieved later.

Using Your API Key​

Include the key in the Authorization header of every request:

from openai import OpenAI

client = OpenAI(
api_key="sk-your-modelhive-key",
base_url="https://api.modelhive.ai/v1"
)

response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)

API Key Properties​

Each key can be configured from the Dashboard:

PropertyDescription
NameA human-readable label
BudgetMaximum spend in USD — deducted from your wallet
ModelsRestrict to specific models (empty = all available)
Auto-RechargeAutomatically refill from wallet when budget is low
Budget AlertsReceive email notifications when approaching the limit

See API Keys & Budgets for full details.

Authentication Errors​

HTTP CodeMeaning
401Missing or invalid API key
402API key has insufficient budget
{
"error": {
"message": "Invalid API key provided.",
"type": "authentication_error",
"code": 401
}
}
tip

If you get a 402 error, recharge your key from the Dashboard or enable auto-recharge to avoid service interruptions.