Core concepts

Errors

Request errors, job errors and what to do about each.

There are two kinds of errors: a request the API refuses, which returns an HTTP error, and a job that fails while running, which you read with a normal 200.

Request errors

Every refused request returns the same body:

402 response
{
  "api_version": "v1",
  "error": {
    "code": "insufficient_funds",
    "message": "Available API wallet funds are below the required pre-debit.",
    "retryable": false,
    "details": [
      {
        "field": "max_charge_amount",
        "reason": "insufficient_available_balance"
      }
    ]
  },
  "request_id": "req_5b2f8e1c-7a4d-4c3b-9e6f-1d8a2c7b4e90"
}
FieldMeaning
error.codeA stable code. Branch on this, not on the message.
error.messagePlain English for a person. It can change.
error.retryableWhether sending the same request again, with the same idempotency key, may work.
error.detailsA list of problems with the request, each pointing at a field.
request_idInclude this when you contact support.

Codes

CodeHTTPWhat to do
invalid_request400The request is malformed or has an unknown field or query parameter. error.details names it.
invalid_input400The model input doesn't match its schema. error.details names the field.
idempotency_key_required400Send exactly one Idempotency-Key header.
spend_limit_required400Send max_charge_amount (needed unless the key has a per-request spend limit).
unauthorized401The API key is missing, wrong, revoked or expired.
insufficient_funds402Add funds to your wallet.
account_in_debt402Pay the outstanding balance in the console.
price_limit_exceeded402Raise max_charge_amount or change the input. If the key has a per-request spend limit, that caps it too.
key_budget_exceeded402The key reached its monthly spend cap. Use another key.
account_restricted403The account can't use the API. Contact support.
scope_denied403Use a key with the scope this endpoint needs.
model_not_available403The model isn't sold, or this key is limited to other models.
not_found404Check the ID. A resource that belongs to another account looks the same.
feature_not_found404The API isn't enabled for this account yet.
idempotency_key_conflict409The key was already used for a different request. Use a new key.
quote_already_used409Get a new quote.
quote_mismatch409The job's model or input differs from the quote's. Send the quoted input or get a new quote.
job_not_cancelable409The job already finished.
file_limit_reached409Too many uploads that no job has used yet. Use them or wait for them to expire.
quote_expired410Get a new quote.
payload_too_large413The request body is over 64 KB. Upload media as a file instead of inlining it.
unsupported_media_type415Send Content-Type: application/json.
queue_full429Wait for Retry-After, then retry with the same Idempotency-Key.
rate_limited429Too many requests. Wait for Retry-After, then retry.
ledger_busy503Retry after Retry-After.
service_unavailable503Retry with the same Idempotency-Key. The job may already exist.

Codes marked retryable: true are queue_full, rate_limited, ledger_busy and service_unavailable. A timeout or dropped connection has no body at all: treat it like a 503.

Field details

For 400 errors, each item in details has a field (a dotted path such as input.duration) and a reason. Model input errors also have a message, and some have a limit that shows what is allowed.

details item
{
  "field": "input.duration",
  "reason": "unpriced_value",
  "message": "This duration is not available for this model.",
  "limit": {
    "allowed": [
      5,
      10
    ]
  }
}

Common reasons:

reasonMeaning
requiredA required field is missing.
unknown_fieldThe model doesn't accept this field.
invalid_typeWrong JSON type, such as a string where a number goes.
invalid_valueNot one of the allowed values. See limit.allowed.
out_of_rangeNumber outside limit.min and limit.max.
lengthText is too long or too short. A list with too many or too few items is out_of_range.
invalid_urlNot a public https URL.
unpriced_valueThis value is valid for the model but isn't sold.
unpriced_fieldThis field would add a cost we don't support yet.
must_be_decimal_stringMoney must be a string like "1.000000".
file_not_uploadedThe file_id exists but its bytes were never uploaded.
file_expiredThe file is too close to its 7-day deletion to use. Upload it again.

Job errors

When a job fails, GET /v1/jobs/{id} returns it with status: "failed" and an error. Failed jobs are never charged.

error.codeMeaningTry again?
invalid_inputThe provider rejected the input.Fix the input first.
content_policyThe prompt or input broke the provider's content rules.Not with the same input.
timeoutThe provider took too long.Yes, as a new job.
generation_failedThe model ran but produced nothing usable.Usually, as a new job.
internal_errorSomething went wrong on our side.Yes, as a new job.
queue_expiredThe job waited 15 minutes in your account queue without starting.Yes, when fewer jobs are running.

On a job error, retryable means a new job with the same input may succeed. It never means the old job will be retried. Starting the new job is up to you and is charged separately.

Errors in the clients

The clients raise typed errors that derive from AstorieError. Errors for an HTTP response also carry the fields above plus status, requestId and idempotencyKey. In Python the same fields are request_id and idempotency_key.

ErrorWhen
InvalidRequestError400, 413, 415, 422
AuthenticationError401
PaymentRequiredError402, with InsufficientFundsError as a subclass
PermissionDeniedError403
NotFoundError404
ConflictError409, with IdempotencyKeyConflictError and JobNotCancelableError
GoneError410
RateLimitError429
ServerError5xx
APIConnectionErrorNetwork failure. APITimeoutError for timeouts.
WaitTimeoutErrorwait() ran out of time. The job is still running.
UploadErrorStorage refused a file upload.
DownloadErrordownloadAsset() couldn't fetch a result, for example because it no longer exists.