Menu: Errors

Reference

Errors

Every error the gateway and published endpoints return, and what to do about each.

All errors have the same body, compatible with OpenAI clients:

{
  "error": {
    "message": "Monthly budget of $50.00 reached for this key.",
    "type": "insufficient_quota",
    "code": "insufficient_quota"
  }
}

type is the category below. code is the same or more specific (for example invalid_model_output). Messages for provider and network failures are deliberately generic. The X-Scalaix-Request-Id header identifies the request; include it when you contact support.

StatustypeMeaningWhat to do
400invalid_requestThe request body or a parameter isn't valid.Fix the request. Don't retry.
401invalid_api_keyThe key is missing, unknown, revoked or expired.Check the Authorization header and the key in the console.
402insufficient_quotaThe team is out of credits, or the key's monthly budget can't cover the request's worst case.Buy credits in the console (account menu → Billing), raise the key's budget, or set max_tokens.
403forbiddenThe key's rules don't allow this model, collection, origin, IP range or mode.Change the request or the key's rules.
404not_foundUnknown model, project, collection, endpoint or version.Check the URL and ?version=.
413invalid_requestThe body is too big: over 10 MB for chat, over 1 MB for endpoint calls.Send less: trim history, or pass large documents another way.
422invalid_inputsEndpoint inputs don't match the variables. The message has the path.Fix the inputs. Don't retry.
429rate_limitedOver the key's requests per minute.Wait Retry-After seconds, then retry.
501not_implementedThe feature isn't available yet (for example file variables).Use another approach for now.
502upstream_errorThe provider failed and no fallback model answered.Retry with backoff; add fallback_models.
502invalid_model_output (code)The model's JSON didn't match the schema after one repair.Simplify the schema, add descriptions, or use a stronger model.
504timeoutThe provider didn't answer in time.Retry; lower max_tokens; add fallback models.

Retrying

Retry 429, 502 and 504 with exponential backoff and jitter. Respect Retry-After on 429. Don't retry 400, 401, 403, 404 or 422: the same request fails again.

The OpenAI SDKs retry 429 and 5xx automatically (twice by default). For endpoint calls, a small loop is enough:

import random, time, requests

def call(url, key, inputs, attempts=4):
    for i in range(attempts):
        r = requests.post(url, headers={"Authorization": f"Bearer {key}"}, json={"inputs": inputs}, timeout=90)
        if r.status_code not in (429, 502, 504):
            r.raise_for_status()
            return r.json()
        wait = float(r.headers.get("retry-after", 2 ** i)) + random.random()
        time.sleep(wait)
    r.raise_for_status()