Basic Usage¶
Learn how to make your first API call to IndoxHub.
Authentication¶
All API requests require an API key passed in the Authorization header:
API keys follow the format indox-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. You can generate keys from the IndoxHub dashboard.
Base URL¶
All API endpoints are available at:
Your First Request¶
import requests
response = requests.post(
"https://api.indoxhub.com/api/v1/chat/completions",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"model": "openai/gpt-4o-mini",
"messages": [
{"role": "user", "content": "Hello, world!"}
]
}
)
print(response.json()["data"])
const response = await fetch("https://api.indoxhub.com/api/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-4o-mini",
messages: [{ role: "user", content: "Hello, world!" }]
})
});
const data = await response.json();
console.log(data.data);
Response Format¶
All endpoints return a consistent response structure:
{
"request_id": "550e8400-e29b-41d4-a716-446655440000",
"created_at": "2026-04-07T12:00:00Z",
"duration_ms": 850.5,
"provider": "openai",
"model": "gpt-4o-mini",
"success": true,
"message": "",
"data": "...",
"usage": {
"tokens_prompt": 12,
"tokens_completion": 45,
"tokens_total": 57,
"cost": 0.0023,
"latency": 850.5
}
}
Model Naming¶
Models use the provider/model-name format:
| Provider | Example Model |
|---|---|
| OpenAI | openai/gpt-4o-mini |
| Anthropic | anthropic/claude-haiku-4.5 |
google/gemini-2.0-flash |
|
| DeepSeek | deepseek/deepseek-chat |
| Mistral | mistral/mistral-large-latest |
| XAI | xai/grok-2 |
Error Handling¶
Errors return standard HTTP status codes with a JSON body:
| Code | Meaning |
|---|---|
| 400 | Invalid request parameters |
| 402 | Insufficient credits |
| 403 | Model access forbidden |
| 404 | Resource not found |
| 500 | Internal server error |
| 504 | Request timeout |