@ai-sdk/provider 4.0.3 → 4.0.5

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 (25) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/index.d.ts +492 -38
  3. package/package.json +1 -1
  4. package/src/embedding-model/v4/embedding-model-v4.ts +1 -1
  5. package/src/image-model/v4/image-model-v4.ts +1 -1
  6. package/src/index.ts +1 -0
  7. package/src/realtime-model/v4/realtime-model-v4-session-config.ts +3 -22
  8. package/src/reranking-model/v4/reranking-model-v4.ts +1 -1
  9. package/src/shared/v4/index.ts +1 -0
  10. package/src/shared/v4/shared-v4-audio-format.ts +14 -0
  11. package/src/speech-model/v4/speech-model-v4.ts +1 -1
  12. package/src/speech-translation-model/index.ts +1 -0
  13. package/src/speech-translation-model/v4/index.ts +5 -0
  14. package/src/speech-translation-model/v4/speech-translation-model-v4-stream-options.ts +65 -0
  15. package/src/speech-translation-model/v4/speech-translation-model-v4-stream-part.ts +141 -0
  16. package/src/speech-translation-model/v4/speech-translation-model-v4-stream-result.ts +47 -0
  17. package/src/speech-translation-model/v4/speech-translation-model-v4-usage.ts +32 -0
  18. package/src/speech-translation-model/v4/speech-translation-model-v4.ts +40 -0
  19. package/src/transcription-model/v4/transcription-model-v4-stream-options.ts +2 -11
  20. package/src/transcription-model/v4/transcription-model-v4.ts +1 -1
  21. package/src/video-model/v4/index.ts +3 -0
  22. package/src/video-model/v4/video-model-v4-operation-start-result.ts +44 -0
  23. package/src/video-model/v4/video-model-v4-operation-status-result.ts +89 -0
  24. package/src/video-model/v4/video-model-v4-operation-webhook.ts +11 -0
  25. package/src/video-model/v4/video-model-v4.ts +87 -2
@@ -1,12 +1,16 @@
1
+ import type { JSONValue } from '../../json-value/json-value';
1
2
  import type { VideoModelV4CallOptions } from './video-model-v4-call-options';
2
3
  import type { VideoModelV4Result } from './video-model-v4-result';
4
+ import type { VideoModelV4OperationStartResult } from './video-model-v4-operation-start-result';
5
+ import type { VideoModelV4OperationStatusResult } from './video-model-v4-operation-status-result';
6
+ import type { VideoModelV4OperationWebhook } from './video-model-v4-operation-webhook';
3
7
 
4
8
  type GetMaxVideosPerCallFunction = (options: {
5
9
  modelId: string;
6
10
  }) => PromiseLike<number | undefined> | number | undefined;
7
11
 
8
12
  /**
9
- * Video generation model specification version 3.
13
+ * Video generation model specification version 4.
10
14
  */
11
15
  export type VideoModelV4 = {
12
16
  /**
@@ -41,6 +45,87 @@ export type VideoModelV4 = {
41
45
 
42
46
  /**
43
47
  * Generates an array of videos.
48
+ *
49
+ * Optional when `doStart` and `doStatus` are provided to support
50
+ * the asynchronous start/status flow.
51
+ */
52
+ doGenerate?(
53
+ options: VideoModelV4CallOptions,
54
+ ): PromiseLike<VideoModelV4Result>;
55
+
56
+ /**
57
+ * Optional method that handles the user's `webhook` option for the
58
+ * asynchronous start/status flow.
59
+ *
60
+ * Its presence on the model signals that the provider's API natively
61
+ * supports webhooks. The SDK checks for this method before invoking the
62
+ * user-provided `webhook` factory:
63
+ *
64
+ * - **Present**: The SDK calls this method with the user's webhook factory.
65
+ * The implementation should invoke the factory to obtain a webhook URL
66
+ * and a `received` promise. The URL is then forwarded to `doStart` via
67
+ * `webhookUrl`, and the SDK awaits `received` instead of polling.
68
+ *
69
+ * - **Absent**: The SDK never calls the user's `webhook` factory and falls
70
+ * back to polling via `doStatus`. This avoids unnecessary webhook
71
+ * endpoint creation for providers whose APIs have no native webhook
72
+ * mechanism.
73
+ *
74
+ * This method exists because the SDK must decide whether to invoke the
75
+ * user's webhook factory — which may create real HTTP endpoints or
76
+ * external resources — *before* calling `doStart`. Without an explicit
77
+ * capability signal on the model, the SDK would eagerly create a webhook
78
+ * endpoint for every provider, even those that silently ignore the URL.
79
+ */
80
+ handleWebhookOption?: (options: {
81
+ webhook: () => PromiseLike<{
82
+ url: string;
83
+ received: PromiseLike<VideoModelV4OperationWebhook>;
84
+ }>;
85
+ }) => PromiseLike<{
86
+ webhookUrl: string;
87
+ received: PromiseLike<VideoModelV4OperationWebhook>;
88
+ }>;
89
+
90
+ /**
91
+ * Starts an asynchronous video generation and returns an opaque operation
92
+ * reference that can be passed to `doStatus` to poll for completion.
93
+ *
94
+ * When both `doStart` and `doStatus` are implemented, the SDK core can
95
+ * orchestrate polling or webhook-based completion instead of requiring
96
+ * the provider to implement its own polling loop in `doGenerate`.
44
97
  */
45
- doGenerate(options: VideoModelV4CallOptions): PromiseLike<VideoModelV4Result>;
98
+ doStart?(
99
+ options: VideoModelV4CallOptions & {
100
+ /**
101
+ * When provided, the provider should register this URL to receive
102
+ * a webhook notification when the video generation completes.
103
+ */
104
+ webhookUrl?: string;
105
+ },
106
+ ): PromiseLike<VideoModelV4OperationStartResult>;
107
+
108
+ /**
109
+ * Checks the status of an asynchronous video generation that was
110
+ * started with `doStart`.
111
+ *
112
+ * Returns either a `pending` status or a `completed` status with the
113
+ * generated videos.
114
+ */
115
+ doStatus?(options: {
116
+ /**
117
+ * The JSON-serializable opaque operation reference returned by `doStart`.
118
+ */
119
+ operation: JSONValue;
120
+
121
+ /**
122
+ * Abort signal for cancelling the operation.
123
+ */
124
+ abortSignal?: AbortSignal;
125
+
126
+ /**
127
+ * Additional HTTP headers.
128
+ */
129
+ headers?: Record<string, string | undefined>;
130
+ }): PromiseLike<VideoModelV4OperationStatusResult>;
46
131
  };