~/docs/api_reference/errors.md
4,278 bytesยทedit on github โ†’

#Errors

When something goes wrong, the API returns a JSON body in this shape:

json
{
  "error": {
    "type": "rate_limit_exceeded",
    "code": "gremlin_in_the_pipes",
    "message": "too many requests, tall one. come back in 12s.",
    "param": null,
    "retry_after": 12
  }
}

##Error types

HTTPTypeRetryableDescription
400invalid_request_errornoMalformed body, missing fields, unsupported parameter
401authentication_errornoBad / missing / revoked API key
403permission_errornoKey lacks required scope
404not_found_errornoModel/resource doesn't exist
409conflict_errornoConcurrent modification of a resource
422validation_errornoBody parsed but failed validation
429rate_limit_exceededyesToo many requests / tokens / concurrent calls
429quota_exceedednoMonthly billing quota hit. Upgrade or wait.
500server_erroryesGeneric server failure
502upstream_erroryesUnderlying inference cluster unreachable
503service_unavailableyesMaintenance or capacity throttling
503horde_unavailableyesSpecific model tier overloaded โ€” try a different one
504request_timeoutyesInference exceeded timeout (default 60s)

##Codes (gob-flavored)

Every error includes a stable machine-readable code. The message is gob-flavored prose meant for humans/logs โ€” don't parse it, parse the code.

CodeTypeNotes
invalid_api_keyauthentication_error
expired_api_keyauthentication_errorRotated keys expire after 24h
revoked_api_keyauthentication_error
wrong_password_to_caveauthentication_errorAuth header missing/malformed
scope_requiredpermission_error
model_not_foundnot_found_error
context_length_exceededinvalid_request_errorReduce messages or pick a larger-context model
invalid_mining_depthinvalid_request_errorMust be 1โ€“7
gremlin_in_the_pipesrate_limit_exceededRPM limit hit. Includes retry_after
too_many_tokensrate_limit_exceededTPM limit hit
no_treasure_in_hoardquota_exceededMonthly quota gone
cave_collapsedserver_errorGeneric 500 โ€” retry
horde_unavailableservice_unavailable
goblin_distractedserver_errorGeneration aborted mid-stream. Retry.
safety_filter_triggeredinvalid_request_errorInput or output blocked by safety layer

##Retry strategy

For all retryable errors, use exponential backoff with jitter:

python
import time, random
from gpt_gob import GPTGob, GobError

client = GPTGob(api_key="gob-...")

def with_retry(fn, max_attempts=5):
    for attempt in range(max_attempts):
        try:
            return fn()
        except GobError as e:
            if not e.is_retryable or attempt == max_attempts - 1:
                raise
            wait = e.retry_after or (2 ** attempt + random.random())
            time.sleep(wait)

The official SDKs do this automatically with sensible defaults (max_attempts=3, base delay 1s). You can configure or disable it:

python
client = GPTGob(api_key="gob-...", max_retries=5)
javascript
const client = new GPTGob({
  apiKey: process.env.GOB_API_KEY,
  maxRetries: 5,
});

##The `X-Request-Id` header

Every response carries an X-Request-Id header. Include it when contacting support โ€” it's the only way we can trace a specific call through our infrastructure.

text
X-Request-Id: req_8kQm3F9pLxN2vH7w