Cheat sheet
401 Unauthorized — Invalid token
Cause. The server didn’t accept your key. Possible reasons:- You’re using the wrong key: it must be a RuAPI key (
sk-...), not an official OpenAI key (sk-...) or Anthropic key (sk-ant-...). OpenAI and RuAPI keys look alike, but only the one from your RuAPI Console works here. - A stray space or newline snuck into the key during copy-paste — a very common one.
- The key is disabled, deleted or expired.
- The key hit its own credit limit (if you set one when creating it). Your overall balance can still be positive — it’s this particular key that’s capped.
- Open Console → API Keys and confirm the key is active, not expired and not over its limit. Copy it again if in doubt.
- Paste the key with no leading/trailing spaces and no line break.
- Make sure the header is
Authorization: Bearer sk-...(OpenAI protocol) orx-api-key: sk-...(Anthropic protocol).
403 — not enough balance
Cause. Your account ran out of funds (or doesn’t have enough for this request). Requests won’t run until you top up. Fix.- Top up in USDT / USDC or by bank card — minimum $5. Crypto is usually credited within 1–5 minutes, card payments within seconds.
- Note: agentic tools (Claude Code, Cline, autonomous agents) and long context burn tokens fast — dozens of requests a minute is normal.
- To avoid draining your whole balance on one project, set a per-key credit limit in Console → API Keys — that key stops at the cap while your others keep working.
404 — wrong URL
Cause. The request went to a path that doesn’t exist. It’s almost always thebase_url, and the right value depends on the protocol:
Fix. Check your
base_url using the table above. Full URL breakdown in the API reference.
503 — model not available (model_not_found)
Cause. Almost always, there is no model with that ID in the catalog. Themodel field must exactly match an ID from the pricing page — hyphens, prefix and letter case included (GLM-5.2 and glm-5.3 are spelled differently; kimi/kimi-k3 needs its prefix). Aliases or “close enough” names won’t work.
The response has "code": "model_not_found", and error.message reads “Model gpt-5 is not available. Check the exact model name on the Pricing page or try again later.”
Fix. Copy the model ID from the pricing page and paste it into model unchanged. If the ID is definitely right, the model is temporarily unavailable — retry in a minute.
429 — Too Many Requests / rate limit
Cause. Too many requests in a short window — either your code is firing them in a burst, or the model provider is temporarily throttling requests. RuAPI also limits how often each account can send requests; normal work, agents included, stays well under that limit. Fix.- Slow down and retry with exponential backoff: 1s, 2s, 4s, 8s…
- Spread the load over time; don’t send hundreds of requests at once.
- For batch jobs, add a small pause between requests or cap the number of parallel workers.
5xx — 500 / 502 / 503 / upstream error
Cause. A temporary failure at the model provider or in the gateway. It’s not your key or your code. (The exception is a503 with the code model_not_found — that’s almost always a typo in the model name, see above.)
Fix.
- Retry after a few seconds — it usually goes through on the second or third attempt.
- Wrap your calls in retry-with-backoff so these blips don’t crash your script.
- If the error sticks around and shows up across different models, email support@ruapi.ai with the
request idfrom the error text.
Streaming cutoffs and timeouts
Long answers (large context, reasoning models, code generation) can take tens of seconds. If the connection drops mid-stream or the client times out — raise thetimeout in your SDK (60–120s or more for heavy requests), make sure no proxy between you and RuAPI is killing long SSE connections, and don’t disable streaming for long responses — streaming is exactly what keeps the request from timing out.
Still stuck?
Email support@ruapi.ai with the error code, the fullerror.message text (including the request id), the model name and the time of the request — and we’ll sort it out fast.
If you’re just getting set up, the Quickstart walks through the key and base_url step by step — most first-request errors come from one of those.