Error Classes
The SDK provides typed error classes for common error scenarios. All errors extend the base APIError class.
import Reminix, { APIError, AuthenticationError, NotFoundError, RateLimitError } from "@reminix/sdk"
APIError (Base)
All SDK errors extend APIError. Catch this to handle any API error.
try {
const response = await client.agents.invoke("my-agent", {
input: { prompt: "Hello" },
})
} catch (error) {
if (error instanceof APIError) {
console.log(error.status) // HTTP status code
console.log(error.message) // Error message
console.log(error.body) // Full error response body
}
}
Specific Error Classes
| Error Class | Status Code | Description |
|---|
AuthenticationError | 401 | Invalid or missing API key |
NotFoundError | 404 | Agent or resource not found |
RateLimitError | 429 | Too many requests |
APIError | Other | Any other API error |
Common Patterns
Use specific error classes to handle different failure modes appropriately.
import Reminix, { APIError, NotFoundError, AuthenticationError } from "@reminix/sdk"
const client = new Reminix({ apiKey: "your-api-key" })
try {
const response = await client.agents.invoke("my-agent", {
input: { prompt: "Hello" },
})
} catch (error) {
if (error instanceof AuthenticationError) {
console.log("Check your API key")
} else if (error instanceof NotFoundError) {
console.log("Agent not found — check the name")
} else if (error instanceof APIError) {
if (error.status === 502) {
console.log("Agent runtime error — check execution logs")
} else if (error.status === 504) {
console.log("Agent timed out")
} else {
console.log(`API error: ${error.status} ${error.message}`)
}
}
}
Always catch specific error classes before the base APIError to ensure proper handling of known error types.
Retry Pattern
Implement exponential backoff for rate limits and transient server errors.
import Reminix, { APIError, RateLimitError } from "@reminix/sdk"
async function invokeWithRetry(
client: Reminix,
agentName: string,
input: Record<string, unknown>,
maxRetries = 3
) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
return await client.agents.invoke(agentName, { input })
} catch (error) {
if (error instanceof RateLimitError && attempt < maxRetries - 1) {
await new Promise((r) => setTimeout(r, 2 ** attempt * 1000))
} else if (error instanceof APIError && error.status >= 500 && attempt < maxRetries - 1) {
await new Promise((r) => setTimeout(r, 2 ** attempt * 1000))
} else {
throw error
}
}
}
}
Only retry on rate limits (429) and server errors (5xx). Retrying on client errors (4xx) other than 429 will always produce the same result.
Next steps
Errors
Error format, status codes, and execution metadata.
Troubleshooting
Common failures and how to diagnose them.
invoke()
Back to the invoke reference.
chat()
Back to the chat reference.