Amarsia
API Reference

Errors

HTTP status codes, error object fields, and practical handling rules.

Error response shape

When a request fails, response generally contains:

{
  "error": {
    "type": "invalid_request_error",
    "message": "content is required",
    "param": "content",
    "code": "missing_required_field"
  }
}

Error object fields

FieldTypeMeaning
typestringHigh-level error category
messagestringHuman-readable explanation
paramstring or nullRelated request field
codestring or nullStable machine-readable code

HTTP status code summary

StatusNameMeaningRecommended action
200OKRequest succeededUse response
400Bad RequestInvalid request body/paramsFix payload
401UnauthorizedMissing/invalid API keyFix key header
403ForbiddenKey valid but no accessCheck permissions
404Not FoundResource or path not foundVerify IDs/path
409ConflictRequest conflicts with existing stateResolve conflict and retry
429Too Many RequestsRate limit reachedRetry with exponential backoff
500/502/503/504Server ErrorsTemporary server issueRetry safely

Error type values

TypeMeaning
api_errorUnexpected server-side error
invalid_request_errorRequest shape or parameters are invalid
auth_errorAuthentication/authorization issue
rate_limit_errorRequest limit exceeded

Retry rules

  • Retry: 429, 5xx, network timeouts
  • Do not retry blindly: 400, 401, 403, 404
  • For streaming errors: retry once, then fallback to regular endpoint