翻篇收录说明
翻篇网页快照

AssemblyAI | AI SDK

https://ai-sdk.dev/providers/ai-sdk-providers/assemblyai

最近抓取:2026-12-04 03:17:14(北京时间)

最近内容变化:2026-11-30 23:52:36(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Learn how to set up the AssemblyAI provider and check AI Gateway availability.

正文摘录

AI SDK ProvidersMenuAssemblyAICopy for LLMView MarkdownAsk AI about this pageThe AssemblyAI provider contains transcription model support for the AssemblyAI transcription API and speech model support for the AssemblyAI text-to-speech API. AssemblyAI models are not currently available through AI Gateway, so the opening example uses @ai-sdk/assemblyai directly. See Using AI Gateway below for supported alternatives. import { transcribe } from 'ai'; import { assemblyai } from '@ai-sdk/assemblyai'; import { readFile } from 'node:fs/promises'; const { text } = await transcribe({ model: assemblyai.transcription('assemblyai-stt-3-7'), audio: await readFile('audio.mp3'), }); console.log(text); The example transcribes an audio.mp3 file from your project. Using AI Gateway The current AI Gateway model catalog does not list AssemblyAI models. Use @ai-sdk/assemblyai for the APIs on this page. To use other transcription models through Gateway, install ai and configure a Gateway API key: pnpmnpmyarnbun$ pnpm add ai Set an AI Gateway API key in your environment: export AI_GATEWAY_API_KEY=your_api_key_here Vercel deployments can also use OIDC authentication. See the Gateway documentation for supported models and APIs. Using @ai-sdk/assemblyai For direct access to AssemblyAI, install ai and @ai-sdk/assemblyai: pnpmnpmyarnbun$ pnpm add ai @ai-sdk/assemblyai Set your AssemblyAI API credential in the ASSEMBLYAI_API_KEY environment variable: export ASSEMBLYAI_API_KEY=your_api_key_here The following sections document the direct @ai-sdk/assemblyai provider, including its model factories and settings. Gateway model and feature availability can differ. Provider Instance You can import the default provider instance assemblyai from @ai-sdk/assemblyai: import { assemblyai } from '@ai-sdk/assemblyai'; If you need a customized setup, you can import createAssemblyAI from @ai-sdk/assemblyai and create a provider instance with your settings: import { createAssemblyAI } from '@ai-sdk/assemblyai'; const assemblyai = createAssemblyAI({ // custom settings, e.g. fetch: customFetch, }); You can use the following optional settings to customize the AssemblyAI provider instance: apiKey string | PromiseLike<string> | (() => string | PromiseLike<string>) Pass a synchronous or asynchronous callback to resolve the key before each request. The callback is responsible for caching and refreshing credentials. API key that is being sent using the Authorization header. It defaults to the ASSEMBLYAI_API_KEY environment variable. headers Record<string,string> Custom headers to include in the requests. fetch (input: RequestInfo, init?: RequestInit) => Promise<Response> Custom fetch implementation. Defaults to the global fetch function. You can use it as a middleware to intercept requests, or to provide a custom fetch implementation for e.g. testing. webSocket WebSocketConstructor Custom WebSocket implementation for streaming transcription, such as the ws package. AssemblyAI authenticates the streaming WebSocket with an Authorization header, which the native WebSocket in browsers, Node.js, Deno, and Bun cannot send. Transcription Models You can create models that call the AssemblyAI transcription API using the .transcription() factory method. The first argument is the model id, e.g. assemblyai-stt-3-7. const model = assemblyai.transcription('assemblyai-stt-3-7'); assemblyai-stt-3-7 is AssemblyAI's latest flagship model for pre-recorded audio. universal-2 is fully supported and remains available for languages assemblyai-stt-3-7 does not support; using it emits an informational warning (not a deprecation) suggesting assemblyai-stt-3-7. AssemblyAI has deprecated universal-3-5-pro. It still works, but using it emits a deprecation warning — prefer assemblyai-stt-3-7. The provider no longer lists universal-3-pro, which AssemblyAI has deprecated and no longer includes in its accepted models. AssemblyAI no longer accepts the best, slam-1, and nano models: requests for them fail with an AssemblyAI error that lists the accepted models. Models are sent using the speech_models request parameter. You can also pass additional provider-specific options using the providerOptions argument. For example, supplying the contentSafety option will enable content safety filtering. import { transcribe } from 'ai'; import { assemblyai } from '@ai-sdk/assemblyai'; import { type AssemblyAITranscriptionModelOptions } from '@ai-sdk/assemblyai'; import { readFile } from 'fs/promises'; const result = await transcribe({ model: assemblyai.transcription('assemblyai-stt-3-7'), audio: await readFile('audio.mp3'), providerOptions: { assemblyai: { contentSafety: true, } satisfies AssemblyAITranscriptionModelOptions, }, }); The following provider options are available: audioEndAt number End time of the audio in milliseconds. Optional. audioStartFrom number Start time of the audio in milliseconds. Optional. autoChapters boolean Whether to automatically generate chapters for the transcription. Optional. autoHighlights boolean Whether to automatically generate highlights for the transcription. Optional. boostParam enum Boost parameter for wordBoost. Allowed values: 'low', 'default', 'high'. Deprecated — only applies to the deprecated wordBoost; use keytermsPrompt instead. Optional. contentSafety boolean Whether to enable content safety filtering. Optional. contentSafetyConfidence number Confidence threshold for content safety filtering (25-100). Optional. customSpelling array of objects Custom spelling rules for the transcription. Each object has from (array of strings) and to (string) properties. Optional. disfluencies boolean Whether to include disfluencies (um, uh, etc.) in the transcription. Optional. domain string Enable a domain-specific model for specialized terminology. Currently supports 'medical-v1' (Medical Mode). Optional. entityDetection boolean Whether to detect entities in the transcription. Optional. filterProfanity boolean Whether to filter profanity in the transcription. Optional. formatText boolean Whether to format the text in the transcription. Optional. iabCategories boolean Whether to include IAB categories in the transcription. Optional. keytermsPrompt array of strings Domain-specific keyterms to boost recognition for (max 6 words per phrase). Replaces wordBoost for newer models — supported by assemblyai-stt-3-7 and universal-3-5-pro (and universal-2 when enabled). Optional. languageCode string Language code for the audio. Supports numerous ISO-639-1 and ISO-639-3 language codes. Optional. languageConfidenceThreshold number Confidence threshold for language detection. Optional. languageDetection boolean Whether to enable language detection. Optional. languageDetectionOptions object Options for automatic language detection: expectedLanguages (array of strings), fallbackLanguage (string), codeSwitching (boolean), codeSwitchingConfidenceThreshold (number, 0-1). Optional. multichannel boolean Whether to process multiple audio channels separately. Optional. prompt string Natural-language context (up to 1,500 words) to steer the model. Only supported by assemblyai-stt-3-7 and universal-3-5-pro. Optional. punctuate boolean Whether to add punctuation to the transcription. Optional. redactPii boolean Whether to redact personally identifiable information. Optional. redactPiiAudio boolean Whether to redact PII in the audio file. Optional. redactPiiAudioOptions object Options for PII-redacted audio: returnRedactedNoSpeechAudio (boolean), overrideAudioRedactionMethod ('silence'). Requires redactPiiAudio. Optional. redactPiiAudioQuality enum Quality of the redacted audio file. Allowed values: 'mp3', 'wav'. Optional. redactPiiPolicies array of enums Policies for PII redaction, specifying which types of information to redact. Supports numerous types like 'person_name', 'phone_number', etc. Optional. redactPiiReturnUnredacted boolean Return the original unredacted transcript alongside the redacted one. Requires redactPii. Optional. redactPiiSub enum Substitution method for redacted PII. Allowed values: 'entity_name', 'hash'. Optional. redactStaticEntities object Map of user-defined labels to exact terms to redact, e.g. { INTERNAL_TOOL: ['Bearclaw'] }. Applied on top of standard PII redaction. Requires redactPii. Optional. removeAudioTags enum Remove inline annotations from rich transcripts. Allowed values: 'all' (all annotations), 'speaker' (speaker cues only). AssemblyAI-STT-3.7 and Universal-3 Pro models. Optional. sentimentAnalysis boolean Whether to perform sentiment analysis on the transcription. Optional. speakerLabels boolean Whether to label different speakers in the transcription. Optional. speakerOptions object Options for speaker diarization: minSpeakersExpected (number), maxSpeakersExpected (number). Optional. speakersExpected number Expected number of speakers in the audio. Optional. speechThreshold number Threshold for speech detection (0-1). Optional. summarization boolean Whether to generate a summary of the transcription. Optional. summaryModel enum Model to use for summarization. Allowed values: 'informative', 'conversational', 'catchy'. Optional. summaryType enum Type of summary to generate. Allowed values: 'bullets', 'bullets_verbose', 'gist', 'headline', 'paragraph'. Optional. temperature number Sampling temperature (0-1) controlling randomness. AssemblyAI-STT-3.7 and Universal-3 Pro models. Optional. webhookAuthHeaderName string Name of the authentication header for webhook requests. Optional. webhookAuthHeaderValue string Value of the authentication header for webhook requests. Optional. webhookUrl string URL to send webhook notifications to. Optional. wordBoost array of strings List of words to boost in the transcription. Deprecated — rejected by assemblyai-stt-3-7 and universal-3-5-pro (works only on universal-2); use keytermsPrompt instead. Optional. Speaker diarization and audio-intelligence results The AI SDK's transcribe result exposes text, segments, language, and duratio