ClaudeCode.Message.RateLimitEvent (ClaudeCode v0.29.0)

View Source

Represents a rate limit event from the Claude CLI.

Emitted when the session encounters a rate limit. This is common for claude.ai subscription users and provides information about rate limit status and when limits reset.

Fields

  • :rate_limit_info - Map with rate limit details:
    • :status - One of :allowed, :allowed_warning, or :rejected
    • :resets_at - Unix timestamp (ms) when the limit resets (optional)
    • :utilization - Current utilization as a float 0.0–1.0 (optional)
  • :uuid - Message UUID
  • :session_id - Session identifier

JSON Format

{
  "type": "rate_limit_event",
  "rate_limit_info": {
    "status": "allowed_warning",
    "resetsAt": 1700000000000,
    "utilization": 0.85
  },
  "uuid": "...",
  "session_id": "..."
}

Summary

Functions

Creates a new RateLimitEvent from JSON data.

Type guard to check if a value is a RateLimitEvent.

Types

status()

@type status() :: :allowed | :allowed_warning | :rejected

t()

@type t() :: %ClaudeCode.Message.RateLimitEvent{
  rate_limit_info: %{
    status: status(),
    resets_at: integer() | nil,
    utilization: number() | nil
  },
  session_id: String.t(),
  type: :rate_limit_event,
  uuid: String.t() | nil
}

Functions

new(json)

@spec new(map()) :: {:ok, t()} | {:error, atom()}

Creates a new RateLimitEvent from JSON data.

Examples

iex> RateLimitEvent.new(%{
...>   "type" => "rate_limit_event",
...>   "rate_limit_info" => %{"status" => "allowed_warning", "resetsAt" => 1700000000000},
...>   "session_id" => "session-1"
...> })
{:ok, %RateLimitEvent{type: :rate_limit_event, ...}}

iex> RateLimitEvent.new(%{"type" => "assistant"})
{:error, :invalid_message_type}

rate_limit_event?(arg1)

@spec rate_limit_event?(any()) :: boolean()

Type guard to check if a value is a RateLimitEvent.