Authentication
All API requests to ModelHive require an API Key for authentication.
Getting Your API Key
- Sign up at app.modelhive.ai
- Complete the onboarding flow
- Go to Dashboard → API Keys → Create New Key
- Set a name, budget, and optionally restrict to specific models
- 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:
- Python
- JavaScript
- cURL
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!"}]
)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'sk-your-modelhive-key',
baseURL: 'https://api.modelhive.ai/v1',
});
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }],
});
curl -X POST https://api.modelhive.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-modelhive-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'
API Key Properties
Each key can be configured from the Dashboard:
| Property | Description |
|---|---|
| Name | A human-readable label |
| Budget | Maximum spend in USD — deducted from your wallet |
| Models | Restrict to specific models (empty = all available) |
| Auto-Recharge | Automatically refill from wallet when budget is low |
| Budget Alerts | Receive email notifications when approaching the limit |
See API Keys & Budgets for full details.
Authentication Errors
| HTTP Code | Meaning |
|---|---|
401 | Missing or invalid API key |
402 | API 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.