@ai-sdk/assemblyai 0.0.0-fd764a60-20260114143805

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.
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # AI SDK - AssemblyAI Provider
2
+
3
+ The **[AssemblyAI provider](https://ai-sdk.dev/providers/ai-sdk-providers/assemblyai)** for the [AI SDK](https://ai-sdk.dev/docs)
4
+ contains transcription model support for the AssemblyAI transcription API.
5
+
6
+ ## Setup
7
+
8
+ The AssemblyAI provider is available in the `@ai-sdk/assemblyai` module. You can install it with
9
+
10
+ ```bash
11
+ npm i @ai-sdk/assemblyai
12
+ ```
13
+
14
+ ## Provider Instance
15
+
16
+ You can import the default provider instance `assemblyai` from `@ai-sdk/assemblyai`:
17
+
18
+ ```ts
19
+ import { assemblyai } from '@ai-sdk/assemblyai';
20
+ ```
21
+
22
+ ## Example
23
+
24
+ ```ts
25
+ import { assemblyai } from '@ai-sdk/assemblyai';
26
+ import { experimental_transcribe as transcribe } from 'ai';
27
+
28
+ const { text } = await transcribe({
29
+ model: assemblyai.transcription('best'),
30
+ audio: new URL(
31
+ 'https://github.com/vercel/ai/raw/refs/heads/main/examples/ai-functions/data/galileo.mp3',
32
+ ),
33
+ });
34
+ ```
35
+
36
+ ## Documentation
37
+
38
+ Please check out the **[AssemblyAI provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/assemblyai)** for more information.
@@ -0,0 +1,82 @@
1
+ import { TranscriptionModelV3, ProviderV3 } from '@ai-sdk/provider';
2
+ import { FetchFunction } from '@ai-sdk/provider-utils';
3
+
4
+ type AssemblyAIConfig = {
5
+ provider: string;
6
+ url: (options: {
7
+ modelId: string;
8
+ path: string;
9
+ }) => string;
10
+ headers: () => Record<string, string | undefined>;
11
+ fetch?: FetchFunction;
12
+ generateId?: () => string;
13
+ };
14
+
15
+ type AssemblyAITranscriptionModelId = 'best' | 'nano';
16
+
17
+ interface AssemblyAITranscriptionModelConfig extends AssemblyAIConfig {
18
+ _internal?: {
19
+ currentDate?: () => Date;
20
+ };
21
+ /**
22
+ * The polling interval for checking transcript status in milliseconds.
23
+ */
24
+ pollingInterval?: number;
25
+ }
26
+ declare class AssemblyAITranscriptionModel implements TranscriptionModelV3 {
27
+ readonly modelId: AssemblyAITranscriptionModelId;
28
+ private readonly config;
29
+ readonly specificationVersion = "v3";
30
+ private readonly POLLING_INTERVAL_MS;
31
+ get provider(): string;
32
+ constructor(modelId: AssemblyAITranscriptionModelId, config: AssemblyAITranscriptionModelConfig);
33
+ private getArgs;
34
+ /**
35
+ * Polls the given transcript until we have a status other than `processing` or `queued`.
36
+ *
37
+ * @see https://www.assemblyai.com/docs/getting-started/transcribe-an-audio-file#step-33
38
+ */
39
+ private waitForCompletion;
40
+ doGenerate(options: Parameters<TranscriptionModelV3['doGenerate']>[0]): Promise<Awaited<ReturnType<TranscriptionModelV3['doGenerate']>>>;
41
+ }
42
+
43
+ interface AssemblyAIProvider extends ProviderV3 {
44
+ (modelId: 'best', settings?: {}): {
45
+ transcription: AssemblyAITranscriptionModel;
46
+ };
47
+ /**
48
+ Creates a model for transcription.
49
+ */
50
+ transcription(modelId: AssemblyAITranscriptionModelId): TranscriptionModelV3;
51
+ /**
52
+ * @deprecated Use `embeddingModel` instead.
53
+ */
54
+ textEmbeddingModel(modelId: string): never;
55
+ }
56
+ interface AssemblyAIProviderSettings {
57
+ /**
58
+ API key for authenticating requests.
59
+ */
60
+ apiKey?: string;
61
+ /**
62
+ Custom headers to include in the requests.
63
+ */
64
+ headers?: Record<string, string>;
65
+ /**
66
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
67
+ or to provide a custom fetch implementation for e.g. testing.
68
+ */
69
+ fetch?: FetchFunction;
70
+ }
71
+ /**
72
+ Create an AssemblyAI provider instance.
73
+ */
74
+ declare function createAssemblyAI(options?: AssemblyAIProviderSettings): AssemblyAIProvider;
75
+ /**
76
+ Default AssemblyAI provider instance.
77
+ */
78
+ declare const assemblyai: AssemblyAIProvider;
79
+
80
+ declare const VERSION: string;
81
+
82
+ export { type AssemblyAIProvider, type AssemblyAIProviderSettings, VERSION, assemblyai, createAssemblyAI };
@@ -0,0 +1,82 @@
1
+ import { TranscriptionModelV3, ProviderV3 } from '@ai-sdk/provider';
2
+ import { FetchFunction } from '@ai-sdk/provider-utils';
3
+
4
+ type AssemblyAIConfig = {
5
+ provider: string;
6
+ url: (options: {
7
+ modelId: string;
8
+ path: string;
9
+ }) => string;
10
+ headers: () => Record<string, string | undefined>;
11
+ fetch?: FetchFunction;
12
+ generateId?: () => string;
13
+ };
14
+
15
+ type AssemblyAITranscriptionModelId = 'best' | 'nano';
16
+
17
+ interface AssemblyAITranscriptionModelConfig extends AssemblyAIConfig {
18
+ _internal?: {
19
+ currentDate?: () => Date;
20
+ };
21
+ /**
22
+ * The polling interval for checking transcript status in milliseconds.
23
+ */
24
+ pollingInterval?: number;
25
+ }
26
+ declare class AssemblyAITranscriptionModel implements TranscriptionModelV3 {
27
+ readonly modelId: AssemblyAITranscriptionModelId;
28
+ private readonly config;
29
+ readonly specificationVersion = "v3";
30
+ private readonly POLLING_INTERVAL_MS;
31
+ get provider(): string;
32
+ constructor(modelId: AssemblyAITranscriptionModelId, config: AssemblyAITranscriptionModelConfig);
33
+ private getArgs;
34
+ /**
35
+ * Polls the given transcript until we have a status other than `processing` or `queued`.
36
+ *
37
+ * @see https://www.assemblyai.com/docs/getting-started/transcribe-an-audio-file#step-33
38
+ */
39
+ private waitForCompletion;
40
+ doGenerate(options: Parameters<TranscriptionModelV3['doGenerate']>[0]): Promise<Awaited<ReturnType<TranscriptionModelV3['doGenerate']>>>;
41
+ }
42
+
43
+ interface AssemblyAIProvider extends ProviderV3 {
44
+ (modelId: 'best', settings?: {}): {
45
+ transcription: AssemblyAITranscriptionModel;
46
+ };
47
+ /**
48
+ Creates a model for transcription.
49
+ */
50
+ transcription(modelId: AssemblyAITranscriptionModelId): TranscriptionModelV3;
51
+ /**
52
+ * @deprecated Use `embeddingModel` instead.
53
+ */
54
+ textEmbeddingModel(modelId: string): never;
55
+ }
56
+ interface AssemblyAIProviderSettings {
57
+ /**
58
+ API key for authenticating requests.
59
+ */
60
+ apiKey?: string;
61
+ /**
62
+ Custom headers to include in the requests.
63
+ */
64
+ headers?: Record<string, string>;
65
+ /**
66
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
67
+ or to provide a custom fetch implementation for e.g. testing.
68
+ */
69
+ fetch?: FetchFunction;
70
+ }
71
+ /**
72
+ Create an AssemblyAI provider instance.
73
+ */
74
+ declare function createAssemblyAI(options?: AssemblyAIProviderSettings): AssemblyAIProvider;
75
+ /**
76
+ Default AssemblyAI provider instance.
77
+ */
78
+ declare const assemblyai: AssemblyAIProvider;
79
+
80
+ declare const VERSION: string;
81
+
82
+ export { type AssemblyAIProvider, type AssemblyAIProviderSettings, VERSION, assemblyai, createAssemblyAI };
package/dist/index.js ADDED
@@ -0,0 +1,456 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ VERSION: () => VERSION,
24
+ assemblyai: () => assemblyai,
25
+ createAssemblyAI: () => createAssemblyAI
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/assemblyai-provider.ts
30
+ var import_provider = require("@ai-sdk/provider");
31
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
32
+
33
+ // src/assemblyai-transcription-model.ts
34
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
35
+ var import_v42 = require("zod/v4");
36
+
37
+ // src/assemblyai-error.ts
38
+ var import_v4 = require("zod/v4");
39
+ var import_provider_utils = require("@ai-sdk/provider-utils");
40
+ var assemblyaiErrorDataSchema = import_v4.z.object({
41
+ error: import_v4.z.object({
42
+ message: import_v4.z.string(),
43
+ code: import_v4.z.number()
44
+ })
45
+ });
46
+ var assemblyaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
47
+ errorSchema: assemblyaiErrorDataSchema,
48
+ errorToMessage: (data) => data.error.message
49
+ });
50
+
51
+ // src/assemblyai-transcription-model.ts
52
+ var assemblyaiProviderOptionsSchema = import_v42.z.object({
53
+ /**
54
+ * End time of the audio in milliseconds.
55
+ */
56
+ audioEndAt: import_v42.z.number().int().nullish(),
57
+ /**
58
+ * Start time of the audio in milliseconds.
59
+ */
60
+ audioStartFrom: import_v42.z.number().int().nullish(),
61
+ /**
62
+ * Whether to automatically generate chapters for the transcription.
63
+ */
64
+ autoChapters: import_v42.z.boolean().nullish(),
65
+ /**
66
+ * Whether to automatically generate highlights for the transcription.
67
+ */
68
+ autoHighlights: import_v42.z.boolean().nullish(),
69
+ /**
70
+ * Boost parameter for the transcription.
71
+ * Allowed values: 'low', 'default', 'high'.
72
+ */
73
+ boostParam: import_v42.z.string().nullish(),
74
+ /**
75
+ * Whether to enable content safety filtering.
76
+ */
77
+ contentSafety: import_v42.z.boolean().nullish(),
78
+ /**
79
+ * Confidence threshold for content safety filtering (25-100).
80
+ */
81
+ contentSafetyConfidence: import_v42.z.number().int().min(25).max(100).nullish(),
82
+ /**
83
+ * Custom spelling rules for the transcription.
84
+ */
85
+ customSpelling: import_v42.z.array(
86
+ import_v42.z.object({
87
+ from: import_v42.z.array(import_v42.z.string()),
88
+ to: import_v42.z.string()
89
+ })
90
+ ).nullish(),
91
+ /**
92
+ * Whether to include filler words (um, uh, etc.) in the transcription.
93
+ */
94
+ disfluencies: import_v42.z.boolean().nullish(),
95
+ /**
96
+ * Whether to enable entity detection.
97
+ */
98
+ entityDetection: import_v42.z.boolean().nullish(),
99
+ /**
100
+ * Whether to filter profanity from the transcription.
101
+ */
102
+ filterProfanity: import_v42.z.boolean().nullish(),
103
+ /**
104
+ * Whether to format text with punctuation and capitalization.
105
+ */
106
+ formatText: import_v42.z.boolean().nullish(),
107
+ /**
108
+ * Whether to enable IAB categories detection.
109
+ */
110
+ iabCategories: import_v42.z.boolean().nullish(),
111
+ /**
112
+ * Language code for the transcription.
113
+ */
114
+ languageCode: import_v42.z.union([import_v42.z.literal("en"), import_v42.z.string()]).nullish(),
115
+ /**
116
+ * Confidence threshold for language detection.
117
+ */
118
+ languageConfidenceThreshold: import_v42.z.number().nullish(),
119
+ /**
120
+ * Whether to enable language detection.
121
+ */
122
+ languageDetection: import_v42.z.boolean().nullish(),
123
+ /**
124
+ * Whether to process audio as multichannel.
125
+ */
126
+ multichannel: import_v42.z.boolean().nullish(),
127
+ /**
128
+ * Whether to add punctuation to the transcription.
129
+ */
130
+ punctuate: import_v42.z.boolean().nullish(),
131
+ /**
132
+ * Whether to redact personally identifiable information (PII).
133
+ */
134
+ redactPii: import_v42.z.boolean().nullish(),
135
+ /**
136
+ * Whether to redact PII in the audio file.
137
+ */
138
+ redactPiiAudio: import_v42.z.boolean().nullish(),
139
+ /**
140
+ * Audio format for PII redaction.
141
+ */
142
+ redactPiiAudioQuality: import_v42.z.string().nullish(),
143
+ /**
144
+ * List of PII types to redact.
145
+ */
146
+ redactPiiPolicies: import_v42.z.array(import_v42.z.string()).nullish(),
147
+ /**
148
+ * Substitution method for redacted PII.
149
+ */
150
+ redactPiiSub: import_v42.z.string().nullish(),
151
+ /**
152
+ * Whether to enable sentiment analysis.
153
+ */
154
+ sentimentAnalysis: import_v42.z.boolean().nullish(),
155
+ /**
156
+ * Whether to identify different speakers in the audio.
157
+ */
158
+ speakerLabels: import_v42.z.boolean().nullish(),
159
+ /**
160
+ * Number of speakers expected in the audio.
161
+ */
162
+ speakersExpected: import_v42.z.number().int().nullish(),
163
+ /**
164
+ * Threshold for speech detection (0-1).
165
+ */
166
+ speechThreshold: import_v42.z.number().min(0).max(1).nullish(),
167
+ /**
168
+ * Whether to generate a summary of the transcription.
169
+ */
170
+ summarization: import_v42.z.boolean().nullish(),
171
+ /**
172
+ * Model to use for summarization.
173
+ */
174
+ summaryModel: import_v42.z.string().nullish(),
175
+ /**
176
+ * Type of summary to generate.
177
+ */
178
+ summaryType: import_v42.z.string().nullish(),
179
+ /**
180
+ * Name of the authentication header for webhook requests.
181
+ */
182
+ webhookAuthHeaderName: import_v42.z.string().nullish(),
183
+ /**
184
+ * Value of the authentication header for webhook requests.
185
+ */
186
+ webhookAuthHeaderValue: import_v42.z.string().nullish(),
187
+ /**
188
+ * URL to send webhook notifications to.
189
+ */
190
+ webhookUrl: import_v42.z.string().nullish(),
191
+ /**
192
+ * List of words to boost recognition for.
193
+ */
194
+ wordBoost: import_v42.z.array(import_v42.z.string()).nullish()
195
+ });
196
+ var AssemblyAITranscriptionModel = class {
197
+ constructor(modelId, config) {
198
+ this.modelId = modelId;
199
+ this.config = config;
200
+ this.specificationVersion = "v3";
201
+ this.POLLING_INTERVAL_MS = 3e3;
202
+ }
203
+ get provider() {
204
+ return this.config.provider;
205
+ }
206
+ async getArgs({
207
+ providerOptions
208
+ }) {
209
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H;
210
+ const warnings = [];
211
+ const assemblyaiOptions = await (0, import_provider_utils2.parseProviderOptions)({
212
+ provider: "assemblyai",
213
+ providerOptions,
214
+ schema: assemblyaiProviderOptionsSchema
215
+ });
216
+ const body = {
217
+ speech_model: this.modelId
218
+ };
219
+ if (assemblyaiOptions) {
220
+ body.audio_end_at = (_a = assemblyaiOptions.audioEndAt) != null ? _a : void 0;
221
+ body.audio_start_from = (_b = assemblyaiOptions.audioStartFrom) != null ? _b : void 0;
222
+ body.auto_chapters = (_c = assemblyaiOptions.autoChapters) != null ? _c : void 0;
223
+ body.auto_highlights = (_d = assemblyaiOptions.autoHighlights) != null ? _d : void 0;
224
+ body.boost_param = (_e = assemblyaiOptions.boostParam) != null ? _e : void 0;
225
+ body.content_safety = (_f = assemblyaiOptions.contentSafety) != null ? _f : void 0;
226
+ body.content_safety_confidence = (_g = assemblyaiOptions.contentSafetyConfidence) != null ? _g : void 0;
227
+ body.custom_spelling = (_h = assemblyaiOptions.customSpelling) != null ? _h : void 0;
228
+ body.disfluencies = (_i = assemblyaiOptions.disfluencies) != null ? _i : void 0;
229
+ body.entity_detection = (_j = assemblyaiOptions.entityDetection) != null ? _j : void 0;
230
+ body.filter_profanity = (_k = assemblyaiOptions.filterProfanity) != null ? _k : void 0;
231
+ body.format_text = (_l = assemblyaiOptions.formatText) != null ? _l : void 0;
232
+ body.iab_categories = (_m = assemblyaiOptions.iabCategories) != null ? _m : void 0;
233
+ body.language_code = (_n = assemblyaiOptions.languageCode) != null ? _n : void 0;
234
+ body.language_confidence_threshold = (_o = assemblyaiOptions.languageConfidenceThreshold) != null ? _o : void 0;
235
+ body.language_detection = (_p = assemblyaiOptions.languageDetection) != null ? _p : void 0;
236
+ body.multichannel = (_q = assemblyaiOptions.multichannel) != null ? _q : void 0;
237
+ body.punctuate = (_r = assemblyaiOptions.punctuate) != null ? _r : void 0;
238
+ body.redact_pii = (_s = assemblyaiOptions.redactPii) != null ? _s : void 0;
239
+ body.redact_pii_audio = (_t = assemblyaiOptions.redactPiiAudio) != null ? _t : void 0;
240
+ body.redact_pii_audio_quality = (_u = assemblyaiOptions.redactPiiAudioQuality) != null ? _u : void 0;
241
+ body.redact_pii_policies = (_v = assemblyaiOptions.redactPiiPolicies) != null ? _v : void 0;
242
+ body.redact_pii_sub = (_w = assemblyaiOptions.redactPiiSub) != null ? _w : void 0;
243
+ body.sentiment_analysis = (_x = assemblyaiOptions.sentimentAnalysis) != null ? _x : void 0;
244
+ body.speaker_labels = (_y = assemblyaiOptions.speakerLabels) != null ? _y : void 0;
245
+ body.speakers_expected = (_z = assemblyaiOptions.speakersExpected) != null ? _z : void 0;
246
+ body.speech_threshold = (_A = assemblyaiOptions.speechThreshold) != null ? _A : void 0;
247
+ body.summarization = (_B = assemblyaiOptions.summarization) != null ? _B : void 0;
248
+ body.summary_model = (_C = assemblyaiOptions.summaryModel) != null ? _C : void 0;
249
+ body.summary_type = (_D = assemblyaiOptions.summaryType) != null ? _D : void 0;
250
+ body.webhook_auth_header_name = (_E = assemblyaiOptions.webhookAuthHeaderName) != null ? _E : void 0;
251
+ body.webhook_auth_header_value = (_F = assemblyaiOptions.webhookAuthHeaderValue) != null ? _F : void 0;
252
+ body.webhook_url = (_G = assemblyaiOptions.webhookUrl) != null ? _G : void 0;
253
+ body.word_boost = (_H = assemblyaiOptions.wordBoost) != null ? _H : void 0;
254
+ }
255
+ return {
256
+ body,
257
+ warnings
258
+ };
259
+ }
260
+ /**
261
+ * Polls the given transcript until we have a status other than `processing` or `queued`.
262
+ *
263
+ * @see https://www.assemblyai.com/docs/getting-started/transcribe-an-audio-file#step-33
264
+ */
265
+ async waitForCompletion(transcriptId, headers, abortSignal) {
266
+ var _a, _b;
267
+ const pollingInterval = (_a = this.config.pollingInterval) != null ? _a : this.POLLING_INTERVAL_MS;
268
+ while (true) {
269
+ if (abortSignal == null ? void 0 : abortSignal.aborted) {
270
+ throw new Error("Transcription request was aborted");
271
+ }
272
+ const response = await fetch(
273
+ this.config.url({
274
+ path: `/v2/transcript/${transcriptId}`,
275
+ modelId: this.modelId
276
+ }),
277
+ {
278
+ method: "GET",
279
+ headers: (0, import_provider_utils2.combineHeaders)(
280
+ this.config.headers(),
281
+ headers
282
+ ),
283
+ signal: abortSignal
284
+ }
285
+ );
286
+ if (!response.ok) {
287
+ throw await assemblyaiFailedResponseHandler({
288
+ response,
289
+ url: this.config.url({
290
+ path: `/v2/transcript/${transcriptId}`,
291
+ modelId: this.modelId
292
+ }),
293
+ requestBodyValues: {}
294
+ });
295
+ }
296
+ const transcript = assemblyaiTranscriptionResponseSchema.parse(
297
+ await response.json()
298
+ );
299
+ if (transcript.status === "completed") {
300
+ return {
301
+ transcript,
302
+ responseHeaders: (0, import_provider_utils2.extractResponseHeaders)(response)
303
+ };
304
+ }
305
+ if (transcript.status === "error") {
306
+ throw new Error(
307
+ `Transcription failed: ${(_b = transcript.error) != null ? _b : "Unknown error"}`
308
+ );
309
+ }
310
+ await new Promise((resolve) => setTimeout(resolve, pollingInterval));
311
+ }
312
+ }
313
+ async doGenerate(options) {
314
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
315
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
316
+ const { value: uploadResponse } = await (0, import_provider_utils2.postToApi)({
317
+ url: this.config.url({
318
+ path: "/v2/upload",
319
+ modelId: ""
320
+ }),
321
+ headers: {
322
+ "Content-Type": "application/octet-stream",
323
+ ...(0, import_provider_utils2.combineHeaders)(this.config.headers(), options.headers)
324
+ },
325
+ body: {
326
+ content: options.audio,
327
+ values: options.audio
328
+ },
329
+ failedResponseHandler: assemblyaiFailedResponseHandler,
330
+ successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
331
+ assemblyaiUploadResponseSchema
332
+ ),
333
+ abortSignal: options.abortSignal,
334
+ fetch: this.config.fetch
335
+ });
336
+ const { body, warnings } = await this.getArgs(options);
337
+ const { value: submitResponse } = await (0, import_provider_utils2.postJsonToApi)({
338
+ url: this.config.url({
339
+ path: "/v2/transcript",
340
+ modelId: this.modelId
341
+ }),
342
+ headers: (0, import_provider_utils2.combineHeaders)(this.config.headers(), options.headers),
343
+ body: {
344
+ ...body,
345
+ audio_url: uploadResponse.upload_url
346
+ },
347
+ failedResponseHandler: assemblyaiFailedResponseHandler,
348
+ successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
349
+ assemblyaiSubmitResponseSchema
350
+ ),
351
+ abortSignal: options.abortSignal,
352
+ fetch: this.config.fetch
353
+ });
354
+ const { transcript, responseHeaders } = await this.waitForCompletion(
355
+ submitResponse.id,
356
+ options.headers,
357
+ options.abortSignal
358
+ );
359
+ return {
360
+ text: (_d = transcript.text) != null ? _d : "",
361
+ segments: (_f = (_e = transcript.words) == null ? void 0 : _e.map((word) => ({
362
+ text: word.text,
363
+ startSecond: word.start,
364
+ endSecond: word.end
365
+ }))) != null ? _f : [],
366
+ language: (_g = transcript.language_code) != null ? _g : void 0,
367
+ durationInSeconds: (_k = (_j = transcript.audio_duration) != null ? _j : (_i = (_h = transcript.words) == null ? void 0 : _h.at(-1)) == null ? void 0 : _i.end) != null ? _k : void 0,
368
+ warnings,
369
+ response: {
370
+ timestamp: currentDate,
371
+ modelId: this.modelId,
372
+ headers: responseHeaders,
373
+ // Headers from final GET request
374
+ body: transcript
375
+ // Raw response from final GET request
376
+ }
377
+ };
378
+ }
379
+ };
380
+ var assemblyaiUploadResponseSchema = import_v42.z.object({
381
+ upload_url: import_v42.z.string()
382
+ });
383
+ var assemblyaiSubmitResponseSchema = import_v42.z.object({
384
+ id: import_v42.z.string(),
385
+ status: import_v42.z.enum(["queued", "processing", "completed", "error"])
386
+ });
387
+ var assemblyaiTranscriptionResponseSchema = import_v42.z.object({
388
+ id: import_v42.z.string(),
389
+ status: import_v42.z.enum(["queued", "processing", "completed", "error"]),
390
+ text: import_v42.z.string().nullish(),
391
+ language_code: import_v42.z.string().nullish(),
392
+ words: import_v42.z.array(
393
+ import_v42.z.object({
394
+ start: import_v42.z.number(),
395
+ end: import_v42.z.number(),
396
+ text: import_v42.z.string()
397
+ })
398
+ ).nullish(),
399
+ audio_duration: import_v42.z.number().nullish(),
400
+ error: import_v42.z.string().nullish()
401
+ });
402
+
403
+ // src/version.ts
404
+ var VERSION = true ? "0.0.0-fd764a60-20260114143805" : "0.0.0-test";
405
+
406
+ // src/assemblyai-provider.ts
407
+ function createAssemblyAI(options = {}) {
408
+ const getHeaders = () => (0, import_provider_utils3.withUserAgentSuffix)(
409
+ {
410
+ authorization: (0, import_provider_utils3.loadApiKey)({
411
+ apiKey: options.apiKey,
412
+ environmentVariableName: "ASSEMBLYAI_API_KEY",
413
+ description: "AssemblyAI"
414
+ }),
415
+ ...options.headers
416
+ },
417
+ `ai-sdk/assemblyai/${VERSION}`
418
+ );
419
+ const createTranscriptionModel = (modelId) => new AssemblyAITranscriptionModel(modelId, {
420
+ provider: `assemblyai.transcription`,
421
+ url: ({ path }) => `https://api.assemblyai.com${path}`,
422
+ headers: getHeaders,
423
+ fetch: options.fetch
424
+ });
425
+ const provider = function(modelId) {
426
+ return {
427
+ transcription: createTranscriptionModel(modelId)
428
+ };
429
+ };
430
+ provider.specificationVersion = "v3";
431
+ provider.transcription = createTranscriptionModel;
432
+ provider.transcriptionModel = createTranscriptionModel;
433
+ provider.languageModel = () => {
434
+ throw new import_provider.NoSuchModelError({
435
+ modelId: "unknown",
436
+ modelType: "languageModel",
437
+ message: "AssemblyAI does not provide language models"
438
+ });
439
+ };
440
+ provider.embeddingModel = (modelId) => {
441
+ throw new import_provider.NoSuchModelError({ modelId, modelType: "embeddingModel" });
442
+ };
443
+ provider.textEmbeddingModel = provider.embeddingModel;
444
+ provider.imageModel = (modelId) => {
445
+ throw new import_provider.NoSuchModelError({ modelId, modelType: "imageModel" });
446
+ };
447
+ return provider;
448
+ }
449
+ var assemblyai = createAssemblyAI();
450
+ // Annotate the CommonJS export names for ESM import in node:
451
+ 0 && (module.exports = {
452
+ VERSION,
453
+ assemblyai,
454
+ createAssemblyAI
455
+ });
456
+ //# sourceMappingURL=index.js.map