Skip to content

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:

Authorization: Bearer YOUR_API_KEY

API keys follow the format indox-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. You can generate keys from the IndoxHub dashboard.

Base URL

All API endpoints are available at:

https://api.indoxhub.com/api/v1

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);
curl https://api.indoxhub.com/api/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-4o-mini", "messages": [{"role": "user", "content": "Hello, world!"}]}'
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.indoxhub.com/v1"
)
response = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello, world!"}]
)
print(response.choices[0].message.content)

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 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
{
  "request_id": "...",
  "success": false,
  "message": "Insufficient credits. Please top up your account.",
  "data": ""
}
Documentation last built on May 23, 2026