ai 7.0.36 → 7.0.38
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/CHANGELOG.md +19 -0
- package/dist/index.d.ts +263 -40
- package/dist/index.js +684 -423
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/test/index.d.ts +14 -2
- package/dist/test/index.js +15 -0
- package/dist/test/index.js.map +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +1 -0
- package/docs/03-ai-sdk-core/36-transcription.mdx +40 -35
- package/docs/03-ai-sdk-core/36-translation.mdx +196 -0
- package/docs/03-ai-sdk-core/index.mdx +5 -0
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/11-stream-translate.mdx +176 -0
- package/docs/07-reference/01-ai-sdk-core/index.mdx +5 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-translation-generated-error.mdx +26 -0
- package/docs/07-reference/05-ai-sdk-errors/index.mdx +1 -0
- package/package.json +4 -4
- package/src/error/index.ts +1 -0
- package/src/error/no-translation-generated-error.ts +28 -0
- package/src/generate-text/generate-text.ts +4 -1
- package/src/generate-text/stream-language-model-call.ts +14 -12
- package/src/generate-text/stream-text-result.ts +3 -2
- package/src/index.ts +1 -0
- package/src/model/resolve-model.ts +35 -0
- package/src/test/mock-speech-translation-model-v4.ts +24 -0
- package/src/transcribe/stream-transcribe.ts +2 -11
- package/src/translate/index.ts +5 -0
- package/src/translate/stream-translate-result.ts +146 -0
- package/src/translate/stream-translate.ts +374 -0
- package/src/types/speech-translation-model-response-metadata.ts +22 -0
- package/src/types/speech-translation-model.ts +11 -0
package/dist/test/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { convertArrayToAsyncIterable, convertArrayToReadableStream, convertReadableStreamToArray, mockId } from '@ai-sdk/provider-utils/test';
|
|
2
|
-
import { EmbeddingModelV3, EmbeddingModelV4, ImageModelV3, ImageModelV4, LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult, LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, ProviderV3, TranscriptionModelV3, SpeechModelV3, RerankingModelV3, ProviderV4, TranscriptionModelV4, SpeechModelV4, RerankingModelV4, Experimental_VideoModelV3, Experimental_VideoModelV4 } from '@ai-sdk/provider';
|
|
2
|
+
import { EmbeddingModelV3, EmbeddingModelV4, ImageModelV3, ImageModelV4, LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult, LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, ProviderV3, TranscriptionModelV3, SpeechModelV3, RerankingModelV3, ProviderV4, TranscriptionModelV4, SpeechModelV4, RerankingModelV4, Experimental_SpeechTranslationModelV4, Experimental_VideoModelV3, Experimental_VideoModelV4 } from '@ai-sdk/provider';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Creates a ReadableStream that emits the provided values with an optional delay between each value.
|
|
@@ -179,6 +179,18 @@ declare class MockSpeechModelV4 implements SpeechModelV4 {
|
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
declare class MockSpeechTranslationModelV4 implements Experimental_SpeechTranslationModelV4 {
|
|
183
|
+
readonly specificationVersion = "v4";
|
|
184
|
+
readonly provider: Experimental_SpeechTranslationModelV4['provider'];
|
|
185
|
+
readonly modelId: Experimental_SpeechTranslationModelV4['modelId'];
|
|
186
|
+
doStream: Experimental_SpeechTranslationModelV4['doStream'];
|
|
187
|
+
constructor({ provider, modelId, doStream, }?: {
|
|
188
|
+
provider?: Experimental_SpeechTranslationModelV4['provider'];
|
|
189
|
+
modelId?: Experimental_SpeechTranslationModelV4['modelId'];
|
|
190
|
+
doStream?: Experimental_SpeechTranslationModelV4['doStream'];
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
182
194
|
declare class MockTranscriptionModelV3 implements TranscriptionModelV3 {
|
|
183
195
|
readonly specificationVersion = "v3";
|
|
184
196
|
readonly provider: TranscriptionModelV3['provider'];
|
|
@@ -264,4 +276,4 @@ declare function mockValues<T>(...values: T[]): () => T;
|
|
|
264
276
|
*/
|
|
265
277
|
declare const simulateReadableStream: typeof simulateReadableStream$1;
|
|
266
278
|
|
|
267
|
-
export { MockEmbeddingModelV3, MockEmbeddingModelV4, MockImageModelV3, MockImageModelV4, MockLanguageModelV3, MockLanguageModelV4, MockProviderV3, MockProviderV4, MockRerankingModelV3, MockRerankingModelV4, MockSpeechModelV3, MockSpeechModelV4, MockTranscriptionModelV3, MockTranscriptionModelV4, MockVideoModelV3, MockVideoModelV4, mockValues, simulateReadableStream };
|
|
279
|
+
export { MockSpeechTranslationModelV4 as Experimental_MockSpeechTranslationModelV4, MockEmbeddingModelV3, MockEmbeddingModelV4, MockImageModelV3, MockImageModelV4, MockLanguageModelV3, MockLanguageModelV4, MockProviderV3, MockProviderV4, MockRerankingModelV3, MockRerankingModelV4, MockSpeechModelV3, MockSpeechModelV4, MockTranscriptionModelV3, MockTranscriptionModelV4, MockVideoModelV3, MockVideoModelV4, mockValues, simulateReadableStream };
|
package/dist/test/index.js
CHANGED
|
@@ -349,6 +349,20 @@ var MockSpeechModelV4 = class {
|
|
|
349
349
|
}
|
|
350
350
|
};
|
|
351
351
|
|
|
352
|
+
// src/test/mock-speech-translation-model-v4.ts
|
|
353
|
+
var MockSpeechTranslationModelV4 = class {
|
|
354
|
+
constructor({
|
|
355
|
+
provider = "mock-provider",
|
|
356
|
+
modelId = "mock-model-id",
|
|
357
|
+
doStream = notImplemented
|
|
358
|
+
} = {}) {
|
|
359
|
+
this.specificationVersion = "v4";
|
|
360
|
+
this.provider = provider;
|
|
361
|
+
this.modelId = modelId;
|
|
362
|
+
this.doStream = doStream;
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
|
|
352
366
|
// src/test/mock-transcription-model-v3.ts
|
|
353
367
|
var MockTranscriptionModelV3 = class {
|
|
354
368
|
constructor({
|
|
@@ -448,6 +462,7 @@ function mockValues(...values) {
|
|
|
448
462
|
// test/index.ts
|
|
449
463
|
var simulateReadableStream2 = simulateReadableStream;
|
|
450
464
|
export {
|
|
465
|
+
MockSpeechTranslationModelV4 as Experimental_MockSpeechTranslationModelV4,
|
|
451
466
|
MockEmbeddingModelV3,
|
|
452
467
|
MockEmbeddingModelV4,
|
|
453
468
|
MockImageModelV3,
|
package/dist/test/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/simulate-readable-stream.ts","../../test/index.ts","../../src/test/not-implemented.ts","../../src/test/mock-embedding-model-v3.ts","../../src/test/mock-embedding-model-v4.ts","../../src/test/mock-image-model-v3.ts","../../src/test/mock-image-model-v4.ts","../../src/test/mock-language-model-v3.ts","../../src/test/mock-language-model-v4.ts","../../src/test/mock-provider-v3.ts","../../src/test/mock-provider-v4.ts","../../src/test/mock-speech-model-v3.ts","../../src/test/mock-speech-model-v4.ts","../../src/test/mock-transcription-model-v3.ts","../../src/test/mock-transcription-model-v4.ts","../../src/test/mock-reranking-model-v3.ts","../../src/test/mock-reranking-model-v4.ts","../../src/test/mock-video-model-v3.ts","../../src/test/mock-video-model-v4.ts","../../src/test/mock-values.ts"],"sourcesContent":["import { delay as delayFunction } from '@ai-sdk/provider-utils';\n\n/**\n * Creates a ReadableStream that emits the provided values with an optional delay between each value.\n *\n * @param options - The configuration options\n * @param options.chunks - Array of values to be emitted by the stream\n * @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @returns A ReadableStream that emits the provided values\n */\nexport function simulateReadableStream<T>({\n chunks,\n initialDelayInMs = 0,\n chunkDelayInMs = 0,\n _internal,\n}: {\n chunks: T[];\n initialDelayInMs?: number | null;\n chunkDelayInMs?: number | null;\n _internal?: {\n delay?: (ms: number | null) => Promise<void>;\n };\n}): ReadableStream<T> {\n const delay = _internal?.delay ?? delayFunction;\n\n let index = 0;\n\n return new ReadableStream({\n async pull(controller) {\n if (index < chunks.length) {\n await delay(index === 0 ? initialDelayInMs : chunkDelayInMs);\n controller.enqueue(chunks[index++]);\n } else {\n controller.close();\n }\n },\n });\n}\n","import { simulateReadableStream as originalSimulateReadableStream } from '../src/util/simulate-readable-stream';\n\nexport {\n convertArrayToAsyncIterable,\n convertArrayToReadableStream,\n convertReadableStreamToArray,\n mockId,\n} from '@ai-sdk/provider-utils/test';\nexport { MockEmbeddingModelV3 } from '../src/test/mock-embedding-model-v3';\nexport { MockEmbeddingModelV4 } from '../src/test/mock-embedding-model-v4';\nexport { MockImageModelV3 } from '../src/test/mock-image-model-v3';\nexport { MockImageModelV4 } from '../src/test/mock-image-model-v4';\nexport { MockLanguageModelV3 } from '../src/test/mock-language-model-v3';\nexport { MockLanguageModelV4 } from '../src/test/mock-language-model-v4';\nexport { MockProviderV3 } from '../src/test/mock-provider-v3';\nexport { MockProviderV4 } from '../src/test/mock-provider-v4';\nexport { MockSpeechModelV3 } from '../src/test/mock-speech-model-v3';\nexport { MockSpeechModelV4 } from '../src/test/mock-speech-model-v4';\nexport { MockTranscriptionModelV3 } from '../src/test/mock-transcription-model-v3';\nexport { MockTranscriptionModelV4 } from '../src/test/mock-transcription-model-v4';\nexport { MockRerankingModelV3 } from '../src/test/mock-reranking-model-v3';\nexport { MockRerankingModelV4 } from '../src/test/mock-reranking-model-v4';\nexport { MockVideoModelV3 } from '../src/test/mock-video-model-v3';\nexport { MockVideoModelV4 } from '../src/test/mock-video-model-v4';\nexport { mockValues } from '../src/test/mock-values';\n\n/**\n * @deprecated Use `simulateReadableStream` from `ai` instead.\n */\nexport const simulateReadableStream = originalSimulateReadableStream;\n","export function notImplemented(): never {\n throw new Error('Not implemented');\n}\n","import type { EmbeddingModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV3 implements EmbeddingModelV3 {\n readonly specificationVersion = 'v3';\n\n readonly provider: EmbeddingModelV3['provider'];\n readonly modelId: EmbeddingModelV3['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV3['maxEmbeddingsPerCall'];\n readonly supportsParallelCalls: EmbeddingModelV3['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV3['doEmbed'];\n\n doEmbedCalls: Parameters<EmbeddingModelV3['doEmbed']>[0][] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV3['provider'];\n modelId?: EmbeddingModelV3['modelId'];\n maxEmbeddingsPerCall?: EmbeddingModelV3['maxEmbeddingsPerCall'] | null;\n supportsParallelCalls?: EmbeddingModelV3['supportsParallelCalls'];\n doEmbed?:\n | EmbeddingModelV3['doEmbed']\n | Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>\n | Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = async options => {\n this.doEmbedCalls.push(options);\n\n if (typeof doEmbed === 'function') {\n return doEmbed(options);\n } else if (Array.isArray(doEmbed)) {\n return doEmbed[this.doEmbedCalls.length - 1];\n } else {\n return doEmbed;\n }\n };\n }\n}\n","import type { EmbeddingModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV4 implements EmbeddingModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly provider: EmbeddingModelV4['provider'];\n readonly modelId: EmbeddingModelV4['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV4['maxEmbeddingsPerCall'];\n readonly supportsParallelCalls: EmbeddingModelV4['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV4['doEmbed'];\n\n doEmbedCalls: Parameters<EmbeddingModelV4['doEmbed']>[0][] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV4['provider'];\n modelId?: EmbeddingModelV4['modelId'];\n maxEmbeddingsPerCall?: EmbeddingModelV4['maxEmbeddingsPerCall'] | null;\n supportsParallelCalls?: EmbeddingModelV4['supportsParallelCalls'];\n doEmbed?:\n | EmbeddingModelV4['doEmbed']\n | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>\n | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = async options => {\n this.doEmbedCalls.push(options);\n\n if (typeof doEmbed === 'function') {\n return doEmbed(options);\n } else if (Array.isArray(doEmbed)) {\n return doEmbed[this.doEmbedCalls.length - 1];\n } else {\n return doEmbed;\n }\n };\n }\n}\n","import type { ImageModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockImageModelV3 implements ImageModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: ImageModelV3['provider'];\n readonly modelId: ImageModelV3['modelId'];\n readonly maxImagesPerCall: ImageModelV3['maxImagesPerCall'];\n\n doGenerate: ImageModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV3['provider'];\n modelId?: ImageModelV3['modelId'];\n maxImagesPerCall?: ImageModelV3['maxImagesPerCall'];\n doGenerate?: ImageModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type { ImageModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockImageModelV4 implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: ImageModelV4['provider'];\n readonly modelId: ImageModelV4['modelId'];\n readonly maxImagesPerCall: ImageModelV4['maxImagesPerCall'];\n\n doGenerate: ImageModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV4['provider'];\n modelId?: ImageModelV4['modelId'];\n maxImagesPerCall?: ImageModelV4['maxImagesPerCall'];\n doGenerate?: ImageModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type {\n LanguageModelV3,\n LanguageModelV3CallOptions,\n LanguageModelV3GenerateResult,\n LanguageModelV3StreamResult,\n} from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV3 implements LanguageModelV3 {\n readonly specificationVersion = 'v3';\n\n private _supportedUrls: () => LanguageModelV3['supportedUrls'];\n\n readonly provider: LanguageModelV3['provider'];\n readonly modelId: LanguageModelV3['modelId'];\n\n doGenerate: LanguageModelV3['doGenerate'];\n doStream: LanguageModelV3['doStream'];\n\n doGenerateCalls: LanguageModelV3CallOptions[] = [];\n doStreamCalls: LanguageModelV3CallOptions[] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedUrls = {},\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: LanguageModelV3['provider'];\n modelId?: LanguageModelV3['modelId'];\n supportedUrls?:\n | LanguageModelV3['supportedUrls']\n | (() => LanguageModelV3['supportedUrls']);\n doGenerate?:\n | LanguageModelV3['doGenerate']\n | LanguageModelV3GenerateResult\n | LanguageModelV3GenerateResult[];\n doStream?:\n | LanguageModelV3['doStream']\n | LanguageModelV3StreamResult\n | LanguageModelV3StreamResult[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = async options => {\n this.doGenerateCalls.push(options);\n\n if (typeof doGenerate === 'function') {\n return await doGenerate(options);\n } else if (Array.isArray(doGenerate)) {\n return doGenerate[this.doGenerateCalls.length - 1];\n } else {\n return doGenerate;\n }\n };\n this.doStream = async options => {\n this.doStreamCalls.push(options);\n\n if (typeof doStream === 'function') {\n return await doStream(options);\n } else if (Array.isArray(doStream)) {\n return doStream[this.doStreamCalls.length - 1];\n } else {\n return doStream;\n }\n };\n this._supportedUrls =\n typeof supportedUrls === 'function'\n ? supportedUrls\n : async () => await supportedUrls;\n }\n\n get supportedUrls() {\n return this._supportedUrls();\n }\n}\n","import type {\n LanguageModelV4,\n LanguageModelV4CallOptions,\n LanguageModelV4GenerateResult,\n LanguageModelV4StreamResult,\n} from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV4 implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\n\n private _supportedUrls: () => LanguageModelV4['supportedUrls'];\n\n readonly provider: LanguageModelV4['provider'];\n readonly modelId: LanguageModelV4['modelId'];\n\n doGenerate: LanguageModelV4['doGenerate'];\n doStream: LanguageModelV4['doStream'];\n\n doGenerateCalls: LanguageModelV4CallOptions[] = [];\n doStreamCalls: LanguageModelV4CallOptions[] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedUrls = {},\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: LanguageModelV4['provider'];\n modelId?: LanguageModelV4['modelId'];\n supportedUrls?:\n | LanguageModelV4['supportedUrls']\n | (() => LanguageModelV4['supportedUrls']);\n doGenerate?:\n | LanguageModelV4['doGenerate']\n | LanguageModelV4GenerateResult\n | LanguageModelV4GenerateResult[];\n doStream?:\n | LanguageModelV4['doStream']\n | LanguageModelV4StreamResult\n | LanguageModelV4StreamResult[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = async options => {\n this.doGenerateCalls.push(options);\n\n if (typeof doGenerate === 'function') {\n return await doGenerate(options);\n } else if (Array.isArray(doGenerate)) {\n return doGenerate[this.doGenerateCalls.length - 1];\n } else {\n return doGenerate;\n }\n };\n this.doStream = async options => {\n this.doStreamCalls.push(options);\n\n if (typeof doStream === 'function') {\n return await doStream(options);\n } else if (Array.isArray(doStream)) {\n return doStream[this.doStreamCalls.length - 1];\n } else {\n return doStream;\n }\n };\n this._supportedUrls =\n typeof supportedUrls === 'function'\n ? supportedUrls\n : async () => await supportedUrls;\n }\n\n get supportedUrls() {\n return this._supportedUrls();\n }\n}\n","import {\n NoSuchModelError,\n type EmbeddingModelV3,\n type ImageModelV3,\n type LanguageModelV3,\n type ProviderV3,\n type SpeechModelV3,\n type TranscriptionModelV3,\n type RerankingModelV3,\n} from '@ai-sdk/provider';\nexport class MockProviderV3 implements ProviderV3 {\n readonly specificationVersion = 'v3' as const;\n\n languageModel: ProviderV3['languageModel'];\n embeddingModel: ProviderV3['embeddingModel'];\n imageModel: ProviderV3['imageModel'];\n transcriptionModel: ProviderV3['transcriptionModel'];\n speechModel: ProviderV3['speechModel'];\n rerankingModel: ProviderV3['rerankingModel'];\n\n constructor({\n languageModels,\n embeddingModels,\n imageModels,\n transcriptionModels,\n speechModels,\n rerankingModels,\n }: {\n languageModels?: Record<string, LanguageModelV3>;\n embeddingModels?: Record<string, EmbeddingModelV3>;\n imageModels?: Record<string, ImageModelV3>;\n transcriptionModels?: Record<string, TranscriptionModelV3>;\n speechModels?: Record<string, SpeechModelV3>;\n rerankingModels?: Record<string, RerankingModelV3>;\n } = {}) {\n this.languageModel = (modelId: string) => {\n if (!languageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n }\n return languageModels[modelId];\n };\n this.embeddingModel = (modelId: string) => {\n if (!embeddingModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n }\n return embeddingModels[modelId];\n };\n this.imageModel = (modelId: string) => {\n if (!imageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n }\n return imageModels[modelId];\n };\n this.transcriptionModel = (modelId: string) => {\n if (!transcriptionModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'transcriptionModel',\n });\n }\n return transcriptionModels[modelId];\n };\n this.speechModel = (modelId: string): SpeechModelV3 => {\n if (!speechModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'speechModel' });\n }\n return speechModels[modelId];\n };\n this.rerankingModel = (modelId: string) => {\n if (!rerankingModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'rerankingModel' });\n }\n return rerankingModels[modelId];\n };\n }\n}\n","import {\n NoSuchModelError,\n type EmbeddingModelV4,\n type ImageModelV4,\n type LanguageModelV4,\n type ProviderV4,\n type SpeechModelV4,\n type TranscriptionModelV4,\n type RerankingModelV4,\n} from '@ai-sdk/provider';\nexport class MockProviderV4 implements ProviderV4 {\n readonly specificationVersion = 'v4' as const;\n\n languageModel: ProviderV4['languageModel'];\n embeddingModel: ProviderV4['embeddingModel'];\n imageModel: ProviderV4['imageModel'];\n transcriptionModel: ProviderV4['transcriptionModel'];\n speechModel: ProviderV4['speechModel'];\n rerankingModel: ProviderV4['rerankingModel'];\n\n constructor({\n languageModels,\n embeddingModels,\n imageModels,\n transcriptionModels,\n speechModels,\n rerankingModels,\n }: {\n languageModels?: Record<string, LanguageModelV4>;\n embeddingModels?: Record<string, EmbeddingModelV4>;\n imageModels?: Record<string, ImageModelV4>;\n transcriptionModels?: Record<string, TranscriptionModelV4>;\n speechModels?: Record<string, SpeechModelV4>;\n rerankingModels?: Record<string, RerankingModelV4>;\n } = {}) {\n this.languageModel = (modelId: string) => {\n if (!languageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n }\n return languageModels[modelId];\n };\n this.embeddingModel = (modelId: string) => {\n if (!embeddingModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n }\n return embeddingModels[modelId];\n };\n this.imageModel = (modelId: string) => {\n if (!imageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n }\n return imageModels[modelId];\n };\n this.transcriptionModel = (modelId: string) => {\n if (!transcriptionModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'transcriptionModel',\n });\n }\n return transcriptionModels[modelId];\n };\n this.speechModel = (modelId: string): SpeechModelV4 => {\n if (!speechModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'speechModel' });\n }\n return speechModels[modelId];\n };\n this.rerankingModel = (modelId: string) => {\n if (!rerankingModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'rerankingModel' });\n }\n return rerankingModels[modelId];\n };\n }\n}\n","import type { SpeechModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechModelV3 implements SpeechModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: SpeechModelV3['provider'];\n readonly modelId: SpeechModelV3['modelId'];\n\n doGenerate: SpeechModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: SpeechModelV3['provider'];\n modelId?: SpeechModelV3['modelId'];\n doGenerate?: SpeechModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { SpeechModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechModelV4 implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: SpeechModelV4['provider'];\n readonly modelId: SpeechModelV4['modelId'];\n\n doGenerate: SpeechModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: SpeechModelV4['provider'];\n modelId?: SpeechModelV4['modelId'];\n doGenerate?: SpeechModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { TranscriptionModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockTranscriptionModelV3 implements TranscriptionModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: TranscriptionModelV3['provider'];\n readonly modelId: TranscriptionModelV3['modelId'];\n\n doGenerate: TranscriptionModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: TranscriptionModelV3['provider'];\n modelId?: TranscriptionModelV3['modelId'];\n doGenerate?: TranscriptionModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { TranscriptionModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockTranscriptionModelV4 implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: TranscriptionModelV4['provider'];\n readonly modelId: TranscriptionModelV4['modelId'];\n\n doGenerate: TranscriptionModelV4['doGenerate'];\n doStream: TranscriptionModelV4['doStream'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n doStream,\n }: {\n provider?: TranscriptionModelV4['provider'];\n modelId?: TranscriptionModelV4['modelId'];\n doGenerate?: TranscriptionModelV4['doGenerate'];\n doStream?: TranscriptionModelV4['doStream'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\n }\n}\n","import type { RerankingModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockRerankingModelV3 implements RerankingModelV3 {\n readonly specificationVersion = 'v3';\n\n readonly provider: RerankingModelV3['provider'];\n readonly modelId: RerankingModelV3['modelId'];\n\n doRerank: RerankingModelV3['doRerank'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doRerank = notImplemented,\n }: {\n provider?: RerankingModelV3['provider'];\n modelId?: RerankingModelV3['modelId'];\n doRerank?: RerankingModelV3['doRerank'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doRerank = doRerank;\n }\n}\n","import type { RerankingModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockRerankingModelV4 implements RerankingModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly provider: RerankingModelV4['provider'];\n readonly modelId: RerankingModelV4['modelId'];\n\n doRerank: RerankingModelV4['doRerank'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doRerank = notImplemented,\n }: {\n provider?: RerankingModelV4['provider'];\n modelId?: RerankingModelV4['modelId'];\n doRerank?: RerankingModelV4['doRerank'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doRerank = doRerank;\n }\n}\n","import type { Experimental_VideoModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockVideoModelV3 implements Experimental_VideoModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: Experimental_VideoModelV3['provider'];\n readonly modelId: Experimental_VideoModelV3['modelId'];\n readonly maxVideosPerCall: Experimental_VideoModelV3['maxVideosPerCall'];\n\n doGenerate: Experimental_VideoModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxVideosPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: Experimental_VideoModelV3['provider'];\n modelId?: Experimental_VideoModelV3['modelId'];\n maxVideosPerCall?: Experimental_VideoModelV3['maxVideosPerCall'];\n doGenerate?: Experimental_VideoModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxVideosPerCall = maxVideosPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type { Experimental_VideoModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockVideoModelV4 implements Experimental_VideoModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: Experimental_VideoModelV4['provider'];\n readonly modelId: Experimental_VideoModelV4['modelId'];\n readonly maxVideosPerCall: Experimental_VideoModelV4['maxVideosPerCall'];\n\n doGenerate: Experimental_VideoModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxVideosPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: Experimental_VideoModelV4['provider'];\n modelId?: Experimental_VideoModelV4['modelId'];\n maxVideosPerCall?: Experimental_VideoModelV4['maxVideosPerCall'];\n doGenerate?: Experimental_VideoModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxVideosPerCall = maxVideosPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","export function mockValues<T>(...values: T[]): () => T {\n let counter = 0;\n return () => values[counter++] ?? values[values.length - 1];\n}\n"],"mappings":";AAAA,SAAS,SAAS,qBAAqB;AAWhC,SAAS,uBAA0B;AAAA,EACxC;AAAA,EACA,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB;AACF,GAOsB;AACpB,QAAM,QAAQ,WAAW,SAAS;AAElC,MAAI,QAAQ;AAEZ,SAAO,IAAI,eAAe;AAAA,IACxB,MAAM,KAAK,YAAY;AACrB,UAAI,QAAQ,OAAO,QAAQ;AACzB,cAAM,MAAM,UAAU,IAAI,mBAAmB,c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AU;AAAA,IACV,WAAW;AAAA,EACb,IAII,CAAC,GAAG;AAfR,SAAS,uBAAuB;AAgB9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,WAAW;AAAA,EAClB;AACF;;;ACrBO,IAAM,uBAAN,MAAuD;AAAA,EAQ5D,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,EACb,IAII,CAAC,GAAG;AAfR,SAAS,uBAAuB;AAgB9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,WAAW;AAAA,EAClB;AACF;;;ACrBO,IAAM,mBAAN,MAA4D;AAAA,EAQjE,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,mBAAmB;AAAA,IACnB,aAAa;AAAA,EACf,IAKI,CAAC,GAAG;AAjBR,SAAS,uBAAuB;AAkB9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,mBAAmB;AACxB,SAAK,aAAa;AAAA,EACpB;AACF;;;ACxBO,IAAM,mBAAN,MAA4D;AAAA,EAQjE,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,mBAAmB;AAAA,IACnB,aAAa;AAAA,EACf,IAKI,CAAC,GAAG;AAjBR,SAAS,uBAAuB;AAkB9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,mBAAmB;AACxB,SAAK,aAAa;AAAA,EACpB;AACF;;;AC3BO,SAAS,cAAiB,QAAsB;AACrD,MAAI,UAAU;AACd,SAAO,MAAM,OAAO,SAAS,KAAK,OAAO,OAAO,SAAS,CAAC;AAC5D;;;AlB0BO,IAAMC,0BAAyB;","names":["NoSuchModelError","simulateReadableStream"]}
|
|
1
|
+
{"version":3,"sources":["../../src/util/simulate-readable-stream.ts","../../test/index.ts","../../src/test/not-implemented.ts","../../src/test/mock-embedding-model-v3.ts","../../src/test/mock-embedding-model-v4.ts","../../src/test/mock-image-model-v3.ts","../../src/test/mock-image-model-v4.ts","../../src/test/mock-language-model-v3.ts","../../src/test/mock-language-model-v4.ts","../../src/test/mock-provider-v3.ts","../../src/test/mock-provider-v4.ts","../../src/test/mock-speech-model-v3.ts","../../src/test/mock-speech-model-v4.ts","../../src/test/mock-speech-translation-model-v4.ts","../../src/test/mock-transcription-model-v3.ts","../../src/test/mock-transcription-model-v4.ts","../../src/test/mock-reranking-model-v3.ts","../../src/test/mock-reranking-model-v4.ts","../../src/test/mock-video-model-v3.ts","../../src/test/mock-video-model-v4.ts","../../src/test/mock-values.ts"],"sourcesContent":["import { delay as delayFunction } from '@ai-sdk/provider-utils';\n\n/**\n * Creates a ReadableStream that emits the provided values with an optional delay between each value.\n *\n * @param options - The configuration options\n * @param options.chunks - Array of values to be emitted by the stream\n * @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @returns A ReadableStream that emits the provided values\n */\nexport function simulateReadableStream<T>({\n chunks,\n initialDelayInMs = 0,\n chunkDelayInMs = 0,\n _internal,\n}: {\n chunks: T[];\n initialDelayInMs?: number | null;\n chunkDelayInMs?: number | null;\n _internal?: {\n delay?: (ms: number | null) => Promise<void>;\n };\n}): ReadableStream<T> {\n const delay = _internal?.delay ?? delayFunction;\n\n let index = 0;\n\n return new ReadableStream({\n async pull(controller) {\n if (index < chunks.length) {\n await delay(index === 0 ? initialDelayInMs : chunkDelayInMs);\n controller.enqueue(chunks[index++]);\n } else {\n controller.close();\n }\n },\n });\n}\n","import { simulateReadableStream as originalSimulateReadableStream } from '../src/util/simulate-readable-stream';\n\nexport {\n convertArrayToAsyncIterable,\n convertArrayToReadableStream,\n convertReadableStreamToArray,\n mockId,\n} from '@ai-sdk/provider-utils/test';\nexport { MockEmbeddingModelV3 } from '../src/test/mock-embedding-model-v3';\nexport { MockEmbeddingModelV4 } from '../src/test/mock-embedding-model-v4';\nexport { MockImageModelV3 } from '../src/test/mock-image-model-v3';\nexport { MockImageModelV4 } from '../src/test/mock-image-model-v4';\nexport { MockLanguageModelV3 } from '../src/test/mock-language-model-v3';\nexport { MockLanguageModelV4 } from '../src/test/mock-language-model-v4';\nexport { MockProviderV3 } from '../src/test/mock-provider-v3';\nexport { MockProviderV4 } from '../src/test/mock-provider-v4';\nexport { MockSpeechModelV3 } from '../src/test/mock-speech-model-v3';\nexport { MockSpeechModelV4 } from '../src/test/mock-speech-model-v4';\nexport { MockSpeechTranslationModelV4 as Experimental_MockSpeechTranslationModelV4 } from '../src/test/mock-speech-translation-model-v4';\nexport { MockTranscriptionModelV3 } from '../src/test/mock-transcription-model-v3';\nexport { MockTranscriptionModelV4 } from '../src/test/mock-transcription-model-v4';\nexport { MockRerankingModelV3 } from '../src/test/mock-reranking-model-v3';\nexport { MockRerankingModelV4 } from '../src/test/mock-reranking-model-v4';\nexport { MockVideoModelV3 } from '../src/test/mock-video-model-v3';\nexport { MockVideoModelV4 } from '../src/test/mock-video-model-v4';\nexport { mockValues } from '../src/test/mock-values';\n\n/**\n * @deprecated Use `simulateReadableStream` from `ai` instead.\n */\nexport const simulateReadableStream = originalSimulateReadableStream;\n","export function notImplemented(): never {\n throw new Error('Not implemented');\n}\n","import type { EmbeddingModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV3 implements EmbeddingModelV3 {\n readonly specificationVersion = 'v3';\n\n readonly provider: EmbeddingModelV3['provider'];\n readonly modelId: EmbeddingModelV3['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV3['maxEmbeddingsPerCall'];\n readonly supportsParallelCalls: EmbeddingModelV3['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV3['doEmbed'];\n\n doEmbedCalls: Parameters<EmbeddingModelV3['doEmbed']>[0][] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV3['provider'];\n modelId?: EmbeddingModelV3['modelId'];\n maxEmbeddingsPerCall?: EmbeddingModelV3['maxEmbeddingsPerCall'] | null;\n supportsParallelCalls?: EmbeddingModelV3['supportsParallelCalls'];\n doEmbed?:\n | EmbeddingModelV3['doEmbed']\n | Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>\n | Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = async options => {\n this.doEmbedCalls.push(options);\n\n if (typeof doEmbed === 'function') {\n return doEmbed(options);\n } else if (Array.isArray(doEmbed)) {\n return doEmbed[this.doEmbedCalls.length - 1];\n } else {\n return doEmbed;\n }\n };\n }\n}\n","import type { EmbeddingModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV4 implements EmbeddingModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly provider: EmbeddingModelV4['provider'];\n readonly modelId: EmbeddingModelV4['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV4['maxEmbeddingsPerCall'];\n readonly supportsParallelCalls: EmbeddingModelV4['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV4['doEmbed'];\n\n doEmbedCalls: Parameters<EmbeddingModelV4['doEmbed']>[0][] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV4['provider'];\n modelId?: EmbeddingModelV4['modelId'];\n maxEmbeddingsPerCall?: EmbeddingModelV4['maxEmbeddingsPerCall'] | null;\n supportsParallelCalls?: EmbeddingModelV4['supportsParallelCalls'];\n doEmbed?:\n | EmbeddingModelV4['doEmbed']\n | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>\n | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = async options => {\n this.doEmbedCalls.push(options);\n\n if (typeof doEmbed === 'function') {\n return doEmbed(options);\n } else if (Array.isArray(doEmbed)) {\n return doEmbed[this.doEmbedCalls.length - 1];\n } else {\n return doEmbed;\n }\n };\n }\n}\n","import type { ImageModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockImageModelV3 implements ImageModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: ImageModelV3['provider'];\n readonly modelId: ImageModelV3['modelId'];\n readonly maxImagesPerCall: ImageModelV3['maxImagesPerCall'];\n\n doGenerate: ImageModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV3['provider'];\n modelId?: ImageModelV3['modelId'];\n maxImagesPerCall?: ImageModelV3['maxImagesPerCall'];\n doGenerate?: ImageModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type { ImageModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockImageModelV4 implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: ImageModelV4['provider'];\n readonly modelId: ImageModelV4['modelId'];\n readonly maxImagesPerCall: ImageModelV4['maxImagesPerCall'];\n\n doGenerate: ImageModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV4['provider'];\n modelId?: ImageModelV4['modelId'];\n maxImagesPerCall?: ImageModelV4['maxImagesPerCall'];\n doGenerate?: ImageModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type {\n LanguageModelV3,\n LanguageModelV3CallOptions,\n LanguageModelV3GenerateResult,\n LanguageModelV3StreamResult,\n} from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV3 implements LanguageModelV3 {\n readonly specificationVersion = 'v3';\n\n private _supportedUrls: () => LanguageModelV3['supportedUrls'];\n\n readonly provider: LanguageModelV3['provider'];\n readonly modelId: LanguageModelV3['modelId'];\n\n doGenerate: LanguageModelV3['doGenerate'];\n doStream: LanguageModelV3['doStream'];\n\n doGenerateCalls: LanguageModelV3CallOptions[] = [];\n doStreamCalls: LanguageModelV3CallOptions[] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedUrls = {},\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: LanguageModelV3['provider'];\n modelId?: LanguageModelV3['modelId'];\n supportedUrls?:\n | LanguageModelV3['supportedUrls']\n | (() => LanguageModelV3['supportedUrls']);\n doGenerate?:\n | LanguageModelV3['doGenerate']\n | LanguageModelV3GenerateResult\n | LanguageModelV3GenerateResult[];\n doStream?:\n | LanguageModelV3['doStream']\n | LanguageModelV3StreamResult\n | LanguageModelV3StreamResult[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = async options => {\n this.doGenerateCalls.push(options);\n\n if (typeof doGenerate === 'function') {\n return await doGenerate(options);\n } else if (Array.isArray(doGenerate)) {\n return doGenerate[this.doGenerateCalls.length - 1];\n } else {\n return doGenerate;\n }\n };\n this.doStream = async options => {\n this.doStreamCalls.push(options);\n\n if (typeof doStream === 'function') {\n return await doStream(options);\n } else if (Array.isArray(doStream)) {\n return doStream[this.doStreamCalls.length - 1];\n } else {\n return doStream;\n }\n };\n this._supportedUrls =\n typeof supportedUrls === 'function'\n ? supportedUrls\n : async () => await supportedUrls;\n }\n\n get supportedUrls() {\n return this._supportedUrls();\n }\n}\n","import type {\n LanguageModelV4,\n LanguageModelV4CallOptions,\n LanguageModelV4GenerateResult,\n LanguageModelV4StreamResult,\n} from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV4 implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\n\n private _supportedUrls: () => LanguageModelV4['supportedUrls'];\n\n readonly provider: LanguageModelV4['provider'];\n readonly modelId: LanguageModelV4['modelId'];\n\n doGenerate: LanguageModelV4['doGenerate'];\n doStream: LanguageModelV4['doStream'];\n\n doGenerateCalls: LanguageModelV4CallOptions[] = [];\n doStreamCalls: LanguageModelV4CallOptions[] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedUrls = {},\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: LanguageModelV4['provider'];\n modelId?: LanguageModelV4['modelId'];\n supportedUrls?:\n | LanguageModelV4['supportedUrls']\n | (() => LanguageModelV4['supportedUrls']);\n doGenerate?:\n | LanguageModelV4['doGenerate']\n | LanguageModelV4GenerateResult\n | LanguageModelV4GenerateResult[];\n doStream?:\n | LanguageModelV4['doStream']\n | LanguageModelV4StreamResult\n | LanguageModelV4StreamResult[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = async options => {\n this.doGenerateCalls.push(options);\n\n if (typeof doGenerate === 'function') {\n return await doGenerate(options);\n } else if (Array.isArray(doGenerate)) {\n return doGenerate[this.doGenerateCalls.length - 1];\n } else {\n return doGenerate;\n }\n };\n this.doStream = async options => {\n this.doStreamCalls.push(options);\n\n if (typeof doStream === 'function') {\n return await doStream(options);\n } else if (Array.isArray(doStream)) {\n return doStream[this.doStreamCalls.length - 1];\n } else {\n return doStream;\n }\n };\n this._supportedUrls =\n typeof supportedUrls === 'function'\n ? supportedUrls\n : async () => await supportedUrls;\n }\n\n get supportedUrls() {\n return this._supportedUrls();\n }\n}\n","import {\n NoSuchModelError,\n type EmbeddingModelV3,\n type ImageModelV3,\n type LanguageModelV3,\n type ProviderV3,\n type SpeechModelV3,\n type TranscriptionModelV3,\n type RerankingModelV3,\n} from '@ai-sdk/provider';\nexport class MockProviderV3 implements ProviderV3 {\n readonly specificationVersion = 'v3' as const;\n\n languageModel: ProviderV3['languageModel'];\n embeddingModel: ProviderV3['embeddingModel'];\n imageModel: ProviderV3['imageModel'];\n transcriptionModel: ProviderV3['transcriptionModel'];\n speechModel: ProviderV3['speechModel'];\n rerankingModel: ProviderV3['rerankingModel'];\n\n constructor({\n languageModels,\n embeddingModels,\n imageModels,\n transcriptionModels,\n speechModels,\n rerankingModels,\n }: {\n languageModels?: Record<string, LanguageModelV3>;\n embeddingModels?: Record<string, EmbeddingModelV3>;\n imageModels?: Record<string, ImageModelV3>;\n transcriptionModels?: Record<string, TranscriptionModelV3>;\n speechModels?: Record<string, SpeechModelV3>;\n rerankingModels?: Record<string, RerankingModelV3>;\n } = {}) {\n this.languageModel = (modelId: string) => {\n if (!languageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n }\n return languageModels[modelId];\n };\n this.embeddingModel = (modelId: string) => {\n if (!embeddingModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n }\n return embeddingModels[modelId];\n };\n this.imageModel = (modelId: string) => {\n if (!imageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n }\n return imageModels[modelId];\n };\n this.transcriptionModel = (modelId: string) => {\n if (!transcriptionModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'transcriptionModel',\n });\n }\n return transcriptionModels[modelId];\n };\n this.speechModel = (modelId: string): SpeechModelV3 => {\n if (!speechModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'speechModel' });\n }\n return speechModels[modelId];\n };\n this.rerankingModel = (modelId: string) => {\n if (!rerankingModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'rerankingModel' });\n }\n return rerankingModels[modelId];\n };\n }\n}\n","import {\n NoSuchModelError,\n type EmbeddingModelV4,\n type ImageModelV4,\n type LanguageModelV4,\n type ProviderV4,\n type SpeechModelV4,\n type TranscriptionModelV4,\n type RerankingModelV4,\n} from '@ai-sdk/provider';\nexport class MockProviderV4 implements ProviderV4 {\n readonly specificationVersion = 'v4' as const;\n\n languageModel: ProviderV4['languageModel'];\n embeddingModel: ProviderV4['embeddingModel'];\n imageModel: ProviderV4['imageModel'];\n transcriptionModel: ProviderV4['transcriptionModel'];\n speechModel: ProviderV4['speechModel'];\n rerankingModel: ProviderV4['rerankingModel'];\n\n constructor({\n languageModels,\n embeddingModels,\n imageModels,\n transcriptionModels,\n speechModels,\n rerankingModels,\n }: {\n languageModels?: Record<string, LanguageModelV4>;\n embeddingModels?: Record<string, EmbeddingModelV4>;\n imageModels?: Record<string, ImageModelV4>;\n transcriptionModels?: Record<string, TranscriptionModelV4>;\n speechModels?: Record<string, SpeechModelV4>;\n rerankingModels?: Record<string, RerankingModelV4>;\n } = {}) {\n this.languageModel = (modelId: string) => {\n if (!languageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n }\n return languageModels[modelId];\n };\n this.embeddingModel = (modelId: string) => {\n if (!embeddingModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n }\n return embeddingModels[modelId];\n };\n this.imageModel = (modelId: string) => {\n if (!imageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n }\n return imageModels[modelId];\n };\n this.transcriptionModel = (modelId: string) => {\n if (!transcriptionModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'transcriptionModel',\n });\n }\n return transcriptionModels[modelId];\n };\n this.speechModel = (modelId: string): SpeechModelV4 => {\n if (!speechModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'speechModel' });\n }\n return speechModels[modelId];\n };\n this.rerankingModel = (modelId: string) => {\n if (!rerankingModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'rerankingModel' });\n }\n return rerankingModels[modelId];\n };\n }\n}\n","import type { SpeechModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechModelV3 implements SpeechModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: SpeechModelV3['provider'];\n readonly modelId: SpeechModelV3['modelId'];\n\n doGenerate: SpeechModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: SpeechModelV3['provider'];\n modelId?: SpeechModelV3['modelId'];\n doGenerate?: SpeechModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { SpeechModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechModelV4 implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: SpeechModelV4['provider'];\n readonly modelId: SpeechModelV4['modelId'];\n\n doGenerate: SpeechModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: SpeechModelV4['provider'];\n modelId?: SpeechModelV4['modelId'];\n doGenerate?: SpeechModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { Experimental_SpeechTranslationModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechTranslationModelV4 implements Experimental_SpeechTranslationModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: Experimental_SpeechTranslationModelV4['provider'];\n readonly modelId: Experimental_SpeechTranslationModelV4['modelId'];\n\n doStream: Experimental_SpeechTranslationModelV4['doStream'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doStream = notImplemented,\n }: {\n provider?: Experimental_SpeechTranslationModelV4['provider'];\n modelId?: Experimental_SpeechTranslationModelV4['modelId'];\n doStream?: Experimental_SpeechTranslationModelV4['doStream'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doStream = doStream;\n }\n}\n","import type { TranscriptionModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockTranscriptionModelV3 implements TranscriptionModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: TranscriptionModelV3['provider'];\n readonly modelId: TranscriptionModelV3['modelId'];\n\n doGenerate: TranscriptionModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: TranscriptionModelV3['provider'];\n modelId?: TranscriptionModelV3['modelId'];\n doGenerate?: TranscriptionModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { TranscriptionModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockTranscriptionModelV4 implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: TranscriptionModelV4['provider'];\n readonly modelId: TranscriptionModelV4['modelId'];\n\n doGenerate: TranscriptionModelV4['doGenerate'];\n doStream: TranscriptionModelV4['doStream'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n doStream,\n }: {\n provider?: TranscriptionModelV4['provider'];\n modelId?: TranscriptionModelV4['modelId'];\n doGenerate?: TranscriptionModelV4['doGenerate'];\n doStream?: TranscriptionModelV4['doStream'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\n }\n}\n","import type { RerankingModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockRerankingModelV3 implements RerankingModelV3 {\n readonly specificationVersion = 'v3';\n\n readonly provider: RerankingModelV3['provider'];\n readonly modelId: RerankingModelV3['modelId'];\n\n doRerank: RerankingModelV3['doRerank'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doRerank = notImplemented,\n }: {\n provider?: RerankingModelV3['provider'];\n modelId?: RerankingModelV3['modelId'];\n doRerank?: RerankingModelV3['doRerank'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doRerank = doRerank;\n }\n}\n","import type { RerankingModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockRerankingModelV4 implements RerankingModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly provider: RerankingModelV4['provider'];\n readonly modelId: RerankingModelV4['modelId'];\n\n doRerank: RerankingModelV4['doRerank'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doRerank = notImplemented,\n }: {\n provider?: RerankingModelV4['provider'];\n modelId?: RerankingModelV4['modelId'];\n doRerank?: RerankingModelV4['doRerank'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doRerank = doRerank;\n }\n}\n","import type { Experimental_VideoModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockVideoModelV3 implements Experimental_VideoModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: Experimental_VideoModelV3['provider'];\n readonly modelId: Experimental_VideoModelV3['modelId'];\n readonly maxVideosPerCall: Experimental_VideoModelV3['maxVideosPerCall'];\n\n doGenerate: Experimental_VideoModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxVideosPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: Experimental_VideoModelV3['provider'];\n modelId?: Experimental_VideoModelV3['modelId'];\n maxVideosPerCall?: Experimental_VideoModelV3['maxVideosPerCall'];\n doGenerate?: Experimental_VideoModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxVideosPerCall = maxVideosPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type { Experimental_VideoModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockVideoModelV4 implements Experimental_VideoModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: Experimental_VideoModelV4['provider'];\n readonly modelId: Experimental_VideoModelV4['modelId'];\n readonly maxVideosPerCall: Experimental_VideoModelV4['maxVideosPerCall'];\n\n doGenerate: Experimental_VideoModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxVideosPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: Experimental_VideoModelV4['provider'];\n modelId?: Experimental_VideoModelV4['modelId'];\n maxVideosPerCall?: Experimental_VideoModelV4['maxVideosPerCall'];\n doGenerate?: Experimental_VideoModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxVideosPerCall = maxVideosPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","export function mockValues<T>(...values: T[]): () => T {\n let counter = 0;\n return () => values[counter++] ?? values[values.length - 1];\n}\n"],"mappings":";AAAA,SAAS,SAAS,qBAAqB;AAWhC,SAAS,uBAA0B;AAAA,EACxC;AAAA,EACA,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB;AACF,GAOsB;AACpB,QAAM,QAAQ,WAAW,SAAS;AAElC,MAAI,QAAQ;AAEZ,SAAO,IAAI,eAAe;AAAA,IACxB,MAAM,KAAK,YAAY;AACrB,UAAI,QAAQ,OAAO,QAAQ;AACzB,cAAM,MAAM,UAAU,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AC5D;;;AnB2BO,IAAMC,0BAAyB;","names":["NoSuchModelError","simulateReadableStream"]}
|
|
@@ -95,6 +95,7 @@ The open-source community has created the following providers:
|
|
|
95
95
|
- [Zhipu (Z.AI) Provider](/providers/community-providers/zhipu) (`zhipu-ai-provider`)
|
|
96
96
|
- [OLLM Provider](/providers/community-providers/ollm) (`@ofoundation/ollm`)
|
|
97
97
|
- [ZeroEntropy Provider](/providers/community-providers/zeroentropy) (`zeroentropy-ai-provider`)
|
|
98
|
+
- [Neon AI Gateway Provider](/providers/community-providers/neon-ai-gateway) (`@neon/ai-sdk-provider`)
|
|
98
99
|
|
|
99
100
|
## Self-Hosted Models
|
|
100
101
|
|
|
@@ -91,7 +91,8 @@ The `audio` stream must contain raw audio chunks. `Uint8Array` chunks are raw by
|
|
|
91
91
|
<Note>
|
|
92
92
|
String model IDs resolve through the global provider (AI Gateway by
|
|
93
93
|
default). AI Gateway supports streaming transcription for supported models
|
|
94
|
-
(e.g. `openai/gpt-realtime-whisper`, `
|
|
94
|
+
(e.g. `openai/gpt-realtime-whisper`, `elevenlabs/eleven-scribe-2-realtime`,
|
|
95
|
+
`xai/grok-stt`), so string IDs work:
|
|
95
96
|
`experimental_streamTranscribe({ model: 'openai/gpt-realtime-whisper', ...
|
|
96
97
|
})`. You can also pass a provider model instance (e.g.
|
|
97
98
|
`openai.transcription('gpt-realtime-whisper')`) to stream directly against
|
|
@@ -100,9 +101,11 @@ The `audio` stream must contain raw audio chunks. `Uint8Array` chunks are raw by
|
|
|
100
101
|
|
|
101
102
|
OpenAI streaming transcription uses `openai.transcription('gpt-realtime-whisper')`.
|
|
102
103
|
Cartesia uses `cartesia.transcription('ink-2')` for streaming-only Ink 2
|
|
103
|
-
transcription.
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
transcription. ElevenLabs uses
|
|
105
|
+
`elevenLabs.transcription('scribe_v2_realtime')` for Scribe v2 Realtime. xAI
|
|
106
|
+
uses the same `xai.transcription()` model for request/response and streaming
|
|
107
|
+
transcription; `experimental_streamTranscribe` selects the provider's
|
|
108
|
+
WebSocket STT transport.
|
|
106
109
|
|
|
107
110
|
```ts
|
|
108
111
|
import { xai } from '@ai-sdk/xai';
|
|
@@ -290,36 +293,38 @@ try {
|
|
|
290
293
|
|
|
291
294
|
## Transcription Models
|
|
292
295
|
|
|
293
|
-
| Provider
|
|
294
|
-
|
|
|
295
|
-
| [OpenAI](/providers/ai-sdk-providers/openai#transcription-models)
|
|
296
|
-
| [OpenAI](/providers/ai-sdk-providers/openai#transcription-models)
|
|
297
|
-
| [OpenAI](/providers/ai-sdk-providers/openai#transcription-models)
|
|
298
|
-
| [ElevenLabs](/providers/ai-sdk-providers/elevenlabs#transcription-models)
|
|
299
|
-
| [ElevenLabs](/providers/ai-sdk-providers/elevenlabs#transcription-models)
|
|
300
|
-
| [
|
|
301
|
-
| [
|
|
302
|
-
| [
|
|
303
|
-
| [
|
|
304
|
-
| [Azure OpenAI](/providers/ai-sdk-providers/azure#transcription-models)
|
|
305
|
-
| [
|
|
306
|
-
| [
|
|
307
|
-
| [Rev.ai](/providers/ai-sdk-providers/revai#transcription-models)
|
|
308
|
-
| [
|
|
309
|
-
| [
|
|
310
|
-
| [Deepgram](/providers/ai-sdk-providers/deepgram#transcription-models)
|
|
311
|
-
| [Deepgram](/providers/ai-sdk-providers/deepgram#transcription-models)
|
|
312
|
-
| [Deepgram](/providers/ai-sdk-providers/deepgram#transcription-models)
|
|
313
|
-
| [
|
|
314
|
-
| [
|
|
315
|
-
| [
|
|
316
|
-
| [
|
|
317
|
-
| [
|
|
318
|
-
| [
|
|
319
|
-
| [
|
|
320
|
-
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#transcription-models)
|
|
321
|
-
| [
|
|
322
|
-
| [
|
|
323
|
-
| [
|
|
296
|
+
| Provider | Model |
|
|
297
|
+
| ----------------------------------------------------------------------------------- | ------------------------ |
|
|
298
|
+
| [OpenAI](/providers/ai-sdk-providers/openai#transcription-models) | `whisper-1` |
|
|
299
|
+
| [OpenAI](/providers/ai-sdk-providers/openai#transcription-models) | `gpt-4o-transcribe` |
|
|
300
|
+
| [OpenAI](/providers/ai-sdk-providers/openai#transcription-models) | `gpt-4o-mini-transcribe` |
|
|
301
|
+
| [ElevenLabs](/providers/ai-sdk-providers/elevenlabs#transcription-models) | `scribe_v1` |
|
|
302
|
+
| [ElevenLabs](/providers/ai-sdk-providers/elevenlabs#transcription-models) | `scribe_v1_experimental` |
|
|
303
|
+
| [ElevenLabs](/providers/ai-sdk-providers/elevenlabs#transcription-models) | `scribe_v2` |
|
|
304
|
+
| [ElevenLabs](/providers/ai-sdk-providers/elevenlabs#streaming-transcription-models) | `scribe_v2_realtime` |
|
|
305
|
+
| [Groq](/providers/ai-sdk-providers/groq#transcription-models) | `whisper-large-v3-turbo` |
|
|
306
|
+
| [Groq](/providers/ai-sdk-providers/groq#transcription-models) | `whisper-large-v3` |
|
|
307
|
+
| [Azure OpenAI](/providers/ai-sdk-providers/azure#transcription-models) | `whisper-1` |
|
|
308
|
+
| [Azure OpenAI](/providers/ai-sdk-providers/azure#transcription-models) | `gpt-4o-transcribe` |
|
|
309
|
+
| [Azure OpenAI](/providers/ai-sdk-providers/azure#transcription-models) | `gpt-4o-mini-transcribe` |
|
|
310
|
+
| [Rev.ai](/providers/ai-sdk-providers/revai#transcription-models) | `machine` |
|
|
311
|
+
| [Rev.ai](/providers/ai-sdk-providers/revai#transcription-models) | `low_cost` |
|
|
312
|
+
| [Rev.ai](/providers/ai-sdk-providers/revai#transcription-models) | `fusion` |
|
|
313
|
+
| [Deepgram](/providers/ai-sdk-providers/deepgram#transcription-models) | `base` (+ variants) |
|
|
314
|
+
| [Deepgram](/providers/ai-sdk-providers/deepgram#transcription-models) | `enhanced` (+ variants) |
|
|
315
|
+
| [Deepgram](/providers/ai-sdk-providers/deepgram#transcription-models) | `nova` (+ variants) |
|
|
316
|
+
| [Deepgram](/providers/ai-sdk-providers/deepgram#transcription-models) | `nova-2` (+ variants) |
|
|
317
|
+
| [Deepgram](/providers/ai-sdk-providers/deepgram#transcription-models) | `nova-3` (+ variants) |
|
|
318
|
+
| [Gladia](/providers/ai-sdk-providers/gladia#transcription-models) | `default` |
|
|
319
|
+
| [AssemblyAI](/providers/ai-sdk-providers/assemblyai#transcription-models) | `universal-3-5-pro` |
|
|
320
|
+
| [AssemblyAI](/providers/ai-sdk-providers/assemblyai#transcription-models) | `universal-3-pro` |
|
|
321
|
+
| [Fal](/providers/ai-sdk-providers/fal#transcription-models) | `whisper` |
|
|
322
|
+
| [Fal](/providers/ai-sdk-providers/fal#transcription-models) | `wizper` |
|
|
323
|
+
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#transcription-models) | `chirp_2` |
|
|
324
|
+
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#transcription-models) | `chirp_3` |
|
|
325
|
+
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#transcription-models) | `telephony` |
|
|
326
|
+
| [xAI](/providers/ai-sdk-providers/xai#transcription-models) | `default` |
|
|
327
|
+
| [Cartesia](/providers/ai-sdk-providers/cartesia#transcription-models) | `ink-whisper` |
|
|
328
|
+
| [Cartesia](/providers/ai-sdk-providers/cartesia#streaming-transcription-models) | `ink-2` |
|
|
324
329
|
|
|
325
330
|
Above are a small subset of the transcription models supported by the AI SDK providers. For more, see the respective provider documentation.
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Translation
|
|
3
|
+
description: Learn how to translate speech with the AI SDK.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Translation
|
|
7
|
+
|
|
8
|
+
<Note type="warning">Speech translation is an experimental feature.</Note>
|
|
9
|
+
|
|
10
|
+
The AI SDK provides the
|
|
11
|
+
[`experimental_streamTranslate`](/docs/reference/ai-sdk-core/stream-translate)
|
|
12
|
+
function to translate live speech into another language. Translation is a
|
|
13
|
+
streaming-only modality: models translate live source audio into
|
|
14
|
+
target-language audio and text.
|
|
15
|
+
|
|
16
|
+
`experimental_streamTranslate` is built on the speech translation model
|
|
17
|
+
specification (`Experimental_SpeechTranslationModelV4`).
|
|
18
|
+
|
|
19
|
+
<Note>
|
|
20
|
+
Provider implementations of the speech translation model specification ship
|
|
21
|
+
separately. Pass any model instance that implements
|
|
22
|
+
`Experimental_SpeechTranslationModelV4` — see your provider's documentation
|
|
23
|
+
for available translation models.
|
|
24
|
+
</Note>
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { experimental_streamTranslate as streamTranslate } from 'ai';
|
|
28
|
+
|
|
29
|
+
const result = streamTranslate({
|
|
30
|
+
// any provider model instance that implements the experimental
|
|
31
|
+
// speech translation model specification (Experimental_SpeechTranslationModelV4):
|
|
32
|
+
model: translationModel,
|
|
33
|
+
audio: audioStream, // ReadableStream<Uint8Array | string>
|
|
34
|
+
inputAudioFormat: { type: 'audio/pcm', rate: 24000 },
|
|
35
|
+
targetLanguage: 'es',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
for await (const part of result.fullStream) {
|
|
39
|
+
if (part.type === 'output-text-delta') {
|
|
40
|
+
process.stdout.write(part.delta);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (part.type === 'audio') {
|
|
44
|
+
// translated audio chunk (Uint8Array or base64 string)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (part.type === 'source-transcript-final') {
|
|
48
|
+
console.log('source:', part.text);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
console.log(await result.translationText);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The `audio` stream must contain raw audio chunks. `Uint8Array` chunks are raw
|
|
56
|
+
bytes; `string` chunks are base64-encoded raw bytes. Always set
|
|
57
|
+
`inputAudioFormat` to match the chunks you send.
|
|
58
|
+
|
|
59
|
+
`targetLanguage` (and the optional `sourceLanguage`) are BCP-47-style language
|
|
60
|
+
tags (e.g. `en`, `es`, `fr-CA`). Supported values are provider-specific and
|
|
61
|
+
validated by the provider.
|
|
62
|
+
|
|
63
|
+
When `sourceLanguage` is absent, providers auto-detect the source language.
|
|
64
|
+
|
|
65
|
+
`fullStream` is a single-consumer live stream and can only be accessed once.
|
|
66
|
+
When you need both stream parts and final results, access `fullStream` first and
|
|
67
|
+
await the result promises while or after consuming it. Accessing a result
|
|
68
|
+
promise first consumes the stream internally, so `fullStream` is no longer
|
|
69
|
+
available. This avoids retaining an unbounded replay buffer for live audio.
|
|
70
|
+
|
|
71
|
+
To access the final translation metadata:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
const sourceText = await result.sourceText; // final source-language transcript
|
|
75
|
+
const translationText = await result.translationText; // final translated text
|
|
76
|
+
const durationInSeconds = await result.durationInSeconds; // duration of the source audio in seconds, if available
|
|
77
|
+
const usage = await result.usage; // audio/text token usage, if reported
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
A translation stream is considered successful when at least one `audio` part
|
|
81
|
+
was emitted or the final output text is non-empty. For providers that produce
|
|
82
|
+
only audio output, `translationText` may resolve to an empty string.
|
|
83
|
+
|
|
84
|
+
## Stream parts
|
|
85
|
+
|
|
86
|
+
The `fullStream` yields the following part types:
|
|
87
|
+
|
|
88
|
+
- `audio`: a translated audio chunk in the target language.
|
|
89
|
+
- `output-text-delta`: an append-only translated text delta.
|
|
90
|
+
- `output-text-final`: final translated text for a provider-defined segment or
|
|
91
|
+
utterance.
|
|
92
|
+
- `source-transcript-delta`: an append-only source transcript delta.
|
|
93
|
+
- `source-transcript-partial`: non-final source transcript text that may be
|
|
94
|
+
revised by later parts.
|
|
95
|
+
- `source-transcript-final`: final source transcript text for a
|
|
96
|
+
provider-defined segment or utterance.
|
|
97
|
+
- `raw`: raw provider chunks when `includeRawChunks` is enabled.
|
|
98
|
+
- `error`: stream errors.
|
|
99
|
+
|
|
100
|
+
Output text is append-only: providers stream `output-text-delta` parts and
|
|
101
|
+
finalize per-utterance with `output-text-final`. There is no partial/revision
|
|
102
|
+
part for output text by design for now.
|
|
103
|
+
|
|
104
|
+
## Settings
|
|
105
|
+
|
|
106
|
+
### Output audio format
|
|
107
|
+
|
|
108
|
+
Use `outputAudioFormat` to request a specific audio format for translated
|
|
109
|
+
audio chunks. When absent, the provider default output format is used.
|
|
110
|
+
|
|
111
|
+
```ts highlight="6"
|
|
112
|
+
import { experimental_streamTranslate as streamTranslate } from 'ai';
|
|
113
|
+
|
|
114
|
+
const result = streamTranslate({
|
|
115
|
+
model: translationModel,
|
|
116
|
+
audio: audioStream,
|
|
117
|
+
inputAudioFormat: { type: 'audio/pcm', rate: 24000 },
|
|
118
|
+
outputAudioFormat: { type: 'audio/pcm', rate: 24000 },
|
|
119
|
+
targetLanguage: 'es',
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Provider-Specific settings
|
|
124
|
+
|
|
125
|
+
Translation models often have provider or model-specific settings which you can
|
|
126
|
+
set using the `providerOptions` parameter.
|
|
127
|
+
|
|
128
|
+
```ts highlight="8-12"
|
|
129
|
+
import { experimental_streamTranslate as streamTranslate } from 'ai';
|
|
130
|
+
|
|
131
|
+
const result = streamTranslate({
|
|
132
|
+
model: translationModel,
|
|
133
|
+
audio: audioStream,
|
|
134
|
+
inputAudioFormat: { type: 'audio/pcm', rate: 24000 },
|
|
135
|
+
targetLanguage: 'es',
|
|
136
|
+
providerOptions: {
|
|
137
|
+
'provider-name': {
|
|
138
|
+
// provider-specific options
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Abort Signals
|
|
145
|
+
|
|
146
|
+
Pass an `abortSignal` to cancel the translation:
|
|
147
|
+
|
|
148
|
+
```ts highlight="8"
|
|
149
|
+
import { experimental_streamTranslate as streamTranslate } from 'ai';
|
|
150
|
+
|
|
151
|
+
const result = streamTranslate({
|
|
152
|
+
model: translationModel,
|
|
153
|
+
audio: audioStream,
|
|
154
|
+
inputAudioFormat: { type: 'audio/pcm', rate: 24000 },
|
|
155
|
+
targetLanguage: 'es',
|
|
156
|
+
abortSignal: AbortSignal.timeout(60_000), // abort after 1 minute
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Error Handling
|
|
161
|
+
|
|
162
|
+
When `experimental_streamTranslate` cannot produce a translation — no `audio`
|
|
163
|
+
part was emitted and the final output text is empty, or the stream ends
|
|
164
|
+
without a finish event — it errors with a
|
|
165
|
+
[`AI_NoTranslationGeneratedError`](/docs/reference/ai-sdk-errors/ai-no-translation-generated-error).
|
|
166
|
+
|
|
167
|
+
The error preserves the following information to help you log the issue:
|
|
168
|
+
|
|
169
|
+
- `response`: Metadata about the speech translation model response, including
|
|
170
|
+
timestamp, model, and headers.
|
|
171
|
+
- `cause`: The cause of the error. You can use this for more detailed error
|
|
172
|
+
handling.
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import {
|
|
176
|
+
experimental_streamTranslate as streamTranslate,
|
|
177
|
+
NoTranslationGeneratedError,
|
|
178
|
+
} from 'ai';
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
const result = streamTranslate({
|
|
182
|
+
model: translationModel,
|
|
183
|
+
audio: audioStream,
|
|
184
|
+
inputAudioFormat: { type: 'audio/pcm', rate: 24000 },
|
|
185
|
+
targetLanguage: 'es',
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
console.log(await result.translationText);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
if (NoTranslationGeneratedError.isInstance(error)) {
|
|
191
|
+
console.log('NoTranslationGeneratedError');
|
|
192
|
+
console.log('Cause:', error.cause);
|
|
193
|
+
console.log('Response:', error.response);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
@@ -82,6 +82,11 @@ description: Learn about AI SDK Core.
|
|
|
82
82
|
description: 'Learn how to transcribe audio with AI SDK Core.',
|
|
83
83
|
href: '/docs/ai-sdk-core/transcription',
|
|
84
84
|
},
|
|
85
|
+
{
|
|
86
|
+
title: 'Translation',
|
|
87
|
+
description: 'Learn how to translate speech with AI SDK Core.',
|
|
88
|
+
href: '/docs/ai-sdk-core/translation',
|
|
89
|
+
},
|
|
85
90
|
{
|
|
86
91
|
title: 'Speech',
|
|
87
92
|
description: 'Learn how to generate speech with AI SDK Core.',
|
|
@@ -3210,7 +3210,7 @@ To see `streamText` in action, check out [these examples](#examples).
|
|
|
3210
3210
|
name: 'textStream',
|
|
3211
3211
|
type: 'AsyncIterableStream<string>',
|
|
3212
3212
|
description:
|
|
3213
|
-
'A text stream that returns only the generated text deltas. You can use it as either an AsyncIterable or a ReadableStream.
|
|
3213
|
+
'A text stream that returns only the generated text deltas. You can use it as either an AsyncIterable or a ReadableStream. Error parts are not surfaced in this stream. Use the `onError` callback or `stream` to observe them.',
|
|
3214
3214
|
},
|
|
3215
3215
|
{
|
|
3216
3216
|
name: 'finalStep',
|