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.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"}
]
}'https://apiex.cc/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.cc/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.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 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.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)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)
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_TOKENTemporary access (environment variables)
export ANTHROPIC_BASE_URL="https://apiex.cc/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.cc/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.cc/gateway/v1; usehttps://apiex.cc/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.cc/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.cc/gateway/v1Tools appending /v1 https://apiex.cc/gatewayResponses API https://apiex.cc/gateway/v1/responses |
| Model ID | provider/model-name format — see the common config. |
API reference
All endpoints are mounted under https://apiex.cc/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.
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.