class OpenRouterErrorLangChainError<this>Base error for all OpenRouter API errors.
Subclasses (OpenRouterAuthError, OpenRouterRateLimitError) represent specific failure modes. Use the static fromResponse factory to let the library pick the right subclass from an HTTP response, or throw this class directly for generic API failures.
Type-check errors with OpenRouterError.isInstance(err) rather than
instanceof ā this avoids cross-realm / duplicate-package pitfalls.
HTTP or API error code, if available.
Additional error metadata returned by the API, if available.
Creates a typed error from an HTTP Response.
Attempts to parse the body as JSON (OpenRouter's standard
{ error: { message, code, metadata } } shape). Falls back to the
raw HTTP status text when the body is missing or unparseable.
Status-code mapping: