Skip to content
PluginStats

ai-retry weekly downloads statistics

By zirkelc (3 listings) · npm · AI SDKs

Retry and fallback mechanisms for AI SDK

View on npm Fresh · Oct 17, 2026

ai-retry has 34,789 recorded weekly downloads on npm, a decrease of 34.6% over the past 30 days.

It ranks #634 of 2,251 tracked npm listings by weekly downloads.

Over 90 days, weekly downloads changed by -21.5%.

PluginStats has 543 daily observations since Apr 23, 2025; the latest is from Oct 17, 2026.

Weekly downloads
34,789
Official API · Oct 17, 2026
7-day growth
-35.1%
-18.8K weekly downloads
30-day growth
-34.6%
-18.4K weekly downloads
90-day growth
-21.5%
-9.5K weekly downloads
Rank
#634
Among tracked npm listings

About ai-retry

Retries and fallbacks for the AI SDK

Automatically handle API failures, content filtering, timeouts and other errors by switching between different AI models and providers.

ai-retry wraps a base model with a list of typed retry conditions. When a request fails with an error, or the response is not satisfying, it walks the conditions top-down to find a suitable fallback. It tracks which models have been tried and how many attempts have been made to prevent infinite loops.

Two retry shapes are supported:

• Error-based: the model throws (timeouts, rate limits, API errors). • Result-based: the model returns a successful response that still needs retrying (content filtering, schema mismatch, etc.).

Installation

[!NOTE] Version compatibility:

- Use ai-retry@0.x for AI SDK v5 - Use ai-retry@1.x for AI SDK v6 - Use ai-retry@2.x for AI SDK v7

Usage

[!NOTE] The condition API is the recommended way to configure retries. Existing code keeps working:

- The root createRetryable export and the function-style retryables (contentFilterTriggered, requestTimeout, …) are deprecated but still functional. Prefer createRetryableModel from ai-retry/-model — it is typed for that family and resolves gateway strings for it.

See the migration guide to move existing code to the condition API.

Create a retryable model with a base model and a list of conditions plus the action to take when a condition matches.

This also works with embedding models and image models, each through their own entry point:

Entry points

Pick the entry point that matches the model you pass to createRetryableModel. Each module exposes the helpers that make sense for that model family already typed for it, so no manual type annotations are needed.

| Entry point | For models passed to |

| ai-retry/language-model | generateText, generateObject, streamText, streamObject | | ai-retry/embedding-model | embed, embedMany | | ai-retry/image-model | generateImage |

Each entry point re-exports createRetryableModel plus every condition for that family. The condition helpers can also be imported from the dedicated /conditions subpath:

Vercel AI Gateway

You can pass a model as a string and it will be resolved through the default gateway provider instance from the AI SDK. Each entry point resolves strings to its own model family, so the string is typed against that family's gateway model ids.

Embedding and image entry points accept gateway strings too, resolved against their respective families:

Retries

The retries array holds the things ai-retry tries, in order, when a request fails or a result needs retrying. There are two kinds:

• Fallbacks are model instances (or gateway strings). They always match and are used as plain fallbacks. • Conditions are typed predicates produced by helpers like error() or httpStatus() and finalized with a .switch() or .retry() action. They only fire when their predicate matches.

You can think of retries as a big if-else chain — each condition is an if branch matching some error/result, and each fallback is an else branch matching anything left over. Order matters: the array is evaluated top-down until one matches.

Fallbacks

A fallback is a plain model instance (or gateway string) in retries. It always matches, so it acts as a catch-all: when no earlier condition fired, the next fallback model is tried. Each fallback is attempted once by default; use the object form to pass options like maxAttempts.

Fallbacks are tried in order. Once all of them are exhausted, a RetryError is thrown (see All retries failed).

Conditions

A Condition is a typed predicate over a retry context. The library ships two low-level builders (error() and result()) plus high-level helpers built on top of them. Every condition is finalized with one of two terminal actions, .switch() or .retry(), which turn it into a retryable.

Universal conditions

These are available from all three entry points (language-model, embedding-model, image-model).

| Helper | Kind | Matches when |

| error(predicate) | low-level | The current attempt failed and predicate(err, ctx) returns true | | error.isInstance(cls) | low-level | The error is an instance of cls (prefers cls.isInstance, else instanceof) | | error.isRetryable(flag) | low-level | APICallError.isRetryable === flag (default true) | | error.statusCode(...patterns) | low-level | Numbers match the status code exactly; regex matches the stringified code | | error.message(...patterns) | low-level | Substring (case-insensitive) or regex match against the error message | | error.isTimeout() | low-level | Error.name === 'TimeoutError' (AbortSignal.timeout() fired) | | error.isAbort() | low-level | Error.name === 'AbortError' (manual controller.abort()) | | httpStatus(...patterns) | high-level | Numbers match the status code; strings match the message; regex matches either | | timeout() | high-level | Alias for error.isTimeout() | | aborted() | high-level | Alias for error.isAbort() |

error(predicate)

Takes any predicate over the failed attempt's error. Its namespace bundles the common matchers: isInstance (matches an error class), isRetryable (defaults to true), statusCode (numbers or regex), message (case-insensitive substring or regex), and isTimeout / isAbort (match AbortSignal.timeout() firing vs a manual controller.abort()). The pattern matchers accept any number of patterns and match if any matches.

httpStatus(...patterns)

Matches an APICallError by status code (numbers), message substring (strings), or either (regex). Mix any combination in one call.

timeout()

Alias for error.isTimeout() — matches AbortSignal.timeout() firing (Error.name === 'TimeoutError'); pass a fresh timeout to the action so the fallback gets its own deadline.

aborted()

Alias for error.isAbort() — matches a manual controller.abort() (Error.name === 'AbortError').…

Description from the npm listing.

  • ai
  • ai-sdk
  • fallback
  • retry

Where ai-retry sits in the listing

Each band is one page of 20. Weekly downloads on a log scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

All npm2,248 listings · 113 pages · page 32, #14 (overall #634)
All npm: every listing in weekly downloads order
PNG SVG
AI SDKs249 listings · 13 pages · page 2, #18 (overall #38)
AI SDKs: every listing in weekly downloads order
PNG SVG

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

ai-retry weekly downloads on npm, last 90 days: 34,789 weekly downloads as of Oct 17, 2026, -21.5% over 90 days.ai-retryWeekly downloads on npm · Last 90 days34,789downloads / week-21.5% over 90 days30K40K50K60K70K80KJul 19Aug 3Aug 18Sep 2Sep 17Oct 2Oct 17downloads / weekobservedarchived (Internet Archive)no observationsJul 20, 2026 – Oct 17, 2026 · 90 observations · Updated Oc…pluginstats.com
ai-retry weekly downloads on npm, last 90 days: 34,789 weekly downloads as of Oct 17, 2026, -21.5% over 90 days.
PNG SVG

7/30/90-day growth

ai-retry weekly downloads growth on npm: -35.1% over 7 days, -34.6% over 30 days, -21.5% over 90 days.ai-retryWeekly downloads growth on npm34,789downloads / week now7-day growth-18,847 weekly downloads-35.1%30-day growth-18,406 weekly downloads-34.6%90-day growth-9,524 weekly downloads-21.5%Growth vs. nearest observation to each baseline date · Updated Oct 17, 2026pluginstats.com
ai-retry weekly downloads growth on npm: -35.1% over 7 days, -34.6% over 30 days, -21.5% over 90 days.
PNG SVG

Ranking history

ai-retry npm ranking history: currently #634 (by weekly downloads).ai-retrynpm ranking · by weekly downloads · Last 90 days#634current rank#200#300#400#500#600#700Jul 20Aug 4Aug 19Sep 3Sep 18Oct 3Oct 18rankOct 17, 2026 – Oct 18, 2026 · 2 observations · Updated Oct 17, 2026pluginstats.com
ai-retry npm ranking history: currently #634 (by weekly downloads).
PNG SVG

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Recent observations

Full history (543)
Recent weekly downloads observations for ai-retry
Date (UTC)Weekly downloadsChange vs. previous
34,789-5.9K
40,723+3.4K
37,368-12K
49,408-11K
60,3950
60,395+3.3K
57,108+3.5K
53,636+2K
51,665+2.1K
49,599+403
49,196+15
49,181-11.3K
60,524-2.4K
62,899—

Similar npm AI SDKs plugins

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/ai-retry. First seen Oct 16, 2026; last successful collection Oct 18, 2026. See the methodology.