ai-retry 1.11.0 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +11 -5
  2. package/dist/{conditions-CyJOeRZK.mjs → conditions-CfeJD4K4.mjs} +2 -2
  3. package/dist/{conditions-BGoANmfr.mjs → conditions-DAetW5_1.mjs} +2 -2
  4. package/dist/{create-retryable-model-CLCFZANp.mjs → create-retryable-model-CCvLZL7h.mjs} +4 -4
  5. package/dist/{create-retryable-model-BIMStLIF.mjs → create-retryable-model-D4v2D0iX.mjs} +5 -5
  6. package/dist/{create-retryable-model-DEQ5jciq.mjs → create-retryable-model-ushVtD_m.mjs} +4 -4
  7. package/dist/embedding-model/conditions/index.d.mts +2 -2
  8. package/dist/embedding-model/conditions/index.mjs +1 -1
  9. package/dist/embedding-model/index.d.mts +2 -2
  10. package/dist/embedding-model/index.mjs +3 -3
  11. package/dist/{guards-DtZgDqE3.mjs → guards-CKn5dl__.mjs} +3 -3
  12. package/dist/image-model/conditions/index.d.mts +3 -3
  13. package/dist/image-model/conditions/index.mjs +2 -2
  14. package/dist/image-model/index.d.mts +3 -3
  15. package/dist/image-model/index.mjs +4 -4
  16. package/dist/{index-BkvvEDSr.d.mts → index-5jhZQN3C.d.mts} +2 -2
  17. package/dist/{index-D3t1Xo_U.d.mts → index-bEq1CHFY.d.mts} +2 -2
  18. package/dist/index.d.mts +1 -1
  19. package/dist/index.mjs +5 -5
  20. package/dist/language-model/conditions/index.d.mts +3 -3
  21. package/dist/language-model/conditions/index.mjs +2 -2
  22. package/dist/language-model/index.d.mts +3 -3
  23. package/dist/language-model/index.mjs +4 -4
  24. package/dist/{not-C9pUKPO7.mjs → not-6hBRaJRl.mjs} +1 -1
  25. package/dist/{or-CFcJxcaL.d.mts → or-CMOEoNU-.d.mts} +1 -1
  26. package/dist/retryables/index.d.mts +1 -1
  27. package/dist/retryables/index.mjs +1 -1
  28. package/dist/{telemetry-CJFJzjTr.mjs → telemetry-B0Pblnhb.mjs} +8 -1
  29. package/dist/{types-B8qg3Yzx.d.mts → types-DzfKbxXv.d.mts} +28 -16
  30. package/package.json +14 -14
package/README.md CHANGED
@@ -25,6 +25,7 @@ Two retry shapes are supported:
25
25
  >
26
26
  > - `ai-retry@0.x` — AI SDK v5
27
27
  > - `ai-retry@1.x` — AI SDK v6
28
+ > - `ai-retry@2.x` (beta) — AI SDK v7
28
29
 
29
30
  ```bash
30
31
  npm install ai-retry
@@ -714,11 +715,11 @@ const retryableModel = createRetryableModel({
714
715
  > [!NOTE]
715
716
  > Experimental: span names and attributes may change in patch versions.
716
717
 
717
- `ai-retry` can emit [OpenTelemetry](https://opentelemetry.io/) spans for each request and every retry attempt. Spans are created on the active OpenTelemetry context, so they nest automatically under the AI SDK's own spans (e.g. `ai.generateText.doGenerate`) when you also enable `experimental_telemetry` on `generateText` / `streamText`. A single trace then shows the individual attempts — which model each used, why it was retried, and the backoff between them — that the SDK's own span otherwise hides.
718
+ `ai-retry` can emit [OpenTelemetry](https://opentelemetry.io/) spans for each request and every retry attempt. Spans are created on the active OpenTelemetry context, so they nest automatically under the AI SDK's own spans (e.g. `ai.generateText.doGenerate`) when that integration is active in AI SDK v7 that means installing [`@ai-sdk/otel`](https://ai-sdk.dev/docs/ai-sdk-core/telemetry) and registering it with `registerTelemetry(new OpenTelemetry())`. A single trace then shows the individual attempts — which model each used, why it was retried, and the backoff between them — that the SDK's own span otherwise hides. Retry telemetry works on its own too: it talks to OpenTelemetry directly, so it does not require `@ai-sdk/otel`.
718
719
 
719
720
  #### Setup
720
721
 
721
- Telemetry uses the optional peer dependency `@opentelemetry/api` (already present if you use the AI SDK). Register an OpenTelemetry SDK once at startup, then opt in per model:
722
+ Telemetry uses the optional peer dependency `@opentelemetry/api`. In AI SDK v7 it is no longer a transitive dependency of `ai`, so install `@ai-sdk/otel` (which brings it in) or `@opentelemetry/api` directly. Register an OpenTelemetry SDK once at startup, then opt in per model:
722
723
 
723
724
  ```typescript
724
725
  import { createRetryableModel } from 'ai-retry/language-model';
@@ -726,11 +727,14 @@ import { createRetryableModel } from 'ai-retry/language-model';
726
727
  const retryableModel = createRetryableModel({
727
728
  model: openai('gpt-4o'),
728
729
  retries: [anthropic('claude-sonnet-4-5')],
729
- experimental_telemetry: { isEnabled: true },
730
+ telemetry: { isEnabled: true },
730
731
  });
731
732
  ```
732
733
 
733
- The settings mirror the AI SDK's `experimental_telemetry` shape:
734
+ > [!NOTE]
735
+ > `telemetry` replaces the now-deprecated `experimental_telemetry` option. The old name still works as an alias; when both are set, `telemetry` wins.
736
+
737
+ The settings resemble the AI SDK's `telemetry` shape, but stay opt-in and keep a `tracer` field (which the AI SDK moved into `@ai-sdk/otel`):
734
738
 
735
739
  ```ts
736
740
  interface RetryTelemetrySettings {
@@ -843,6 +847,8 @@ interface RetryableModelOptions<
843
847
  retries: Array<Retryable<MODEL> | MODEL>;
844
848
  disabled?: boolean | (() => boolean);
845
849
  reset?: Reset;
850
+ telemetry?: RetryTelemetrySettings;
851
+ /** @deprecated use `telemetry` */
846
852
  experimental_telemetry?: RetryTelemetrySettings;
847
853
  onError?: (context: RetryContext<MODEL>) => void;
848
854
  onRetry?: (
@@ -859,7 +865,7 @@ interface RetryableModelOptions<
859
865
  - `retries` — array of conditions (`.switch(...)` / `.retry(...)` outputs), models, or retry objects to try on failure.
860
866
  - `disabled` — disable all retry logic. `boolean` or `() => boolean`. Default `false`.
861
867
  - `reset` — controls when to reset back to the base model after a successful retry. Default `'after-request'`.
862
- - `experimental_telemetry` — OpenTelemetry instrumentation. See [Telemetry](#telemetry).
868
+ - `telemetry` — OpenTelemetry instrumentation. See [Telemetry](#telemetry). (`experimental_telemetry` is a deprecated alias.)
863
869
  - `onError` — fires when an error occurs.
864
870
  - `onRetry` — fires before a retry attempt. May return `OnRetryOverrides` (or a promise of one) to override `options.*` for that attempt only. See [Dynamic call options](#dynamic-call-options).
865
871
  - `onSuccess` — fires after a successful request.
@@ -1,5 +1,5 @@
1
- import { r as isErrorAttempt } from "./guards-DtZgDqE3.mjs";
2
- import { a as Condition, r as createErrorAPI } from "./not-C9pUKPO7.mjs";
1
+ import { r as isErrorAttempt } from "./guards-CKn5dl__.mjs";
2
+ import { a as Condition, r as createErrorAPI } from "./not-6hBRaJRl.mjs";
3
3
  import { NoImageGeneratedError } from "ai";
4
4
 
5
5
  //#region src/internal/conditions/no-image.ts
@@ -1,5 +1,5 @@
1
- import { c as isResultAttempt } from "./guards-DtZgDqE3.mjs";
2
- import { a as Condition, r as createErrorAPI } from "./not-C9pUKPO7.mjs";
1
+ import { c as isResultAttempt } from "./guards-CKn5dl__.mjs";
2
+ import { a as Condition, r as createErrorAPI } from "./not-6hBRaJRl.mjs";
3
3
  import { safeParseJSON } from "@ai-sdk/provider-utils";
4
4
  import { fromJSONSchema } from "zod";
5
5
 
@@ -1,10 +1,10 @@
1
- import { a as prepareRetryError, c as resolveImageModel, f as calculateExponentialBackoff, o as findRetryModel, p as BaseRetryableModel, r as mergeImageModelCallOptions, t as createRetryTelemetry, u as countModelAttempts } from "./telemetry-CJFJzjTr.mjs";
2
- import { o as isModel } from "./guards-DtZgDqE3.mjs";
1
+ import { a as prepareRetryError, c as resolveImageModel, f as calculateExponentialBackoff, o as findRetryModel, p as BaseRetryableModel, r as mergeImageModelCallOptions, t as createRetryTelemetry, u as countModelAttempts } from "./telemetry-B0Pblnhb.mjs";
2
+ import { o as isModel } from "./guards-CKn5dl__.mjs";
3
3
  import { delay } from "@ai-sdk/provider-utils";
4
4
 
5
5
  //#region src/internal/retryable-image-model.ts
6
6
  var RetryableImageModel = class extends BaseRetryableModel {
7
- specificationVersion = "v3";
7
+ specificationVersion = "v4";
8
8
  get modelId() {
9
9
  return this.currentModel.modelId;
10
10
  }
@@ -180,7 +180,7 @@ var RetryableImageModel = class extends BaseRetryableModel {
180
180
  * If retries are disabled, bypass retry machinery entirely
181
181
  */
182
182
  if (this.isDisabled()) return this.currentModel.doGenerate(callOptions);
183
- const recorder = await createRetryTelemetry(this.options.experimental_telemetry, {
183
+ const recorder = await createRetryTelemetry(this.telemetrySettings, {
184
184
  operation: "doGenerate",
185
185
  genAiOperation: "generate_content",
186
186
  provider: startModel.provider,
@@ -1,10 +1,10 @@
1
- import { a as prepareRetryError, f as calculateExponentialBackoff, i as mergeLanguageModelCallOptions, l as resolveLanguageModel, o as findRetryModel, p as BaseRetryableModel, t as createRetryTelemetry, u as countModelAttempts } from "./telemetry-CJFJzjTr.mjs";
2
- import { i as isGenerateResult, l as isStreamContentPart, o as isModel, r as isErrorAttempt } from "./guards-DtZgDqE3.mjs";
1
+ import { a as prepareRetryError, f as calculateExponentialBackoff, i as mergeLanguageModelCallOptions, l as resolveLanguageModel, o as findRetryModel, p as BaseRetryableModel, t as createRetryTelemetry, u as countModelAttempts } from "./telemetry-B0Pblnhb.mjs";
2
+ import { i as isGenerateResult, l as isStreamContentPart, o as isModel, r as isErrorAttempt } from "./guards-CKn5dl__.mjs";
3
3
  import { delay } from "@ai-sdk/provider-utils";
4
4
 
5
5
  //#region src/internal/retryable-language-model.ts
6
6
  var RetryableLanguageModel = class extends BaseRetryableModel {
7
- specificationVersion = "v3";
7
+ specificationVersion = "v4";
8
8
  get modelId() {
9
9
  return this.currentModel.modelId;
10
10
  }
@@ -242,7 +242,7 @@ var RetryableLanguageModel = class extends BaseRetryableModel {
242
242
  * If retries are disabled, bypass retry machinery entirely
243
243
  */
244
244
  if (this.isDisabled()) return this.currentModel.doGenerate(callOptions);
245
- const recorder = await createRetryTelemetry(this.options.experimental_telemetry, {
245
+ const recorder = await createRetryTelemetry(this.telemetrySettings, {
246
246
  operation: "doGenerate",
247
247
  genAiOperation: "chat",
248
248
  provider: startModel.provider,
@@ -296,7 +296,7 @@ var RetryableLanguageModel = class extends BaseRetryableModel {
296
296
  * If retries are disabled, bypass retry machinery entirely
297
297
  */
298
298
  if (this.isDisabled()) return this.currentModel.doStream(callOptions);
299
- const recorder = await createRetryTelemetry(this.options.experimental_telemetry, {
299
+ const recorder = await createRetryTelemetry(this.telemetrySettings, {
300
300
  operation: "doStream",
301
301
  genAiOperation: "chat",
302
302
  provider: startModel.provider,
@@ -1,10 +1,10 @@
1
- import { a as prepareRetryError, f as calculateExponentialBackoff, n as mergeEmbeddingModelCallOptions, o as findRetryModel, p as BaseRetryableModel, s as resolveEmbeddingModel, t as createRetryTelemetry, u as countModelAttempts } from "./telemetry-CJFJzjTr.mjs";
2
- import { o as isModel } from "./guards-DtZgDqE3.mjs";
1
+ import { a as prepareRetryError, f as calculateExponentialBackoff, n as mergeEmbeddingModelCallOptions, o as findRetryModel, p as BaseRetryableModel, s as resolveEmbeddingModel, t as createRetryTelemetry, u as countModelAttempts } from "./telemetry-B0Pblnhb.mjs";
2
+ import { o as isModel } from "./guards-CKn5dl__.mjs";
3
3
  import { delay } from "@ai-sdk/provider-utils";
4
4
 
5
5
  //#region src/internal/retryable-embedding-model.ts
6
6
  var RetryableEmbeddingModel = class extends BaseRetryableModel {
7
- specificationVersion = "v3";
7
+ specificationVersion = "v4";
8
8
  get modelId() {
9
9
  return this.currentModel.modelId;
10
10
  }
@@ -183,7 +183,7 @@ var RetryableEmbeddingModel = class extends BaseRetryableModel {
183
183
  * If retries are disabled, bypass retry machinery entirely
184
184
  */
185
185
  if (this.isDisabled()) return this.currentModel.doEmbed(callOptions);
186
- const recorder = await createRetryTelemetry(this.options.experimental_telemetry, {
186
+ const recorder = await createRetryTelemetry(this.telemetrySettings, {
187
187
  operation: "doEmbed",
188
188
  genAiOperation: "embeddings",
189
189
  provider: startModel.provider,
@@ -1,5 +1,5 @@
1
- import { F as RetryContext, T as ResolvableEmbeddingModel } from "../../types-B8qg3Yzx.mjs";
2
- import { a as Condition, i as StatusPattern, n as not, r as and, t as or } from "../../or-CFcJxcaL.mjs";
1
+ import { F as RetryContext, T as ResolvableEmbeddingModel } from "../../types-DzfKbxXv.mjs";
2
+ import { a as Condition, i as StatusPattern, n as not, r as and, t as or } from "../../or-CMOEoNU-.mjs";
3
3
 
4
4
  //#region src/embedding-model/conditions/index.d.ts
5
5
  declare const error: {
@@ -1,4 +1,4 @@
1
- import { i as or, n as and, r as createErrorAPI, t as not } from "../../not-C9pUKPO7.mjs";
1
+ import { i as or, n as and, r as createErrorAPI, t as not } from "../../not-6hBRaJRl.mjs";
2
2
 
3
3
  //#region src/embedding-model/conditions/index.ts
4
4
  const { error, httpStatus, timeout, aborted } = createErrorAPI();
@@ -1,5 +1,5 @@
1
- import { B as RetryableModelOptions, T as ResolvableEmbeddingModel, r as EmbeddingModel } from "../types-B8qg3Yzx.mjs";
2
- import { n as not, r as and, t as or } from "../or-CFcJxcaL.mjs";
1
+ import { B as RetryableModelOptions, T as ResolvableEmbeddingModel, r as EmbeddingModel } from "../types-DzfKbxXv.mjs";
2
+ import { n as not, r as and, t as or } from "../or-CMOEoNU-.mjs";
3
3
  import { aborted, error, httpStatus, timeout } from "./conditions/index.mjs";
4
4
 
5
5
  //#region src/embedding-model/create-retryable-model.d.ts
@@ -1,6 +1,6 @@
1
- import "../telemetry-CJFJzjTr.mjs";
2
- import { t as createRetryableModel } from "../create-retryable-model-DEQ5jciq.mjs";
3
- import { i as or, n as and, t as not } from "../not-C9pUKPO7.mjs";
1
+ import "../telemetry-B0Pblnhb.mjs";
2
+ import { t as createRetryableModel } from "../create-retryable-model-ushVtD_m.mjs";
3
+ import { i as or, n as and, t as not } from "../not-6hBRaJRl.mjs";
4
4
  import { aborted, error, httpStatus, timeout } from "./conditions/index.mjs";
5
5
 
6
6
  export { aborted, and, createRetryableModel, error, httpStatus, not, or, timeout };
@@ -2,9 +2,9 @@
2
2
  const isObject = (value) => typeof value === "object" && value !== null;
3
3
  const isString = (value) => typeof value === "string";
4
4
  const isModel = (model) => isLanguageModel(model) || isEmbeddingModel(model) || isImageModel(model);
5
- const isLanguageModel = (model) => isObject(model) && "provider" in model && "modelId" in model && "specificationVersion" in model && "doGenerate" in model && "doStream" in model && model.specificationVersion === "v3";
6
- const isEmbeddingModel = (model) => isObject(model) && "provider" in model && "modelId" in model && "specificationVersion" in model && "doEmbed" in model && model.specificationVersion === "v3";
7
- const isImageModel = (model) => isObject(model) && "provider" in model && "modelId" in model && "specificationVersion" in model && "doGenerate" in model && model.specificationVersion === "v3" && !("doStream" in model) && !("doEmbed" in model);
5
+ const isLanguageModel = (model) => isObject(model) && "provider" in model && "modelId" in model && "specificationVersion" in model && "doGenerate" in model && "doStream" in model && model.specificationVersion === "v4";
6
+ const isEmbeddingModel = (model) => isObject(model) && "provider" in model && "modelId" in model && "specificationVersion" in model && "doEmbed" in model && model.specificationVersion === "v4";
7
+ const isImageModel = (model) => isObject(model) && "provider" in model && "modelId" in model && "specificationVersion" in model && "doGenerate" in model && model.specificationVersion === "v4" && !("doStream" in model) && !("doEmbed" in model);
8
8
  const isGenerateResult = (result) => "content" in result;
9
9
  /**
10
10
  * Type guard to check if a retry attempt is an error attempt
@@ -1,4 +1,4 @@
1
- import "../../types-B8qg3Yzx.mjs";
2
- import { n as not, r as and, t as or } from "../../or-CFcJxcaL.mjs";
3
- import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../../index-D3t1Xo_U.mjs";
1
+ import "../../types-DzfKbxXv.mjs";
2
+ import { n as not, r as and, t as or } from "../../or-CMOEoNU-.mjs";
3
+ import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../../index-bEq1CHFY.mjs";
4
4
  export { aborted, and, error, httpStatus, noImage, not, or, timeout };
@@ -1,4 +1,4 @@
1
- import { i as or, n as and, t as not } from "../../not-C9pUKPO7.mjs";
2
- import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../../conditions-CyJOeRZK.mjs";
1
+ import { i as or, n as and, t as not } from "../../not-6hBRaJRl.mjs";
2
+ import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../../conditions-CfeJD4K4.mjs";
3
3
 
4
4
  export { aborted, and, error, httpStatus, noImage, not, or, timeout };
@@ -1,6 +1,6 @@
1
- import { B as RetryableModelOptions, E as ResolvableImageModel, d as ImageModel } from "../types-B8qg3Yzx.mjs";
2
- import { n as not, r as and, t as or } from "../or-CFcJxcaL.mjs";
3
- import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../index-D3t1Xo_U.mjs";
1
+ import { B as RetryableModelOptions, E as ResolvableImageModel, d as ImageModel } from "../types-DzfKbxXv.mjs";
2
+ import { n as not, r as and, t as or } from "../or-CMOEoNU-.mjs";
3
+ import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../index-bEq1CHFY.mjs";
4
4
 
5
5
  //#region src/image-model/create-retryable-model.d.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
- import "../telemetry-CJFJzjTr.mjs";
2
- import { t as createRetryableModel } from "../create-retryable-model-CLCFZANp.mjs";
3
- import { i as or, n as and, t as not } from "../not-C9pUKPO7.mjs";
4
- import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../conditions-CyJOeRZK.mjs";
1
+ import "../telemetry-B0Pblnhb.mjs";
2
+ import { t as createRetryableModel } from "../create-retryable-model-CCvLZL7h.mjs";
3
+ import { i as or, n as and, t as not } from "../not-6hBRaJRl.mjs";
4
+ import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../conditions-CfeJD4K4.mjs";
5
5
 
6
6
  export { aborted, and, createRetryableModel, error, httpStatus, noImage, not, or, timeout };
@@ -1,5 +1,5 @@
1
- import { D as ResolvableLanguageModel, F as RetryContext, v as LanguageModelResult } from "./types-B8qg3Yzx.mjs";
2
- import { a as Condition, i as StatusPattern } from "./or-CFcJxcaL.mjs";
1
+ import { D as ResolvableLanguageModel, F as RetryContext, v as LanguageModelResult } from "./types-DzfKbxXv.mjs";
2
+ import { a as Condition, i as StatusPattern } from "./or-CMOEoNU-.mjs";
3
3
 
4
4
  //#region src/internal/conditions/result.d.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { E as ResolvableImageModel, F as RetryContext } from "./types-B8qg3Yzx.mjs";
2
- import { a as Condition, i as StatusPattern } from "./or-CFcJxcaL.mjs";
1
+ import { E as ResolvableImageModel, F as RetryContext } from "./types-DzfKbxXv.mjs";
2
+ import { a as Condition, i as StatusPattern } from "./or-CMOEoNU-.mjs";
3
3
 
4
4
  //#region src/internal/conditions/no-image.d.ts
5
5
  /**
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as Result, B as RetryableModelOptions, C as ProviderOptions, D as ResolvableLanguageModel, E as ResolvableImageModel, F as RetryContext, H as SuccessAttempt, I as RetryErrorAttempt, L as RetryResultAttempt, M as Retry, N as RetryAttempt, O as ResolvableModel, P as RetryCallOptions, R as RetryTelemetrySettings, S as OnRetryOverrides, T as ResolvableEmbeddingModel, U as SuccessContext, V as RetryableOptions, _ as LanguageModelGenerate, a as EmbeddingModelEmbed, b as LanguageModelStream, c as GatewayEmbeddingModelId, d as ImageModel, f as ImageModelCallOptions, g as LanguageModelCallOptions, h as LanguageModel, i as EmbeddingModelCallOptions, j as Retries, k as ResolvedModel, l as GatewayImageModelId, m as ImageModelRetryCallOptions, n as CallOptions, o as EmbeddingModelRetryCallOptions, p as ImageModelGenerate, r as EmbeddingModel, s as FailureContext, t as AnyResolvableModel, u as GatewayLanguageModelId, v as LanguageModelResult, w as Reset, x as LanguageModelStreamPart, y as LanguageModelRetryCallOptions, z as Retryable } from "./types-B8qg3Yzx.mjs";
1
+ import { A as Result, B as RetryableModelOptions, C as ProviderOptions, D as ResolvableLanguageModel, E as ResolvableImageModel, F as RetryContext, H as SuccessAttempt, I as RetryErrorAttempt, L as RetryResultAttempt, M as Retry, N as RetryAttempt, O as ResolvableModel, P as RetryCallOptions, R as RetryTelemetrySettings, S as OnRetryOverrides, T as ResolvableEmbeddingModel, U as SuccessContext, V as RetryableOptions, _ as LanguageModelGenerate, a as EmbeddingModelEmbed, b as LanguageModelStream, c as GatewayEmbeddingModelId, d as ImageModel, f as ImageModelCallOptions, g as LanguageModelCallOptions, h as LanguageModel, i as EmbeddingModelCallOptions, j as Retries, k as ResolvedModel, l as GatewayImageModelId, m as ImageModelRetryCallOptions, n as CallOptions, o as EmbeddingModelRetryCallOptions, p as ImageModelGenerate, r as EmbeddingModel, s as FailureContext, t as AnyResolvableModel, u as GatewayLanguageModelId, v as LanguageModelResult, w as Reset, x as LanguageModelStreamPart, y as LanguageModelRetryCallOptions, z as Retryable } from "./types-DzfKbxXv.mjs";
2
2
  import "@ai-sdk/provider";
3
3
 
4
4
  //#region src/internal/create-retryable-model.d.ts
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { d as getModelKey, l as resolveLanguageModel } from "./telemetry-CJFJzjTr.mjs";
2
- import { a as isImageModel, c as isResultAttempt, n as isEmbeddingModel, o as isModel, r as isErrorAttempt } from "./guards-DtZgDqE3.mjs";
3
- import { t as createRetryableModel$1 } from "./create-retryable-model-DEQ5jciq.mjs";
4
- import { t as createRetryableModel$2 } from "./create-retryable-model-CLCFZANp.mjs";
5
- import { t as createRetryableModel$3 } from "./create-retryable-model-BIMStLIF.mjs";
1
+ import { d as getModelKey, l as resolveLanguageModel } from "./telemetry-B0Pblnhb.mjs";
2
+ import { a as isImageModel, c as isResultAttempt, n as isEmbeddingModel, o as isModel, r as isErrorAttempt } from "./guards-CKn5dl__.mjs";
3
+ import { t as createRetryableModel$1 } from "./create-retryable-model-ushVtD_m.mjs";
4
+ import { t as createRetryableModel$2 } from "./create-retryable-model-CCvLZL7h.mjs";
5
+ import { t as createRetryableModel$3 } from "./create-retryable-model-D4v2D0iX.mjs";
6
6
 
7
7
  //#region src/internal/create-retryable-model.ts
8
8
  function createRetryableModel(options) {
@@ -1,4 +1,4 @@
1
- import "../../types-B8qg3Yzx.mjs";
2
- import { n as not, r as and, t as or } from "../../or-CFcJxcaL.mjs";
3
- import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../../index-BkvvEDSr.mjs";
1
+ import "../../types-DzfKbxXv.mjs";
2
+ import { n as not, r as and, t as or } from "../../or-CMOEoNU-.mjs";
3
+ import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../../index-5jhZQN3C.mjs";
4
4
  export { aborted, and, error, finishReason, httpStatus, not, or, result, schemaInvalid, timeout };
@@ -1,4 +1,4 @@
1
- import { i as or, n as and, t as not } from "../../not-C9pUKPO7.mjs";
2
- import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../../conditions-BGoANmfr.mjs";
1
+ import { i as or, n as and, t as not } from "../../not-6hBRaJRl.mjs";
2
+ import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../../conditions-DAetW5_1.mjs";
3
3
 
4
4
  export { aborted, and, error, finishReason, httpStatus, not, or, result, schemaInvalid, timeout };
@@ -1,6 +1,6 @@
1
- import { B as RetryableModelOptions, D as ResolvableLanguageModel, h as LanguageModel } from "../types-B8qg3Yzx.mjs";
2
- import { n as not, r as and, t as or } from "../or-CFcJxcaL.mjs";
3
- import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../index-BkvvEDSr.mjs";
1
+ import { B as RetryableModelOptions, D as ResolvableLanguageModel, h as LanguageModel } from "../types-DzfKbxXv.mjs";
2
+ import { n as not, r as and, t as or } from "../or-CMOEoNU-.mjs";
3
+ import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../index-5jhZQN3C.mjs";
4
4
 
5
5
  //#region src/language-model/create-retryable-model.d.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
- import "../telemetry-CJFJzjTr.mjs";
2
- import { t as createRetryableModel } from "../create-retryable-model-BIMStLIF.mjs";
3
- import { i as or, n as and, t as not } from "../not-C9pUKPO7.mjs";
4
- import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../conditions-BGoANmfr.mjs";
1
+ import "../telemetry-B0Pblnhb.mjs";
2
+ import { t as createRetryableModel } from "../create-retryable-model-D4v2D0iX.mjs";
3
+ import { i as or, n as and, t as not } from "../not-6hBRaJRl.mjs";
4
+ import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../conditions-DAetW5_1.mjs";
5
5
 
6
6
  export { aborted, and, createRetryableModel, error, finishReason, httpStatus, not, or, result, schemaInvalid, timeout };
@@ -1,4 +1,4 @@
1
- import { d as isTimeoutError, r as isErrorAttempt, t as isAbortError } from "./guards-DtZgDqE3.mjs";
1
+ import { d as isTimeoutError, r as isErrorAttempt, t as isAbortError } from "./guards-CKn5dl__.mjs";
2
2
  import { n as parseRetryHeaders, t as MAX_RETRY_AFTER_MS } from "./parse-retry-headers-RPSiSNjf.mjs";
3
3
  import { APICallError } from "ai";
4
4
 
@@ -1,4 +1,4 @@
1
- import { F as RetryContext, M as Retry, t as AnyResolvableModel, z as Retryable } from "./types-B8qg3Yzx.mjs";
1
+ import { F as RetryContext, M as Retry, t as AnyResolvableModel, z as Retryable } from "./types-DzfKbxXv.mjs";
2
2
 
3
3
  //#region src/internal/conditions/condition.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { D as ResolvableLanguageModel, E as ResolvableImageModel, V as RetryableOptions, t as AnyResolvableModel, z as Retryable } from "../types-B8qg3Yzx.mjs";
1
+ import { D as ResolvableLanguageModel, E as ResolvableImageModel, V as RetryableOptions, t as AnyResolvableModel, z as Retryable } from "../types-DzfKbxXv.mjs";
2
2
 
3
3
  //#region src/retryables/content-filter-triggered.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { c as isResultAttempt, d as isTimeoutError, r as isErrorAttempt, s as isObject, u as isString } from "../guards-DtZgDqE3.mjs";
1
+ import { c as isResultAttempt, d as isTimeoutError, r as isErrorAttempt, s as isObject, u as isString } from "../guards-CKn5dl__.mjs";
2
2
  import { n as parseRetryHeaders, t as MAX_RETRY_AFTER_MS } from "../parse-retry-headers-RPSiSNjf.mjs";
3
3
  import { safeParseJSON } from "@ai-sdk/provider-utils";
4
4
  import { APICallError, NoImageGeneratedError } from "ai";
@@ -1,4 +1,4 @@
1
- import { c as isResultAttempt, d as isTimeoutError, o as isModel, r as isErrorAttempt, s as isObject } from "./guards-DtZgDqE3.mjs";
1
+ import { c as isResultAttempt, d as isTimeoutError, o as isModel, r as isErrorAttempt, s as isObject } from "./guards-CKn5dl__.mjs";
2
2
  import { RetryError, gateway } from "ai";
3
3
  import { getErrorMessage } from "@ai-sdk/provider";
4
4
 
@@ -73,6 +73,13 @@ var BaseRetryableModel = class {
73
73
  };
74
74
  }
75
75
  /**
76
+ * Resolve the telemetry settings, preferring `telemetry` over the deprecated
77
+ * `experimental_telemetry` alias.
78
+ */
79
+ get telemetrySettings() {
80
+ return this.options.telemetry ?? this.options.experimental_telemetry;
81
+ }
82
+ /**
76
83
  * Check if retries are disabled
77
84
  */
78
85
  isDisabled() {
@@ -1,16 +1,16 @@
1
1
  import { gateway } from "ai";
2
- import { EmbeddingModelV3, ImageModelV3, ImageModelV3CallOptions, LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamPart, SharedV3ProviderOptions } from "@ai-sdk/provider";
2
+ import { EmbeddingModelV4, ImageModelV4, ImageModelV4CallOptions, LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamPart, SharedV4ProviderOptions } from "@ai-sdk/provider";
3
3
  import { AttributeValue, Tracer } from "@opentelemetry/api";
4
4
 
5
5
  //#region src/types.d.ts
6
6
  type Literals<T> = T extends string ? string extends T ? never : T : never;
7
- type LanguageModel = LanguageModelV3;
8
- type EmbeddingModel = EmbeddingModelV3;
9
- type ImageModel = ImageModelV3;
10
- type LanguageModelCallOptions = LanguageModelV3CallOptions;
11
- type LanguageModelStreamPart = LanguageModelV3StreamPart;
12
- type ImageModelCallOptions = ImageModelV3CallOptions;
13
- type ProviderOptions = SharedV3ProviderOptions;
7
+ type LanguageModel = LanguageModelV4;
8
+ type EmbeddingModel = EmbeddingModelV4;
9
+ type ImageModel = ImageModelV4;
10
+ type LanguageModelCallOptions = LanguageModelV4CallOptions;
11
+ type LanguageModelStreamPart = LanguageModelV4StreamPart;
12
+ type ImageModelCallOptions = ImageModelV4CallOptions;
13
+ type ProviderOptions = SharedV4ProviderOptions;
14
14
  type GatewayLanguageModelId = Parameters<(typeof gateway)['languageModel']>[0];
15
15
  type GatewayEmbeddingModelId = Parameters<(typeof gateway)['embeddingModel']>[0];
16
16
  type GatewayImageModelId = Parameters<(typeof gateway)['imageModel']>[0];
@@ -31,7 +31,7 @@ type ResolvedModel<MODEL extends AnyResolvableModel> = MODEL extends ResolvableL
31
31
  /**
32
32
  * Result from a generateText call.
33
33
  */
34
- type LanguageModelResult = LanguageModelV3GenerateResult;
34
+ type LanguageModelResult = LanguageModelV4GenerateResult;
35
35
  /**
36
36
  * Call options that can be overridden during retry for language models.
37
37
  */
@@ -149,13 +149,20 @@ type FailureContext<MODEL extends ResolvableLanguageModel | EmbeddingModel | Ima
149
149
  /**
150
150
  * Telemetry configuration for retry instrumentation.
151
151
  *
152
- * Mirrors the AI SDK's `experimental_telemetry` shape so the two can be
153
- * configured the same way. When enabled, each request emits an OpenTelemetry
154
- * span for the operation with a child span per attempt. Spans created here
155
- * nest under any active span (e.g. the AI SDK's `ai.generateText.doGenerate`)
156
- * via OpenTelemetry context propagation.
152
+ * Talks to OpenTelemetry directly and independently of the AI SDK: when
153
+ * enabled, each request emits a span for the operation with a child span per
154
+ * attempt. Spans created here nest under any active span (e.g. the AI SDK's
155
+ * `ai.generateText.doGenerate`, when that integration is registered) via
156
+ * OpenTelemetry context propagation.
157
157
  *
158
- * Requires the optional peer dependency `@opentelemetry/api` to be installed.
158
+ * The shape resembles the AI SDK's `telemetry` settings but is opt-in and
159
+ * deliberately keeps a `tracer` field (which the AI SDK moved to its
160
+ * `@ai-sdk/otel` integration), so retry spans work without adopting that
161
+ * integration.
162
+ *
163
+ * Requires the optional peer dependency `@opentelemetry/api` to be installed
164
+ * (in AI SDK v7 it is no longer a transitive dependency of `ai`; install
165
+ * `@ai-sdk/otel` or `@opentelemetry/api` directly).
159
166
  */
160
167
  interface RetryTelemetrySettings {
161
168
  /**
@@ -197,6 +204,11 @@ interface RetryableModelOptions<MODEL extends LanguageModel | EmbeddingModel | I
197
204
  * Telemetry configuration. When enabled, emits OpenTelemetry spans for
198
205
  * retry operations and attempts. Requires `@opentelemetry/api`.
199
206
  */
207
+ telemetry?: RetryTelemetrySettings;
208
+ /**
209
+ * @deprecated Use `telemetry` instead. Kept as an alias for compatibility;
210
+ * when both are set, `telemetry` takes precedence.
211
+ */
200
212
  experimental_telemetry?: RetryTelemetrySettings;
201
213
  onError?: (context: RetryContext<MODEL>) => void;
202
214
  /**
@@ -262,7 +274,7 @@ type Retry<MODEL extends AnyResolvableModel> = {
262
274
  * If both `providerOptions` and `options.providerOptions` are set,
263
275
  * `options.providerOptions` takes precedence.
264
276
  */
265
- providerOptions?: SharedV3ProviderOptions;
277
+ providerOptions?: SharedV4ProviderOptions;
266
278
  };
267
279
  /**
268
280
  * A function that determines whether to retry with a different model based on the current attempt and all previous attempts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-retry",
3
- "version": "1.11.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Retry and fallback mechanisms for AI SDK",
5
5
  "keywords": [
6
6
  "ai",
@@ -34,15 +34,15 @@
34
34
  "access": "public"
35
35
  },
36
36
  "devDependencies": {
37
- "@ai-sdk/anthropic": "3.0.23",
38
- "@ai-sdk/azure": "3.0.19",
39
- "@ai-sdk/gateway": "3.0.23",
40
- "@ai-sdk/google": "^3.0.33",
41
- "@ai-sdk/groq": "3.0.15",
42
- "@ai-sdk/openai": "3.0.19",
43
- "@ai-sdk/provider": "3.0.5",
44
- "@ai-sdk/provider-utils": "4.0.9",
45
- "@ai-sdk/test-server": "1.0.3",
37
+ "@ai-sdk/anthropic": "4.0.0-beta.67",
38
+ "@ai-sdk/azure": "4.0.0-beta.76",
39
+ "@ai-sdk/gateway": "4.0.0-beta.110",
40
+ "@ai-sdk/google": "4.0.0-beta.82",
41
+ "@ai-sdk/groq": "4.0.0-beta.54",
42
+ "@ai-sdk/openai": "4.0.0-beta.74",
43
+ "@ai-sdk/provider": "4.0.0-beta.19",
44
+ "@ai-sdk/provider-utils": "5.0.0-beta.49",
45
+ "@ai-sdk/test-server": "2.0.0-beta.7",
46
46
  "@arethetypeswrong/cli": "^0.18.2",
47
47
  "@langfuse/otel": "^5.3.0",
48
48
  "@langfuse/tracing": "^5.3.0",
@@ -52,7 +52,7 @@
52
52
  "@opentelemetry/sdk-trace-base": "^2.7.1",
53
53
  "@total-typescript/tsconfig": "^1.0.4",
54
54
  "@types/node": "^25.0.10",
55
- "ai": "6.0.50",
55
+ "ai": "7.0.0-beta.179",
56
56
  "husky": "^9.1.7",
57
57
  "lint-staged": "^16.4.0",
58
58
  "msw": "^2.12.7",
@@ -67,10 +67,10 @@
67
67
  "zod": "^4.3.6"
68
68
  },
69
69
  "peerDependencies": {
70
- "@ai-sdk/provider": "^3.0.0",
71
- "@ai-sdk/provider-utils": "^4.0.0",
70
+ "@ai-sdk/provider": "^4.0.0-beta.0",
71
+ "@ai-sdk/provider-utils": "^5.0.0-beta.0",
72
72
  "@opentelemetry/api": "^1.9.0",
73
- "ai": "6.x",
73
+ "ai": "^7.0.0-beta.0",
74
74
  "zod": "^4.0.0"
75
75
  },
76
76
  "peerDependenciesMeta": {