ModelsPricingAPI keys
  • Overview
  • Quickstart
  • Authentication
  • Errors and retries
  • Limits and billing
  • JavaScript client

Reference

Errors and retries

Every error is an HTTP status and one error object. Branch on its code, show its message, quote its request_id to support.

Error format

400 Bad Request
{
  "error": {
    "code": "invalid_request",
    "message": "Invalid request body.",
    "request_id": "req_0ee311b4334e4b118a94c7d1c48577fd",
    "category": "validation",
    "retryable": false,
    "retry_after_seconds": null,
    "next_action": "fix_input",
    "details": {
      "errors": [
        {
          "path": "prompt",
          "loc": [
            "prompt"
          ],
          "message": "must have required property 'prompt'",
          "type": "required"
        }
      ]
    }
  }
}
FieldMeaning
codeStable and machine-readable. Branch on this, not on the message.
messageFor people.
request_idAlso in the x-sume-request-id header.
retryabletrue when the same request can succeed later.
retry_after_secondsHow long to wait first, when known; also the retry-after header.
next_actionfix_input, authenticate, retry, inspect_events…
detailsExtra facts, such as the failing fields in details.errors[].

Codes

StatuscodeMeaningRetry
400bad_requestThe body is not valid JSON.No, fix the body
400invalid_requestA field is missing or wrong; details.errors[] names it.No, fix the field
401unauthorizedNo key, or the key is wrong or revoked.No
402insufficient_creditsThe balance cannot cover the price; details has required_usd and available_usd.After a top-up
402organization_wallet_not_provisionedA team workspace has no funded balance yet.After a top-up
403insufficient_scopeThe key lacks the scope this route needs.No
404not_foundNo such job or model in your workspace.No
409idempotency_conflictThe Idempotency-Key was used for a different request.No, use a new key
409job_not_completedYou read a result before the job finished.Yes, poll first
409job_not_cancelableGeneration has started.No
413payload_too_largeThe request body is too big.No
429queue_fullYour workspace has as many jobs in flight as it may.After a job ends
429rate_limitedToo many requests for this key in the window.Yes, after retry-after
500internal_errorA fault on Sume's side.Yes, with backoff
503database_busyA short overload.Yes, after retry-after

Retrying safely

  • Retry reads (status, result, list) after a network error, a 429 or a 5xx, with exponential backoff and jitter. Honour retry-after.
  • Retry a generate request only with the same Idempotency-Key.
  • Do not retry 401, 403, 404 or a 400 you have not fixed.

Idempotency

A network error after a submit leaves you unsure whether the job exists. Send an Idempotency-Key on every generate request and reuse it on retry:

Header
Idempotency-Key: 9816bc88-9791-43a1-86c2-876dc7c544e8
  • 1–255 printable ASCII characters. A UUID per request is the simple choice.
  • The same key with the same body returns the original job with idempotency_hit: true, charged once.
  • The same key with a different body answers 409 idempotency_conflict.

Failed jobs

A job that ends failed is not an HTTP error. The submit succeeded; the job's error object (same fields as above) says what went wrong, and its price is refunded. A model refusing a prompt on content grounds reports public_reason: "content_policy_rejected".

Related

  • Limits and billing
  • Jobs and polling
  • Authentication

On this page

  • Error format
  • Codes
  • Retrying safely
  • Idempotency
  • Failed jobs