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-compatibleexport APIEX_API_KEY="sk-..."
curl https://apiex.ai/gateway/v1/chat/completions \
-H "Authorization: Bearer $APIEX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-max",
"messages": [
{"role": "user", "content": "hi"}
]
}'https://apiex.ai/gateway/v1Authorization: Bearer $APIEX_API_KEYSwap baseURL, API Key and model to integrate.
CLI / AgentConfig for Claude Code, Codex, Cursor and similar tools lives here.
Choosing modelsPick models by scenario, provider, price and latency.
Quick start
1. Create an API Key
- Sign in to the console.
- Open API Key management and create a new key.
- 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
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.ai/gateway/v1/chat/completionsStandard 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 Key | A sk-... key created in the console. Store it in the APIEX_API_KEY environment variable and never commit it to a repository. |
|---|---|
| Base URL | Use https://apiex.ai/gateway/v1 by default; tools that expect the URL before the version segment and append /v1 themselves should use https://apiex.ai/gateway. Both are equivalent. Never put a full endpoint path into the Base URL. |
| Model ID | Use the provider/model-name format from Models; copy it there to avoid typos. |
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["APIEX_API_KEY"],
base_url="https://apiex.ai/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)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.ai/gateway (no /v1) — the CLI appends /v1/messages itself.
Persistent config (recommended)
mkdir -p ~/.claude
cat > ~/.claude/settings.json <<'EOF'
{
"env": {
"ANTHROPIC_BASE_URL": "https://apiex.ai/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_TOKENTemporary access (environment variables)
export ANTHROPIC_BASE_URL="https://apiex.ai/gateway"
export ANTHROPIC_API_KEY="sk-xxxxxxxx"
claude.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.
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.ai/gateway/v1"
env_key = "APIEX_API_KEY"
wire_api = "responses"
requires_openai_auth = false
EOF
export APIEX_API_KEY="sk-xxxxxxxx"
codex/responses returns 404, check wire_api = "responses" and the Base URL first — never put a full endpoint path into base_url.Cursor
- Open Cursor settings and go to Models.
- Add a custom model; use the
provider/model-nameformat from Models for the model ID. - Enable the OpenAI API Key switch and fill in your apiex key.
- Set the Base URL per the common config (
https://apiex.ai/gateway/v1; usehttps://apiex.ai/gatewayif the tool appends /v1 itself). - 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.
export APIEX_API_KEY="sk-xxxxxxxx"
export APIEX_BASE_URL="https://apiex.ai/gateway/v1"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 Key | APIEX_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.ai/gateway/v1Tools appending /v1 https://apiex.ai/gatewayResponses API https://apiex.ai/gateway/v1/responses |
| Model ID | provider/model-name format — see the common config. |
API reference
All endpoints are mounted under https://apiex.ai/gateway/v1.
Chat completions
/gateway/v1/chat/completionsOpenAI-compatible chat completion endpoint.
Responses
/gateway/v1/responsesResponses API, used by Codex and similar tools.
Model list
/gateway/v1/modelsReturns currently available models and capability info.
Anthropic format
/gateway/v1/messagesAnthropic-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.
Abilities
Abilities are pay-per-call atomic capabilities: one call, one line on the bill — sharing the same account, the same key and the same invoice as your model tokens. API / skill / MCP are three doors to the same ability at the same price — doors are free, only the dish is billed.
| REST API | Call /gateway/abilities/{slug}/invoke — one call, one line on the bill; only enabled abilities can be invoked — find slugs and parameter schemas on the Abilities page. |
|---|---|
| MCP server | Endpoint /gateway/mcp; protocol operations (initialize / tools/list / ping) are free. Tools sync with the ability catalog automatically, priced and rate-limited the same as REST. |
| Skill file | Every enabled ability publishes a SKILL.md integration note at /skills/{slug}/SKILL.md for agents to discover and read automatically; humans can follow the SKILL.md links on each Abilities card. |
Minimal REST call
The request body follows the parameter schema of each ability (check the Abilities cards and SKILL.md); replace {slug} with the ability slug before running the snippet.
export APIEX_API_KEY="sk-..."
curl https://apiex.ai/gateway/abilities/{slug}/invoke \
-H "Authorization: Bearer $APIEX_API_KEY" \
-H "Content-Type: application/json" \
-d '{ ... }'A successful response returns result plus billing metadata meta (request_id / latency_ms / price_units, reconcilable call by call); a failure returns error with code and message to locate the cause directly.
{
"ok": true,
"result": { ... },
"meta": {
"ability": "echo",
"request_id": "ab-...",
"latency_ms": 342,
"price_units": 0.000139
}
}One-line MCP setup
Register the MCP server in one line with Claude Code; the auth header uses the same key as REST.
claude mcp add --transport http apiex-abilities https://apiex.ai/gateway/mcp --header "X-API-Key: sk-..."Ability example: fetch_markdown
Take the first production ability on the Abilities page as an example. Send a public URL and get the article as Markdown (default), raw HTML, or page metadata; single-page only — no JS rendering, no site crawling. If extraction fails it falls back to raw HTML with fallback=true, so content is never lost.
export APIEX_API_KEY="sk-..."
curl https://apiex.ai/gateway/abilities/fetch_markdown/invoke \
-H "Authorization: Bearer $APIEX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/article", "mode": "markdown"}'On success result.content carries the body according to the mode; result.metadata reports the final URL, status code, detected charset, original byte size, and truncation / fallback flags — what encoding was fetched and whether it was truncated, inspectable item by item.
{
"ok": true,
"result": {
"final_url": "https://example.com/article",
"title": "Article Title",
"content": "# Body Markdown (links preserved)…",
"metadata": {
"final_url": "https://example.com/article",
"status_code": 200,
"content_type": "text/html; charset=utf-8",
"charset": "utf-8",
"content_length_bytes": 48211,
"extracted_chars": 4180,
"extracted_at": "2026-11-23T12:00:00+00:00",
"truncated": false,
"fallback": false
},
"truncated": false,
"fallback": false,
"message": ""
},
"meta": {
"ability": "fetch_markdown",
"request_id": "ab-...",
"latency_ms": 1204,
"price_units": 0.0007
}
}The MCP server exposes a tool with the same name, fetch_markdown, with identical parameters; register via "One-line MCP setup" above and call it directly from your agent.
Common errors
| 401 Auth failed | API key missing or malformed. Check the key and auth header — same troubleshooting as the model API. |
|---|---|
| 402 Insufficient balance | Blocked by the balance gate (INSUFFICIENT_BALANCE). Top up on the console Billing page and retry. |
| 404 Ability not found | The ability does not exist or is not enabled — both return 404. Verify the slug and availability on the Abilities page. |
| 429 Rate limited | Wait retry_after_ms milliseconds as reported in the error object before retrying; do not retry immediately. |
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.
{
"id": "chatcmpl-...",
"model": "openai/gpt-5.2",
"usage": {
"prompt_tokens": 18,
"completion_tokens": 42,
"total_tokens": 60
}
}| Billing basis | Billed 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 audit | The console Logs page shows token details and charges per request ID, matching the response usage one to one. |
| Balance & budget | Check balance, enterprise quota and budget limits on the console Billing page; insufficient balance returns 402. |
| Streaming calls | Streaming (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.
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.
Insufficient balance
CauseAccount balance or enterprise quota exhausted.
FixTop up or adjust budget limits on the console Billing page, then retry.
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).
Rate limited
CauseConcurrency or frequency limits exceeded.
FixLower the call rate or concurrency; if it persists, check limit settings in the console.
Server error
CauseTransient upstream or gateway failure.
FixRetry once; for lasting failures check the status page or contact support instead of hammering retries.
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.
Install failed
CauseRegistry network or permission issue.
FixTemporarily switch the mirror or fix global directory permissions, then retry.