Exceptions
SDK exception types and error codes.
Exception Hierarchy
All SDK exceptions inherit from NoukaiError:
NoukaiError
Base class for all Noukai SDK exceptions.
Attributes:
code(string): Error code for programmatic dispatchmessage(string): Human-readable error messagestatusCode(number | undefined): HTTP status code (if applicable)
Example:
AuthenticationError
API key is invalid, missing, or expired.
Code: authentication_error
HTTP Status: 401
Causes:
- No API key provided
- Invalid API key prefix (not starting with
nk_) - API key is revoked or expired
Example:
PermissionDeniedError
User lacks permission to access the flow.
Code: permission_denied
HTTP Status: 403
Causes:
- Flow is private and user doesn't have access
- User role doesn't allow flow execution
Example:
FlowNotFoundError
Flow doesn't exist or was deleted.
Code: flow_not_found
HTTP Status: 404
Causes:
- Flow slug is incorrect
- Flow was deleted
- Flow is in a different organization/project
Example:
InsufficientCreditsError
Account has no remaining credits.
Code: insufficient_credits
HTTP Status: 402
Causes:
- Account balance is zero
- Credits expired
Example:
RateLimitError
Request rate limit exceeded.
Code: rate_limit_exceeded
HTTP Status: 429
Causes:
- Too many requests in a short time
- Concurrent request limit exceeded
Example:
APITimeoutError
Request timed out.
Code: api_timeout
HTTP Status: 504
Causes:
- Network latency
- Noukai service slow
- Request timeout exceeded
Note: The SDK automatically retries once on timeout. This exception means both attempts failed.
Example:
APIConnectionError
Connection to Noukai failed.
Code: api_connection
HTTP Status: N/A
Causes:
- Network unreachable
- DNS resolution failed
- TLS handshake failed
Example:
FlowExecutionError
Flow execution failed.
Code: flow_execution_error
HTTP Status: 500
Causes:
- LLM provider error
- Step execution error
- Invalid flow configuration
Attributes:
details(object | undefined): Additional error details from the flow
Example:
ToolCallLimitError
Tool calls exceeded retry limit.
Code: tool_call_limit
HTTP Status: N/A
Causes:
- Tool execution failed repeatedly
- All retries exhausted
Attributes:
toolCallId(string | undefined): ID of the failing tool callattemptCount(number | undefined): Number of attempts made
Example:
Error Codes Reference
| Exception | Code | HTTP | When to handle |
|---|---|---|---|
AuthenticationError | authentication_error | 401 | Check API key setup |
PermissionDeniedError | permission_denied | 403 | User role / flow access |
FlowNotFoundError | flow_not_found | 404 | Verify flow slug |
InsufficientCreditsError | insufficient_credits | 402 | Billing / top-up |
RateLimitError | rate_limit_exceeded | 429 | Implement backoff |
APITimeoutError | api_timeout | 504 | Retry manually |
APIConnectionError | api_connection | — | Check network |
FlowExecutionError | flow_execution_error | 500 | Debug flow config |
ToolCallLimitError | tool_call_limit | — | Fix tool handler |