Errors and requests
Error types, retries, request options, and idempotency.
Coming Q4 2026
The SDK ships with AxAgent. The API below may change before launch.
Errors
Every error from the API is an instance of Axerity.APIError. Specific errors extend it.
| Error | When |
|---|---|
Axerity.AuthenticationError | The API key is missing or invalid |
Axerity.RateLimitError | Too many requests |
Axerity.NotFoundError | The resource does not exist |
Axerity.APIError | Any other error from the API |
Every error has these fields:
Prop
Type
Check the specific errors first, then Axerity.APIError.
import Axerity from '@axerity/sdk'
const axerity = new Axerity()
try {
await axerity.runs.create({ agent: agent.id, input: 'Hello' })
} catch (error) {
if (error instanceof Axerity.RateLimitError) {
console.log('retry after', error.retryAfter)
} else if (error instanceof Axerity.APIError) {
console.log(error.status, error.code, error.requestId)
} else {
throw error
}
}Retries
The SDK retries failed requests with exponential backoff on connection errors, 408, 409, 429, and 5xx responses. Set maxRetries on the client to change how many times it retries.
const axerity = new Axerity({ maxRetries: 3 })Request options
Every method accepts request options as its last argument.
Prop
Type
const controller = new AbortController()
const run = await axerity.runs.create(
{ agent: agent.id, input: 'Draft the weekly report' },
{
idempotencyKey: 'weekly-report-2026-10-10',
signal: controller.signal,
timeout: 120_000,
},
)Set timeout on the client to change the default for every request.
Idempotency
Pass an idempotencyKey when you create something you do not want to create twice, such as a run. If the same request is sent again with the same key, it does not start a second run. Use a key that is unique to the action, such as a job name and a date.