Developer docs

Model integration, explained clearly

Copy a model name or config from Models and integrate with the Base URL and Key here. These docs only cover what actually affects calls, billing and troubleshooting.

OpenAI-compatibleOne key for all modelsTransparent, auditable pricing
Minimal configOpenAI-compatible
quickstart.sh
export APIEX_API_KEY="sk-..."

curl https://apiex.cc/gateway/v1/chat/completions \
  -H "Authorization: Bearer $APIEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-max",
    "messages": [
      {"role": "user", "content": "hi"}
    ]
  }'
Base URLhttps://apiex.cc/gateway/v1
AuthAuthorization: Bearer $APIEX_API_KEY
Model IDCopy from Models to avoid typos
Pricing basisUSD / 1M tokens; CNY shown as an estimate only

Quick start

1. Create an API Key

  1. Sign in to the console.
  2. Open API Key management and create a new key.
  3. Confirm the account has available balance or enterprise quota.

2. Choose a model

Browse Models and pick by provider, context length, input/output price and capability tags. Prefer explicit model IDs at the beginning.

3. Verify connectivity

connectivity.sh
export APIEX_API_KEY="sk-xxxxxxxx"

curl -s -o /dev/null -w "%{http_code}\n" \
  -H "Authorization: Bearer $APIEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"openai/gpt-5.2","messages":[{"role":"user","content":"hi"}]}' \
  https://apiex.cc/gateway/v1/chat/completions

Standard integration & config

The apiex gateway is OpenAI-compatible. Any SDK, CLI or Agent tool needs only the three fields below — defined once here, and tool sections only cover their differences.

API KeyA sk-... key created in the console. Store it in the APIEX_API_KEY environment variable and never commit it to a repository.
Base URLUse https://apiex.cc/gateway/v1 by default; tools that expect the URL before the version segment and append /v1 themselves should use https://apiex.cc/gateway. Both are equivalent. Never put a full endpoint path into the Base URL.
Model IDUse the provider/model-name format from Models; copy it there to avoid typos.
python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["APIEX_API_KEY"],
    base_url="https://apiex.cc/gateway/v1",
)

completion = client.chat.completions.create(
    model="openai/gpt-5.2",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "how are you?"}
    ],
)

print(completion.choices[0].message.content)
Tool sections below all follow this table; a Base URL written up to /gateway refers to Anthropic-family tools that append /v1/messages themselves.

IDE & CLI integration

All tools below build on the three fields in Standard integration & config; this group only lists per-tool differences.

Claude Code

Anthropic-compatible tools: set the Base URL to https://apiex.cc/gateway (no /v1) — the CLI appends /v1/messages itself.

Persistent config (recommended)

~/.claude/settings.json
mkdir -p ~/.claude

cat > ~/.claude/settings.json <<'EOF'
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://apiex.cc/gateway",
    "ANTHROPIC_API_KEY": "sk-xxxxxxxx",
    "ANTHROPIC_MODEL": "anthropic/claude-sonnet-4.6"
  },
  "includeCoAuthoredBy": false
}
EOF

claude /logout 2>/dev/null || true
unset ANTHROPIC_AUTH_TOKEN
On auth conflicts, make sure only one authentication method is kept — no OAuth Token and API Key set at the same time.

Temporary access (environment variables)

claude.env
export ANTHROPIC_BASE_URL="https://apiex.cc/gateway"
export ANTHROPIC_API_KEY="sk-xxxxxxxx"

claude
For team collaboration, commit the structured config to the repository and keep real keys in a local .local config or the system keychain.

Codex CLI

Difference: uses the Responses API (wire_api = "responses"), with config in the user-level ~/.codex/config.toml.

~/.codex/config.toml
mkdir -p ~/.codex

cat > ~/.codex/config.toml <<'EOF'
model_provider = "apiex"
model = "openai/gpt-5.2"

[model_providers.apiex]
name = "apiex"
base_url = "https://apiex.cc/gateway/v1"
env_key = "APIEX_API_KEY"
wire_api = "responses"
requires_openai_auth = false
EOF

export APIEX_API_KEY="sk-xxxxxxxx"
codex
If /responses returns 404, check wire_api = "responses" and the Base URL first — never put a full endpoint path into base_url.

Cursor

  1. Open Cursor settings and go to Models.
  2. Add a custom model; use the provider/model-name format from Models for the model ID.
  3. Enable the OpenAI API Key switch and fill in your apiex key.
  4. Set the Base URL per the common config (https://apiex.cc/gateway/v1; use https://apiex.cc/gateway if the tool appends /v1 itself).
  5. After saving, select the model in Chat, Composer or Agent.

Claude Desktop

Difference: desktop clients usually connect through a local MCP or tool proxy. Keep the apiex key in local environment variables and let the tool config read it.

desktop.env
export APIEX_API_KEY="sk-xxxxxxxx"
export APIEX_BASE_URL="https://apiex.cc/gateway/v1"
If the client still reaches the official domain, check whether the tool config reads stale environment variables or a local cache.

Hermes / QClaw / AutoClaw

Difference: these Agent tools support OpenAI-compatible config directly — no dedicated config file. Fill the three common fields into the tool settings:

API KeyAPIEX_API_KEY, or a custom environment variable the tool supports (fill in the real key value; the variable name needs no copying).
Base URL
Standard (recommended)https://apiex.cc/gateway/v1
Tools appending /v1https://apiex.cc/gateway
Responses APIhttps://apiex.cc/gateway/v1/responses
Model IDprovider/model-name format — see the common config.

API reference

All endpoints are mounted under https://apiex.cc/gateway/v1.

POST

Chat completions

/gateway/v1/chat/completions

OpenAI-compatible chat completion endpoint.

POST

Responses

/gateway/v1/responses

Responses API, used by Codex and similar tools.

GET

Model list

/gateway/v1/models

Returns currently available models and capability info.

POST

Anthropic format

/gateway/v1/messages

Anthropic-compatible messages endpoint for the Claude ecosystem.

Multimodal endpoints

Image, video and reference-image generation open up progressively by model capability. Different models may bill by tokens, image count, resolution, video duration or task spec — prices as labeled in Models.

Text to image

Enter a prompt and get an image task result.

Reference image to image

Upload a reference image and specify generation requirements.

Video generation

Billed by the duration, resolution and task type each model supports.

Responses & reconciliation

apiex stands for auditable billing: every response carries a usage field, invoices are settled by it, and you can verify call by call.

usage example
{
  "id": "chatcmpl-...",
  "model": "openai/gpt-5.2",
  "usage": {
    "prompt_tokens": 18,
    "completion_tokens": 42,
    "total_tokens": 60
  }
}
Billing basisBilled by the token counts in the response usage, at the per-model price labeled in Models (USD / 1M tokens); CNY amounts are estimates only.
Per-call auditThe console Logs page shows token details and charges per request ID, matching the response usage one to one.
Balance & budgetCheck balance, enterprise quota and budget limits on the console Billing page; insufficient balance returns 402.
Streaming callsStreaming (stream: true) calls must pass stream_options: {"include_usage": true} so usage arrives with the final chunk; without it chunks carry no usage and per-call reconciliation is impossible.

Troubleshooting

Each row follows a cause-then-fix order; with an error code, match the status badge first to locate the category.

401

Auth failed

CauseKey wrong, expired, or no balance.

FixCheck the key was copied in full and not deleted; confirm the tool reads the apiex key, not an official one; confirm available balance.

402

Insufficient balance

CauseAccount balance or enterprise quota exhausted.

FixTop up or adjust budget limits on the console Billing page, then retry.

404

URL / model not found

CauseBase URL written as a full path, or a mistyped model ID.

FixSDKs take only the Base URL — they append endpoint paths themselves; always copy model IDs from Models (provider/model-name).

429

Rate limited

CauseConcurrency or frequency limits exceeded.

FixLower the call rate or concurrency; if it persists, check limit settings in the console.

5xx

Server error

CauseTransient upstream or gateway failure.

FixRetry once; for lasting failures check the status page or contact support instead of hammering retries.

Domain

Stale domain

CauseThe tool still reaches the official domain.

FixCheck local environment variables, IDE settings, CLI user-level and project-level configs for stale values.

npm

Install failed

CauseRegistry network or permission issue.

FixTemporarily switch the mirror or fix global directory permissions, then retry.