Developer Docs

API Documentation

Connect your tools and applications to AI Hub.

What do you want to build?

👨‍💻 Claude Code Setup Claude Code 🧩 OpenCode Connect OpenCode (Desktop & CLI) Kilo Code Connect Kilo Code
Need help getting started?
Watch step-by-step setup tutorials on our Telegram channel.
Join Channel →
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__"
  }
}

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.

Advanced: the --dangerously-skip-permissions flag and "skipDangerousModePermissionPrompt" setting bypass Claude Code's permission prompts. Leave them off for a safer setup — they are disabled by default.
claude --model __MODEL_SONNET__

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.
Every AI Hub model works with @ai-sdk/anthropic. @ai-sdk/openai-compatible also works — see §5 Which SDK? for the trade-off.
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. Which SDK? @ai-sdk/anthropic vs @ai-sdk/openai-compatible

AI Hub exposes both API shapes, so either SDK works. The npm field in your provider block decides which endpoint OpenCode calls:

Config "npm"Endpoint usedModels supported
@ai-sdk/anthropic (recommended) POST /v1/messages All models
@ai-sdk/openai-compatible POST /v1/chat/completions All models when streaming

Use @ai-sdk/anthropic unless you have a reason not to. It is the only one that also works for non-streaming requests on every model. OpenCode itself always streams, so in normal use both are fine — but scripts or tools that call AI Hub without stream: true should stay on the Anthropic path.

Non-streaming caveats

These only apply when you send a request without "stream": true. OpenCode always streams, so you will not hit these in the app — only in your own curl / script calls.

ModelsNon-streaming behaviour
ag/* (Gemini / Antigravity) Works on /v1/messages. Returns 502 on /v1/chat/completions — add "stream": true.
rs/* (Kimi & Minimax) Returns empty content on both endpoints. Streaming returns text normally.
Everything else Works on both endpoints, streaming or not.

Reasoning models return an empty first reply if max_tokens is too low

Models such as cbcn/kimi-k3 and the cx/* family spend tokens on hidden reasoning before emitting any visible text. With a small max_tokens (say 64) the whole budget goes to reasoning and you get a 200 response with empty content and stop_reason: "max_tokens". Allow at least a few hundred output tokens for these models.

6. Troubleshooting

400 Invalid request parameters — too many tools

Some upstreams cap how many tool definitions one request may carry. cbcn/kimi-k3 in particular rejects large tool blocks with a generic "Invalid request parameters" and an empty param field.

  • Disable some MCP servers so fewer tools are sent
  • Around 16 tools is reliable; 70+ fails on cbcn/kimi-k3
  • cbcn/minimax-m3 handles much larger tool sets if you need them
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
ModelProvider
Loading models…
Models available through providers that support Kilo Code. Copy a model's name to paste as its ID in 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.
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