RateLimitException class

Exception thrown when rate limited (HTTP 429).

This exception includes retry timing information when available.

Example

try {
  await client.chat.completions.create(...);
} on RateLimitException catch (e) {
  print('Rate limited. Retry after: ${e.retryAfter}');
  if (e.retryAfter != null) {
    await Future.delayed(e.retryAfter!);
    // Retry the request
  }
}
Inheritance
Annotations
  • @immutable

Constructors

RateLimitException({required String message, String? type, String? code, String? param, String? requestId, Map<String, dynamic>? body, Duration? retryAfter, Object? cause})
Creates a new RateLimitException.
const

Properties

body Map<String, dynamic>?
The raw response body, if available.
finalinherited
cause Object?
The underlying cause of this exception, if any.
finalinherited
code String?
The error code returned by the API.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
message String
A human-readable description of the error.
finalinherited
param String?
The parameter that caused the error, if applicable.
finalinherited
requestId String?
The request ID for debugging purposes.
finalinherited
retryAfter Duration?
The recommended duration to wait before retrying.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int
The HTTP status code returned by the API.
finalinherited
type String?
The error type returned by the API (e.g., 'invalid_request_error').
finalinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited