OpenAI-compatible pattern
Many tools only need base URL + API key + model. Prefer flash / pro.
HTTP
Python (requests)
VIP named model
After VIP is active, set model to a named id (see VIP list).
This is the simple path that works today. More SDK-style examples will be added over time.
Prerequisites
- Python 3.8 or newer with the
requestslibrary, or any HTTP client in another language. - An AI24X API key exposed as
AI24X_API_KEY. Reading it withos.environkeeps the secret out of your source file. - The endpoint
https://api.ai24x.com/v1/chat/runfor the simple prompt form shown above, orhttps://api.ai24x.com/v1/chat/completionsif you prefer the OpenAI-style messages array.
Check the status before you parse
An error response still carries a status code, so branch on it before touching the body:
Pass an explicit timeout on every call. Without one, a stalled connection can occupy a worker thread indefinitely.
Choosing a tier
Each request names a model. flash suits high-volume, forgiving work such as classification, extraction and summarising user input. Move a call to pro when it genuinely needs deeper reasoning or a longer context. Named VIP models use a vip- prefix, for example vip-kimi, and only resolve once VIP access is active on the account.
Because the request shape does not change between tiers, you can surface the tier as a configuration value and adjust your cost profile without editing calling code.
Common errors and fixes
- 401 Unauthorized — the key is missing or wrong. Confirm
AI24X_API_KEYis set in the environment that runs the process, not only in your shell. - 402 / insufficient credits — top up the AI24X credit balance, then repeat the identical request.
- 400 Bad Request — the payload was not valid JSON. Pass a Python dict through
json=rather than building a string by hand. - 429 Too Many Requests — you are sending faster than your plan allows. Reduce concurrency or add a short delay between calls.
- Requests hang, then fail — no timeout was set, or an egress proxy is intercepting traffic. Set
timeoutand check the proxy configuration on the host.
Troubleshooting order
- Reproduce the call with curl to separate a key or network problem from a code problem.
- Print
r.status_codeand the first few hundred characters ofr.text. - Confirm the key is present in the environment that runs the process.
- Confirm the payload serialises as you expect.
- Only then look at timeouts and proxy settings.
OpenClaw · VIP named models · Docs · Pricing
Gateway guides: What is an AI gateway · OpenAI-compatible API · Pricing · Start free