Developer Documentation

One API key. 500+ AI models. OpenAI SDK compatible. Get started in under 2 minutes.

Contents

  1. Quick Start
  2. Authentication
  3. API Reference
  4. Models
  5. SDKs & Code Examples
  6. Integrations
  7. Features
  8. FAQ & Troubleshooting

1. Quick Start

Three steps to your first API call.

1

Get your API key

Sign up for free, then create a token in the Dashboard → Tokens page. No credit card required.

2

Set the base URL

Point your OpenAI SDK or HTTP client to: https://aihubapi.ai/v1

3

Make your first call

Pick any model and send a request:

curl
Python
Node.js
Go
curl https://aihubapi.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
from openai import OpenAI

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

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

print(response.choices[0].message.content)
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'sk-your-api-key',
  baseURL: 'https://aihubapi.ai/v1',
});

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

console.log(response.choices[0].message.content);
import "github.com/sashabaranov/go-openai"

config := openai.DefaultConfig("sk-your-api-key")
config.BaseURL = "https://aihubapi.ai/v1"
client := openai.NewClientWithConfig(config)

resp, _ := client.CreateChatCompletion(ctx, openai.ChatCompletionRequest{
    Model:    "gpt-4o",
    Messages: []openai.ChatCompletionMessage{
        {Role: "user", Content: "Hello!"},
    },
})
That's it. Any code that works with OpenAI's API works with AIHubAPI — just change the base URL.

2. Authentication

ItemValue
Base URLhttps://aihubapi.ai/v1
API Key formatsk-xxxxxxxxxxxx
HTTP HeaderAuthorization: Bearer sk-xxxxxxxxxxxx
Dashboardhttps://aihubapi.ai/console

Environment variables (recommended)

Most OpenAI-compatible SDKs read these automatically:

export OPENAI_API_KEY=sk-your-api-key
export OPENAI_BASE_URL=https://aihubapi.ai/v1
Never commit API keys to git or expose them in client-side code. Use environment variables or a secrets manager.

3. API Reference

POST /v1/chat/completions

Create a chat completion. Supports all OpenAI-compatible parameters.

ParameterTypeRequiredDescription
modelstringYesModel ID, e.g. gpt-4o, claude-sonnet-4.6, deepseek-chat
messagesarrayYesArray of message objects with role and content
streambooleanNoEnable SSE streaming (default: false)
temperaturenumberNoSampling temperature, 0–2 (default: 1)
max_tokensintegerNoMaximum tokens to generate
top_pnumberNoNucleus sampling
frequency_penaltynumberNo-2.0 to 2.0
presence_penaltynumberNo-2.0 to 2.0
stopstring/arrayNoUp to 4 stop sequences
toolsarrayNoFunction/tool definitions for tool calling

Response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1712345678,
  "model": "gpt-4o",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Hello! How can I help you today?"
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 9,
    "total_tokens": 21
  }
}

Streaming

Set "stream": true to receive Server-Sent Events. Each event is a JSON chunk:

data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":"Hello"}}]}
data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":"!"}}]}
data: [DONE]

GET /v1/models

List all available models. Returns an array of model objects with id, object, created, and owned_by fields.

curl https://aihubapi.ai/v1/models \
  -H "Authorization: Bearer sk-your-api-key"

Error Codes

HTTP CodeMeaningWhat to do
400Bad requestCheck request body format and required fields
401UnauthorizedVerify your API key is valid and correctly formatted
402Insufficient quotaTop up credits in the Dashboard
429Rate limitedBack off and retry with exponential backoff
500Server errorRetry; contact support if persistent
503No channel availableModel may be temporarily unavailable; try a different model

Error responses follow this format:

{
  "error": {
    "code": "model_not_found",
    "message": "No available channel for model X under group default",
    "type": "new_api_error"
  }
}

4. Models

AIHubAPI provides access to 350+ models from all major providers via a single API. Here are the most popular ones:

OpenAI

ModelDescription
gpt-4oFlagship multimodal model, fast and capable
gpt-4o-miniAffordable small model for lightweight tasks
gpt-4-turboGPT-4 Turbo with vision
o3Advanced reasoning model
o4-miniFast reasoning model
gpt-4.1Latest GPT-4 series

Anthropic

ModelDescription
claude-sonnet-4.6Latest Claude, excellent for coding & analysis
claude-opus-4.6Most capable Claude model
claude-haiku-4.5Fast and affordable
claude-sonnet-4Balanced performance

Google

ModelDescription
gemini-2.5-proMost capable Gemini model
gemini-2.5-flashFast multimodal model
gemini-2.5-flash-liteLightweight and fast

DeepSeek

ModelDescription
deepseek-chatGeneral chat, very cost-effective
deepseek-v3.2Latest DeepSeek V3
deepseek-r1Reasoning model

Meta, Mistral, Qwen, xAI & more

ModelDescription
llama-4-maverickMeta's latest large model
mistral-largeMistral's flagship
qwen3-235b-a22bAlibaba's Qwen 3
grok-4xAI's latest Grok
Model aliases: You can use short names like gpt-4o or full provider-prefixed names like openai/gpt-4o. Both work. Run GET /v1/models for the complete list of 350+ available models.

5. SDKs & Code Examples

AIHubAPI works with any OpenAI-compatible SDK. No special client needed.

Python — Streaming

from openai import OpenAI

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

stream = client.chat.completions.create(
    model="claude-sonnet-4.6",
    messages=[{"role": "user", "content": "Explain quantum computing"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Node.js — Streaming

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'sk-your-api-key',
  baseURL: 'https://aihubapi.ai/v1',
});

const stream = await client.chat.completions.create({
  model: 'deepseek-chat',
  messages: [{ role: 'user', content: 'Hello!' }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '');
}

Go

package main

import (
    "context"
    "fmt"
    openai "github.com/sashabaranov/go-openai"
)

func main() {
    config := openai.DefaultConfig("sk-your-api-key")
    config.BaseURL = "https://aihubapi.ai/v1"
    client := openai.NewClientWithConfig(config)

    resp, _ := client.CreateChatCompletion(
        context.Background(),
        openai.ChatCompletionRequest{
            Model:    "gpt-4o",
            Messages: []openai.ChatCompletionMessage{
                {Role: "user", Content: "Hello!"},
            },
        },
    )
    fmt.Println(resp.Choices[0].Message.Content)
}

6. Integrations

Any tool that supports a custom OpenAI base URL works with AIHubAPI.

Cursor

Settings → Models → OpenAI API Key: sk-your-api-key
Override OpenAI Base URL: https://aihubapi.ai/v1

VS Code — Continue

{
  "models": [{
    "provider": "openai",
    "model": "deepseek-chat",
    "apiBase": "https://aihubapi.ai/v1",
    "apiKey": "sk-your-api-key"
  }]
}

Aider

aider --openai-api-base https://aihubapi.ai/v1 --openai-api-key sk-your-api-key

LobeChat

Settings → Language Model → OpenAI → API Proxy URL: https://aihubapi.ai/v1

Cherry Studio

Settings → Model Services → Add custom provider → API URL: https://aihubapi.ai

Works with ChatBox, BoltAI, OpenCat, LibreChat, and any other OpenAI-compatible client.

7. Features

8. FAQ & Troubleshooting

Q: What's the difference from using OpenAI directly?
Same API format, just a different base URL. Benefits: access to 500+ models from all providers, automatic failover, unified billing, and often lower cost through smart routing.
Q: I'm getting "no available channel" (503). What do I do?
The model may not have an active upstream channel. Double-check the model name (see Models), try a different model, or retry after a moment.
Q: My API key isn't working (401).
Check: (1) key starts with sk-, (2) key is not expired or disabled, (3) you have sufficient quota, (4) header format is Authorization: Bearer sk-....
Q: Is there a rate limit?
Default: 180 requests/min for API, 120 requests/min for web. Need higher limits? Contact support.
Q: Do you store my prompts or responses?
No. Request and response content is not persistently stored. Only metadata (timestamps, model, token counts, cost) is logged for billing and usage analytics.
Q: Which SDKs are supported?
Any language that can make HTTP requests. Official OpenAI SDKs for Python, Node.js, Go, Java, .NET, and Ruby all work out of the box — just set the base URL.
Q: How do I check my usage and billing?
Log in to the Dashboard and check the Statistics page for real-time usage, cost breakdowns, and billing details.