All Auriko errors extend AurikoAPIError. The envelope is canonical (see Errors):
Field
Type
Description
message
str
Human-readable error message
status_code
int
HTTP status code
code
str
Machine-readable error code
type
str
Canonical error type (one of six values)
param
str | None
Parameter that caused the error
request_id / requestId
str
Value of x-request-id on the failing response
retry_after_seconds / retryAfterSeconds
int | None
Retry-After header value (429 / 503 only)
doc_url / docUrl
str | None
Link to the error’s docs page
provider
str | None
Upstream provider that generated the error, when attributable
The SDK provides these typed exception classes:
Exception
HTTP
type
BadRequestError
400 / 413 / 422
invalid_request_error
AuthenticationError
401
authentication_error
PermissionDeniedError
403
permission_error
NotFoundError
404
not_found_error
ConflictError
409
invalid_request_error
RateLimitError
429
rate_limit_error
InternalServerError
500
api_error
APIStatusError
502 / 503 / 504
api_error
APIConnectionError
—
network failure before any response
Dispatch on type + HTTP status for exception class, then on code for precise handling within a class. Never branch on message text; see Errors for retry policy by code.
import osimport asyncioimport openaiclient = openai.AsyncOpenAI( api_key=os.environ["AURIKO_API_KEY"], base_url="https://api.auriko.ai/v1", max_retries=0,)async def make_request_with_backoff(messages, max_retries=3): for attempt in range(max_retries): try: return await client.chat.completions.create( model="gpt-4o", messages=messages, ) except (openai.RateLimitError, openai.APIStatusError) as e: if attempt == max_retries - 1: raise retry_after = e.response.headers.get("Retry-After") wait_time = float(retry_after) if retry_after else 2 ** attempt await asyncio.sleep(wait_time)
TypeScript is inherently async. See the TypeScript tabs in Retry manually.
Side effects and retries: When using tools or multi-step workflows, consider whether retries are safe. A retried request that triggers a tool call may execute the tool twice. For idempotency-sensitive operations, either disable automatic retries (max_retries=0) or implement your own deduplication logic.
You get typed error fields (status_code, code, response_headers) and fine-grained isinstance checks, even when using the OpenAI client.map_openai_error() is Python-only. TypeScript users should use the Auriko SDK directly for typed errors.See OpenAI Compatibility for OpenAI SDK error mapping.