Skip to content
PluginStats

ai-retry weekly downloads statistics

By zirkelc (4 listings) · npm · AI SDKs

Retry and fallback mechanisms for AI SDK

View on npm Fresh · Dec 6, 2026

ai-retry has 45,039 recorded weekly downloads on npm, a decrease of 46.4% over the past 30 days, ranking #812 of 3,247 tracked listings.

Weekly downloads
45,039
Official API · Dec 5, 2026
7-day growth
+18.8%
+7.1K weekly downloads
30-day growth
-46.4%
-39K weekly downloads
90-day growth
-26.4%
-16.1K weekly downloads
Rank
#812
▲ 14 in 7 days

About ai-retry

<div align='center'> <picture> <source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.png" /> <source media="(prefers-color-scheme: light)" srcset="assets/logo-light.png" /> <img src="assets/logo-light.png" alt="ai-retry logo" width="320" /> </picture> <p align="center"> Retries and fallbacks for the AI SDK <br/> by <a href="https://x.com/zirkelc">@zirkelc</a> </p> <p align="center"> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/github/license/zirkelc/ai-retry" alt="License"></a> <a href="https://www.npmjs.com/package/ai-retry"><img src="https://img.shields.io/npm/dw/ai-retry" alt="Weekly downloads"></a> <a href="https://www.npmjs.com/package/ai-retry"><img src="https://img.shields.io/npm/dt/ai-retry" alt="Total downloads"></a> <a href="https://github.com/zirkelc/ai-retry"><img src="https://img.shields.io/github/stars/zirkelc/ai-retry" alt="GitHub stars"></a> </p> </div>

ai-retry handles API failures, content filters, timeouts and other errors. It retries the request, or switches to a different model or provider.

You declare a list of typed conditions, for example httpStatus(529), finishReason('content-filter') or timeout(). Each condition ends with an action. .retry() tries the same model again, and .switch() tries a fallback model. When a request fails, or succeeds with a bad result, ai-retry checks the list from top to bottom and uses the first match. It counts attempts per model, so a chain cannot loop.

ai-retry covers two kinds of failure:

  • Error-based: The model throws, for example on a timeout, a rate limit or an API error.
  • Result-based: The response is successful but not usable, for example on a content filter, a schema mismatch or empty output.

Features

  • Two layers: Retry the model request, or run the whole AI SDK call again.
  • Typed conditions: Match errors and results with error(), httpStatus(), finishReason(), timeout(), result() and others.
  • Retry or switch: Try the same model again, or switch to a different model.
  • Fallbacks: Give a list of models or providers to try in sequence.
  • Timeouts: Recover a request or a stream that times out.
  • Streaming: Recover a stream that fails before the first content part arrives.
  • Telemetry: Get an OpenTelemetry span for each request and each attempt.

Two layers

ai-retry has the same retry system at two points of the AI SDK call chain. The point decides which failures a retry can recover.

Retryable model

createRetryableModel wraps a model instance. The retry runs inside the doGenerate, doStream and doEmbed methods of the model. You create it once and give it to any function that takes a model parameter, for example generateText, streamText or embed.

sequenceDiagram
    participant You as your code
    create participant RM as createRetryableModel()
    participant SDK as generateText()

    You->>RM: createRetryableModel({ model: gpt-5,retries: [httpStatus(529).switch(opus-5)] })
    participant M as openai('gpt-5')
    participant F as anthropic('opus-5')

    You->>SDK: generateText({ model: retryableModel, prompt })
    activate SDK
    SDK->>RM: doGenerate(options)
    activate RM

    Note over M: attempt 1
    RM->>M: doGenerate(options)
    M-->>RM: ✗ APICallError 529
    Note over RM: httpStatus(529) matches<br/>switch to fallback model

    Note over F: attempt 2
    RM->>F: doGenerate(options)
    F-->>RM: ✓ result

    RM-->>SDK: ✓ result
    deactivate RM
    SDK-->>You: ✓ result
    deactivate SDK

The retryable model is below the call (generateText, streamText, …). It sees provider errors and raw results, but it cannot see the arguments of the call, such as a timeout argument or an inbound abortSignal. When one of those fires, the AI SDK stops the call and discards the result of any retry below it.

Retryable call

retryableGenerateText and the other retryable functions wrap the function call itself. Each attempt is a new call to generateText, streamText or another function, with its own abort signal. Thus a retry can also recover a timeout.

sequenceDiagram
    participant You as your code
    participant RC as retryableGenerateText()
    participant SDK as generateText()
    participant M as openai('gpt-5')
    participant F as openai('gpt-5-mini')

    You->>RC: retryableGenerateText({ model, prompt, timeout: { totalMs }, retry })
    activate RC

    RC->>SDK: generateText({ model: gpt-5, … })
    activate SDK
    Note over RC,SDK: attempt 1
    SDK->>M: doGenerate(options)
    Note over M: model stalls...
    Note over SDK: timeout fires <br/>call is aborted
    SDK-->>RC: ✗ TimeoutError
    deactivate SDK

    Note over RC: timeout() matches<br/>re-run the full call

    RC->>SDK: generateText({ model: gpt-5-mini, … })
    activate SDK
    Note over RC,SDK: attempt 2
    SDK->>F: doGenerate(options)
    F-->>SDK: ✓ result
    SDK-->>RC: ✓ result
    deactivate SDK

    RC-->>You: ✓ result
    deactivate RC
Recovery matrix…

Description from the npm listing.

  • ai
  • ai-sdk
  • fallback
  • retry

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

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

Adoption over time

ai-retry weekly downloads on npm, last 90 days: 45,039 weekly downloads as of Dec 5, 2026, -26.4% over 90 days.ai-retryWeekly downloads on npm · Last 90 days45,039downloads / week-26.4% over 90 days020K40K60K80K100K120KSep 6Sep 21Oct 6Oct 21Nov 5Nov 20Dec 5downloads / weekobservedarchived (Internet Archive)no observationsSep 7, 2026 – Dec 5, 2026 · 90 observations · Updated Dec …pluginstats.com
ai-retry weekly downloads on npm, last 90 days: 45,039 weekly downloads as of Dec 5, 2026, -26.4% over 90 days.

7/30/90-day growth

ai-retry weekly downloads growth on npm: +18.8% over 7 days, -46.4% over 30 days, -26.4% over 90 days.ai-retryWeekly downloads growth on npm45,039downloads / week now7-day growth+7,122 weekly downloads+18.8%30-day growth-38,987 weekly downloads-46.4%90-day growth-16,137 weekly downloads-26.4%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
ai-retry weekly downloads growth on npm: +18.8% over 7 days, -46.4% over 30 days, -26.4% over 90 days.

Ranking history

ai-retry npm ranking history: currently #812 (by weekly downloads).ai-retrynpm ranking · by weekly downloads · Last 90 days#812current rank#200#300#400#500#600#700#800#900Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankOct 17, 2026 – Dec 6, 2026 · 45 observations · Updated Dec 5, 2026pluginstats.com
ai-retry npm ranking history: currently #812 (by weekly downloads).

Listing placement

All npm3,247 listings · 163 pages · 1,084 shown · page 41, #12 (overall #812)
All npm: every listing in weekly downloads order

Listing placement

AI SDKs378 listings · 19 pages · page 3, #12 (overall #52)
AI SDKs: every listing in weekly downloads order

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.

Each band is one page of 20. Weekly downloads on a linear 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.

Recent observations

Full history (592)
Recent weekly downloads observations for ai-retry
Date (UTC)Weekly downloadsChange vs. previous
45,039+551
44,488+1.8K
42,653+1.6K
41,091+1.8K
39,264-258
39,522+1.6K
37,873-44
37,917+308
37,609-2.2K
39,774-1.6K
41,350+268
41,082+1.1K
40,007+409
39,598—

Similar npm AI SDKs plugins

All 20 ai-retry alternatives

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 Dec 6, 2026. See the methodology.