Documentation

Get started in 5 minutes.

AIAgenHub speaks both the OpenAI /v1/chat/completions API and the Anthropic /v1/messages API. Point your existing SDK at us, paste your API key, and you're live — or configure Claude Code, Codex, OpenCode, and more in one command.

Fastest path for coding agents

One command. Claude, Codex, OpenCode, Hermes, Cline… Create an API key, then run the interactive helper. It validates your key against GET /v1/models, lets you pick agents and models, and writes the right config files for each tool on Windows, macOS, and Linux.

npx (recommended)
# after you have a key from Dashboard -> API Keys
npx @aiagenhub/helper
# interactive wizard:
# 1. paste API key -> validated via /v1/models
# 2. select agents -> Claude Code, Codex, OpenCode, Hermes, OpenClaw, Cline
# 3. search models -> e.g. ocg/glm-5.3
# 4. confirm -> configs written (with backup)

Step 1 — Get an API key

Create an account and head to Dashboard → API Keys. Click Create key, copy it, and store it safely. Keys start with sk-agen- and are shown only once.

Step 2 — Top up with USDC

Open Dashboard → Deposit. Each account gets a unique Solana address. Send USDC from any wallet — no memo required. After finalized commitment (~13 seconds) your balance is credited. Settlement is on Solana mainnet — send real USDC and double-check the address and network before sending; funds sent to the wrong network may be unrecoverable.

Step 3 — Make your first request

OpenAI Python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.aiagenku.app/v1",
    api_key="sk-agen-...",
)

resp = client.chat.completions.create(
    model="ocg/glm-5.3",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
Anthropic Python / Claude Code
from anthropic import Anthropic

# IMPORTANT: Anthropic clients append /v1 themselves.
# Use the API root, NOT ".../v1" (that becomes /v1/v1/messages).
client = Anthropic(
    base_url="https://api.aiagenku.app",
    api_key="sk-agen-...",
)

# Or skip manual env setup:
# npx @aiagenhub/helper
# Claude Code:
# ANTHROPIC_BASE_URL=https://api.aiagenku.app
# ANTHROPIC_AUTH_TOKEN=***
resp = client.messages.create(
    model="zai/glm-5.3",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.content[0].text)
curl (chat completions)
curl https://api.aiagenku.app/v1/chat/completions \
  -H "Authorization: Bearer sk-agen-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ocg/glm-5.3",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
curl (Anthropic messages)
curl https://api.aiagenku.app/v1/messages \
  -H "x-api-key: sk-agen-..." \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "zai/glm-5.3",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
curl (image generation)
curl https://api.aiagenku.app/v1/images/generations \
  -H "Authorization: Bearer sk-agen-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A single red apple on a plain white studio background.",
    "size": "1024x1024"
  }'
# The image comes back inline: data[0].b64_json. There is no hosted URL.
# quality (low/medium/high) changes what the image costs, a lot.
curl (video generation)
# 1. Submit. This returns a JOB, not a video: generation takes 90s+.
curl https://api.aiagenku.app/v1/videos \
  -H "Authorization: Bearer sk-agen-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "leo/veo-3.1-fast-generate-001",
    "prompt": "A red cube slowly rotating on a white table.",
    "seconds": "8"
  }'
# -> {"id":"video_...","object":"video","status":"queued","progress":0}
# 2. Poll until status is "completed" (or "failed").
curl https://api.aiagenku.app/v1/videos/video_... -H "Authorization: Bearer sk-agen-..."
# 3. Download the mp4.
curl https://api.aiagenku.app/v1/videos/video_.../content -H "Authorization: Bearer sk-agen-..." -o out.mp4
# A generation that fails is not billed.
curl (with bid headers)
# Cap what you pay per million tokens with two headers.
# We only route to providers whose asks meet your cap.
curl https://api.aiagenku.app/v1/chat/completions \
  -H "Authorization: Bearer sk-agen-..." \
  -H "x-max-input-price: 0.30" \
  -H "x-max-output-price: 1.50" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ocg/glm-5.3",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Step 4 — Read the API reference

  • GET /v1/models — List every model addressable as <prefix>/<model-id>.
  • POST /v1/chat/completions — OpenAI-compatible chat completions. Streaming and tool calling supported.
  • POST /v1/messages — Anthropic-compatible messages API. Same key, native SSE event stream.
  • POST /v1/images/generations — OpenAI-compatible image generation. Returns the picture inline as b64_json.
  • POST /v1/images/edits — Edit an image you supply. Same contract, plus the input picture.
  • POST /v1/videos — Video generation, OpenAI Videos API shape. Returns a job to poll, not a video.
  • GET /v1/videos/{id}/content — Download a finished video once its job reports completed.
  • POST /v1/embeddings — OpenAI-compatible embeddings.
  • GET /api/me — Balance, tier, and Solana deposit address for the authenticated key.

Routing tips

  • Address models by prefix: Every model lives under an upstream prefix. For example, model="ocg/glm-5.3" targets OpenCode Go’s GLM-5.3; zai/glm-5.3 targets z.ai’s. See /pricing for the full list.
  • Auto routing: The router picks the best publisher serving that prefix per request, falling over to another on failure (up to 5 hops).
  • Busy capacity: When every provider for a model is at its concurrency limit, you get 429 capacity_saturated with Retry-After: 2. Nothing is billed; retry after a short backoff.
  • Bidding (optional): Cap what you pay per million tokens with x-max-input-price and x-max-output-price. If none match you get 402 no_provider_under_bid.