1) Set your key
export AI24X_API_KEY="sk-your-key"
2) Call flash
curl -sS -X POST "https://api.ai24x.com/v1/chat/run" \
-H "X-API-Key: $AI24X_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"Hello","model":"flash","max_tokens":120}'
3) Prefer pro or VIP name
# model: "pro" or "vip-kimi" (VIP required)
Expect HTTP 200 and a text field in JSON. 401 = bad key; 402 = top up credits.
4) Read the response
Piping the output through jq makes the reply readable and turns a truncated response into an obvious error:
# pretty-print the full JSON payload
curl -sS -X POST "https://api.ai24x.com/v1/chat/run" \
-H "X-API-Key: $AI24X_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"Hello","model":"flash","max_tokens":120}' | jq .
# print only the assistant text
curl -sS -X POST "https://api.ai24x.com/v1/chat/run" \
-H "X-API-Key: $AI24X_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"Hello","model":"flash","max_tokens":120}' | jq -r '.text'
Run the first form once to see the exact shape your account returns, then switch to the second in scripts. Add -w "\n%{http_code}\n" to print the status code next to the body.
Prerequisites
curl7.60 or newer. Every current macOS, Linux and Windows 10+ build qualifies; runcurl --versionto confirm.jqinstalled if you want the formatted output above. It is optional but makes failures far easier to read.- An AI24X API key exported as
AI24X_API_KEY, for exampleexport AI24X_API_KEY="sk-your-key".
Scenario cheat-sheet
- Smoke-test a new key — the two-line request above is the fastest possible check.
- Bulk jobs — loop in a shell script and keep
modelatflashunless output quality demands more. - Debugging a client library — capture the exact request with
-v, then replay it in curl to prove where the difference is. - Verifying from a server with no SDK — curl needs nothing beyond a shell, which is why it is the reference implementation for every other guide here.
Common errors and fixes
- 401 Unauthorized —
$AI24X_API_KEYis unset or stale. Echo it in the same shell you run curl from; variables do not survive a new terminal. - 402 / insufficient credits — top up the AI24X credit balance, then repeat the identical command.
- 400 Bad Request — almost always quoting. On bash wrap the JSON in single quotes; on Windows
cmdyou must escape the inner double quotes instead. Use--data-binary @body.jsonto sidestep the quoting rules entirely. - 429 Too Many Requests — you are issuing calls faster than your plan allows. Space them out rather than looping flat out.
- "Empty reply from server" — a proxy or firewall is dropping the connection. Try the same command from another network to confirm.
Troubleshooting order
- Add
-w "\n%{http_code}\n"so the status code is always visible. - Check the key is exported in the current shell.
- Re-check the quoting of the JSON body for your platform.
- Re-run with
-vto see the request headers and the start of the response. - Move the same command to a different host to rule out local network filtering.
HTTP / Python · Node.js · Docs
Gateway guides: What is an AI gateway · OpenAI-compatible API · Pricing · Start free