Skip to content

APIError

Sub classes

Name Children Inherits
AuthenticationError
clawd_code_sdk._errors
Raised when API authentication fails (401).
    BillingError
    clawd_code_sdk._errors
    Raised when there's a billing issue with the API account.
      RateLimitError
      clawd_code_sdk._errors
      Raised when API rate limits are exceeded (429).
        InvalidRequestError
        clawd_code_sdk._errors
        Raised when the API request is invalid (400).
          ServerError
          clawd_code_sdk._errors
          Raised when the API server encounters an error (500/529).

            Base classes

            Name Children Inherits
            ClaudeSDKError
            clawd_code_sdk._errors
            Base exception for all Claude SDK errors.

            ⋔ Inheritance diagram

            graph TD
              3485684694["_errors.APIError"]
              2055642102["_errors.ClaudeSDKError"]
              1615621424["builtins.Exception"]
              3224121899["builtins.BaseException"]
              2751680898["builtins.object"]
              2055642102 --> 3485684694
              1615621424 --> 2055642102
              3224121899 --> 1615621424
              2751680898 --> 3224121899

            🛈 DocStrings

            Bases: ClaudeSDKError

            Base exception for Anthropic API errors.

            This exception is raised when the API returns an error response that was previously returned as a text message. Subclasses provide more specific error types for programmatic handling.

            Attributes:

            Name Type Description
            error_type

            The type of API error (e.g., "rate_limit", "invalid_request").

            message

            The error message from the API.

            model

            The model that was being used when the error occurred.

            Source code in src/clawd_code_sdk/_errors.py
            class APIError(ClaudeSDKError):
                """Base exception for Anthropic API errors.
            
                This exception is raised when the API returns an error response that was
                previously returned as a text message. Subclasses provide more specific
                error types for programmatic handling.
            
                Attributes:
                    error_type: The type of API error (e.g., "rate_limit", "invalid_request").
                    message: The error message from the API.
                    model: The model that was being used when the error occurred.
                """
            
                def __init__(
                    self,
                    message: str,
                    error_type: APIErrorType,
                    model: Model | None = None,
                ) -> None:
                    self.error_type = error_type
                    self.model = model
                    super().__init__(message)
            

            :fa-brands-github: Show source on GitHub