Errors & Retries
Handle SDK exceptions with typed error codes and automatic retry logic.
The SDKs raise typed exceptions for different failure modes. Handle them by exception type or via the .code attribute.
Exception hierarchy
All SDK exceptions inherit from NoukaiError:
Catching exceptions
Catch by type:
Error codes
Each exception has a .code attribute for programmatic dispatch:
Code reference
| Exception | Code | HTTP | Meaning |
|---|---|---|---|
AuthenticationError | authentication_error | 401 | API key invalid/missing |
PermissionDeniedError | permission_denied | 403 | User lacks access |
FlowNotFoundError | flow_not_found | 404 | Flow doesn't exist |
InsufficientCreditsError | insufficient_credits | 402 | Account out of credits |
RateLimitError | rate_limit_exceeded | 429 | Rate limited |
APITimeoutError | api_timeout | 504 | Request timed out |
APIConnectionError | api_connection | — | Connection failed |
FlowExecutionError | flow_execution_error | 500 | Flow execution failed |
ToolCallLimitError | tool_call_limit | — | Tool call limit exceeded |
Automatic retries
The SDK automatically retries on transient errors (5xx, timeouts):
- Retry condition: 5xx status code or timeout
- Retry limit: 1 retry by default
- Backoff: Exponential backoff with jitter (100ms → 200ms)
- Non-retryable: 4xx errors (auth, not found, etc.) are not retried
Example: A request that times out is retried once. If it times out again, APITimeoutError is raised.
Controlling retries
The SDK uses a fixed retry policy (1 retry, exponential backoff). To customize:
Error details
Exceptions include structured error details:
Handling tool call errors
Tool calls can fail if the flow hits its retry limit:
Common errors and solutions
FlowNotFoundError
Solution: Verify the flow slug in Noukai Console.
AuthenticationError
Solution: Check the API key is set correctly.
InsufficientCreditsError
Solution: Add credits to your account.
RateLimitError
Solution: Implement exponential backoff or contact support.
APITimeoutError
Solution: Retry manually or check Noukai status page.
Logging errors
Enable logging to see detailed error information:
Next steps
- Tracing: See Tracing & debugging