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 18, 2026

ai-retry has 41,306 recorded weekly downloads on npm, a decrease of 20.7% over the past 30 days, ranking #628 of 2,322 tracked listings.

Weekly downloads
41,306
Official API · Oct 18, 2026
7-day growth
-27.7%
-15.8K weekly downloads
30-day growth
-20.7%
-10.8K weekly downloads
90-day growth
-9.8%
-4.5K weekly downloads
Rank
#628
Among tracked npm listings

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</p> <p align="center"> <a href="https://www.npmjs.com/package/ai-retry" alt="ai-retry"><img src="https://img.shields.io/npm/dt/ai-retry?label=ai-retry"></a> <a href="https://github.com/zirkelc/ai-retry/actions/workflows/ci.yml" alt="CI"><img src="https://img.shields.io/github/actions/workflow/status/zirkelc/ai-retry/ci.yml?branch=main"></a> </p> </div>

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:

npm install ai-retry@1 # for AI SDK v6
npm install ai-retry@2 # 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/<family>-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.

import { anthropic } from '@ai-sdk/anthropic';
import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';
import {
  createRetryableModel,
  error,
  finishReason,
  httpStatus,
} from 'ai-retry/language-model';

const retryableModel = createRetryableModel({
  model: openai('gpt-4o'),
  retries: [
    // Fall back to a different model on HTTP 529 or any "overloaded" message
    httpStatus(529, 'overloaded').switch({
      model: anthropic('claude-sonnet-4-0'),
    }),

    // Fall back when the response was content-filtered
    finishReason('content-filter').switch({ model: openai('gpt-4o-mini') }),

    // Retry the same model with exponential backoff on retryable errors
    error.isRetryable(true).retry({ delay: 1_000, backoffFactor: 2 }),
  ],
});

const result = await generateText({
  model: retryableModel,
  prompt: 'Hello world!',
  // Let ai-retry own retries; see "Max retries" below
  maxRetries: 0,
});

console.log(result.text);

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

import { openai } from '@ai-sdk/openai';
import { embed } from 'ai';
import { createRetryableModel, httpStatus } from 'ai-retry/embedding-model';

const retryableModel = createRetryableModel({
  model: openai.textEmbedding('text-embedding-3-large'),
  retries: [
    httpStatus(529).switch({
      model: openai.textEmbedding('text-embedding-3-small'),
    }),
  ],
});

const result = await embed({ model: retryableModel, value: 'Hello world!' });
import { google } from '@ai-sdk/google';
import { openai } from '@ai-sdk/openai';
import { generateImage } from 'ai';
import { createRetryableModel, noImage } from 'ai-retry/image-model';

const retryableModel = createRetryableModel({
  model: openai.image('dall-e-3'),
  retries: [
    noImage().switch({ model: google.image('gemini-3-pro-image-preview') }),
  ],
});

const result = await generateImage({
  model: retryableModel,
  prompt: 'A sunset over mountains',
});
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 pointFor models passed to
ai-retry/language-modelgenerateText, generateObject, streamText, streamObject
ai-retry/embedding-modelembed, embedMany
ai-retry/image-modelgenerateImage
import { createRetryableModel } from 'ai-retry/language-model';
import { createRetryableModel } from 'ai-retry/image-model';
import { createRetryableModel } from 'ai-retry/embedding-model';

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

import {
  error,
  httpStatus,
  finishReason,
} from 'ai-retry/language-model/conditions';
// or
import * as conditions from 'ai-retry/language-model/conditions';
Vercel AI Gateway…

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: 41,306 weekly downloads as of Oct 18, 2026, -9.8% over 90 days.ai-retryWeekly downloads on npm · Last 90 days41,306downloads / week-9.8% over 90 days30K40K50K60K70K80KJul 20Aug 4Aug 19Sep 3Sep 18Oct 3Oct 18downloads / weekobservedarchived (Internet Archive)no observationsJul 22, 2026 – Oct 18, 2026 · 89 observations · Updated Oc…pluginstats.com
ai-retry weekly downloads on npm, last 90 days: 41,306 weekly downloads as of Oct 18, 2026, -9.8% over 90 days.

7/30/90-day growth

ai-retry weekly downloads growth on npm: -27.7% over 7 days, -20.7% over 30 days, -9.8% over 90 days.ai-retryWeekly downloads growth on npm41,306downloads / week now7-day growth-15,802 weekly downloads-27.7%30-day growth-10,751 weekly downloads-20.7%90-day growth-4,501 weekly downloads-9.8%Growth vs. nearest observation to each baseline date · Updated Oct 18, 2026pluginstats.com
ai-retry weekly downloads growth on npm: -27.7% over 7 days, -20.7% over 30 days, -9.8% over 90 days.

Ranking history

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

Listing placement

All npm2,320 listings · 116 pages · 1,162 shown · page 32, #8 (overall #628)
All npm: every listing in weekly downloads order

Listing placement

AI SDKs259 listings · 13 pages · page 2, #18 (overall #38)
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 (544)
Recent weekly downloads observations for ai-retry
Date (UTC)Weekly downloadsChange vs. previous
41,306+6.5K
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—

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 Oct 20, 2026. See the methodology.