API Documentation

Connect your tools and applications to AI Hub.

Paste your key — it is injected into all code samples across every tab.
💡
Claude Code CLI with AI Hub
AI Hub is a drop-in replacement for the Anthropic API. Point Claude Code at AI Hub by setting ANTHROPIC_BASE_URL and your hub API key — no other changes needed.
🧩
Prefer VS Code?
Install the Claude Code VS Code Extension to use Claude Code directly inside your editor. The same ANTHROPIC_BASE_URL and API key settings apply — configure them in VS Code settings or your ~/.claude/settings.json.

1. Install Claude Code

To install Claude Code, use one of the following methods:

macOS, Linux, WSL:

curl -fsSL https://claude.ai/install.sh | bash

Windows PowerShell:

irm https://claude.ai/install.ps1 | iex

Windows CMD:

curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd
brew install anthropics/claude-code/claude-code
winget install Anthropic.ClaudeCode

2. Settings File

Loading models…
Pick 1–3 models — 1st = Sonnet, 2nd = Opus, 3rd = Haiku roles.

Create or edit ~/.claude/settings.json (user-level, applies everywhere) or .claude/settings.json inside a project folder.

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://ai-hub.aicampus.my",
    "ANTHROPIC_API_KEY": "YOUR_AI_HUB_API_KEY",
    "CLAUDE_CODE_USE_OAUTH": "false",
    "ANTHROPIC_MODEL": "__MODEL_SONNET__",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "__MODEL_SONNET__",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "__MODEL_OPUS__",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "__MODEL_HAIKU__"
  },
  "skipDangerousModePermissionPrompt": true
}

Replace YOUR_AI_HUB_API_KEY with a key from your Dashboard. Adjust model aliases to ones you have access to.

3. Launch Command

Override the default model at launch time. Configure the command below, then copy and run it.

claude --model __MODEL_SONNET__ --dangerously-skip-permissions

Error Reference

401 Unauthorized

API key is missing, invalid, or revoked.

  • Check x-api-key header is present and correct
  • Key not revoked and not expired (check Dashboard)
429 Too Many Requests

Rate limit or token quota exceeded.

  • Check Retry-After header and wait
  • Check token usage on Dashboard
403 Forbidden

No access to the requested model.

  • Verify model alias is spelled correctly
  • Check your model access in Dashboard
500 Internal Server Error

Upstream provider error or misconfiguration.

  • Retry with exponential backoff
  • Contact admin if persistent
503 Service Unavailable

Provider temporarily disabled. Check the Models page.

💡
OpenCode (Desktop, TUI & CLI) with AI Hub
OpenCode shares one config file across the Desktop app, TUI, and opencode CLI — generate it once below and all three pick it up. Use the Anthropic SDK (@ai-sdk/anthropic) and override baseURL to point at AI Hub — the trailing /v1 is required.
Select models to include Select any models to include in your opencode.jsonc.
Loading models…

1. Config File Location

OpenCode reads its config from:

  • ~/.config/opencode/opencode.jsonc — macOS & Linux
  • %APPDATA%\opencode\opencode.jsonc — Windows

Create the file if it doesn't exist. JSONC means JSON with // comments allowed.

2. opencode.jsonc — Full Setup

Paste this into ~/.config/opencode/opencode.jsonc. The Desktop app, TUI, and opencode CLI all read this file. Snippet uses the models you selected above.

# Select models above to generate your config.

After saving, fully quit and relaunch OpenCode Desktop — config is read on startup, not hot-reloaded. The CLI re-reads on every command, so no restart is needed there.

3. Using with the CLI

Same config file — no extra setup. Install the CLI and you can run AI Hub models from your terminal.

Install

# macOS (Homebrew)
brew install sst/tap/opencode

# npm (cross-platform)
npm install -g opencode-ai

# install script
curl -fsSL https://opencode.ai/install | bash

Verify the provider is loaded

opencode models | grep ai-hub

You should see your AI Hub models listed under the ai-hub/ prefix.

Run a one-shot prompt

opencode run -m ai-hub/__MODEL_SONNET__ "Summarize this repo"

Launch the interactive TUI

opencode

Pick a ai-hub/... model from the picker. Project-level override: drop an opencode.jsonc into a project root to override the global config for that project only.

4. Single Model Snippet

To add just one model to an existing config, drop this entry into the models object.

"__MODEL_SONNET__": { "name": "__MODEL_SONNET__ (via AI Hub)" }

5. Troubleshooting

404 Not Found — "/chat/completions"

You used @ai-sdk/openai-compatible. AI Hub does not expose /v1/chat/completions — only /v1/messages (Anthropic).

  • ✅ Correct: "npm": "@ai-sdk/anthropic"
  • ❌ Wrong: "npm": "@ai-sdk/openai-compatible"
404 Not Found — "forgot /v1"

The Anthropic SDK appends /messages to baseURL. If baseURL does not end with /v1, the request goes to the wrong path.

  • ✅ Correct: "baseURL": "https://ai-hub.aicampus.my/v1"
  • ❌ Wrong: "baseURL": "https://ai-hub.aicampus.my"
401 Unauthorized

API key is missing, invalid, or revoked.

  • Ensure apiKey is set in the options block
  • Check the key is active on your Dashboard
Config changes not taking effect

OpenCode reads opencode.jsonc at startup only.

  • Fully quit OpenCode (Cmd+Q on macOS) — closing the window is not enough
  • Relaunch the app
Models not appearing in the picker

Check that disabled_providers doesn't contain "ai-hub", and that each model alias matches one you have access to (visible on this page).

CLI says "provider not found"

The CLI couldn't load the ai-hub provider from your config.

  • Confirm the file exists at ~/.config/opencode/opencode.jsonc (or opencode.json)
  • Run opencode models — it lists every provider that loaded
  • Set OPENCODE_CONFIG=/full/path/to/opencode.jsonc to force a specific file if needed
Loading models…
Models available through providers that support Kilo Code.
💡
Kilo Code with AI Hub
Kilo Code is a VS Code extension for AI-powered coding. Connect it to AI Hub by adding a custom provider with your hub API key — no Anthropic account needed.
⚠️
Model limitation
Kilo Code currently does not support the built-in claude-cli-opus-*, claude-cli-sonnet-*, and claude-cli-haiku-* model names when using a custom provider. Use the model aliases from your AI Hub dashboard instead.
🧩
Install Kilo Code
Get it from the VS Code Marketplace, or open it directly in VS Code by clicking the link below:
vscode:extension/kilocode.kilo-code

Click the button above to open the extension installer directly in VS Code, or copy the URL and paste it into your browser address bar.

1. Add a Custom Provider

In Kilo Code settings, create a new custom provider with the following details:

  • Provider IDaihub
  • Display nameAI-HUB
  • Provider API (select option)Anthropic Message
  • Base URLhttps://ai-hub.aicampus.my/v1
  • API key — your sk-hub-… key from Dashboard
Kilo Code — Add custom provider

2. Add Models

After saving the provider, add each model you want to use. Enter the model alias (e.g. mimo-v2-omni) as the ID and give it a display name.

Kilo Code — Add models