Integrations

curl → AI24X

Fastest way to verify your key and balance from any machine.

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

  • curl 7.60 or newer. Every current macOS, Linux and Windows 10+ build qualifies; run curl --version to confirm.
  • jq installed 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 example export 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 model at flash unless 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_KEY is 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 cmd you must escape the inner double quotes instead. Use --data-binary @body.json to 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

  1. Add -w "\n%{http_code}\n" so the status code is always visible.
  2. Check the key is exported in the current shell.
  3. Re-check the quoting of the JSON body for your platform.
  4. Re-run with -v to see the request headers and the start of the response.
  5. Move the same command to a different host to rule out local network filtering.

HTTP / Python · Node.js · Docs