IsraelGPT API Docs Get an API key

Errors

Every non-200 answer has the same shape, so you can handle errors generally and look at the code only when you need to.

Shape

{
  "error": {
    "code": "invalid_request",
    "message": "\"messages\" must be an array of 1 to 40 messages.",
    "retry_after_seconds": 12
  }
}

retry_after_seconds comes only with 429 (and a Retry-After header with 429 and 503). message is for the developer reading the logs, not for showing to people as it is.

Reference

StatuscodeMeaningRetry?
400invalid_jsonThe body isn’t valid JSONFix the request first
400invalid_requestA field is wrong or unknown; the message says whichFix the request first
401missing_api_keyNo Authorization headerAdd the header
401invalid_api_keyNot a key, or the key doesn’t exist or was revokedCheck your keys on the dashboard
403suspendedThe key’s account is suspended; the message says until when, and whyNo
413payload_too_largeThe body is over 256 KBSend less history
415unsupported_media_typeContent-Type isn’t application/jsonFix the header
429rate_limitedOver a limit: the key’s, the account’s, or the address’sAfter retry_after_seconds
502upstream_unavailableThe model didn’t answerYes, with a short backoff
503capacity_exceededEvery key together is over the shared cap (see Rate Limits)Yes, after a backoff
503maintenanceThe API is switched off for nowLater: Retry-After says when to look again

What isn't an error

A request stopped by the safety checks (someone in crisis, content that breaks the rules) is not an error. It's a normal 200 with flags.crisis or flags.blocked set and a fixed message in reply. See API Reference. Treat a non-200 as the request or the service failing, never as a moderation signal.

4xx and 5xx

A 4xx means something about the request has to change before it will work (the key, the body, or waiting for a limit). A 5xx means the problem is on our side, and the same request may well work on a retry: safe to build a simple retry around. See Examples.