Guide · Vercel AI SDK
Saidwire speech-to-text in the AI SDK
The AI SDK's transcribe() function works with any transcription provider. Saidwire's transcription endpoint is compatible with OpenAI's, so the AI SDK's own OpenAI provider can call it once you set its baseURL. You don't need a new package.
| you need | |
|---|---|
| AI SDK | npm install ai @ai-sdk/openai. Checked with ai 7.0 and @ai-sdk/openai 4.0, on Node.js 18 or later. |
| Saidwire API key | sk_live_... from saidwire.com/dev (120 free hours, no card) |
Prefer a dedicated provider? Install it from npm:
npm install @saidwire/ai-sdk-provider
npm package · Source on GitHub · The steps below use the OpenAI provider with our base URL and work too.
Transcribe a file
import { createOpenAI } from '@ai-sdk/openai';
import { transcribe } from 'ai';
import { readFile } from 'node:fs/promises';
const saidwire = createOpenAI({
apiKey: process.env.SAIDWIRE_API_KEY,
baseURL: 'https://api.saidwire.com/v1',
});
const result = await transcribe({
model: saidwire.transcription('whisper-1'), // any name works; see below
audio: await readFile('meeting.mp3'),
});
console.log(result.text);
console.log(result.segments); // [{ text, startSecond, endSecond }, ...]
console.log(result.durationInSeconds); // 12
export SAIDWIRE_API_KEY=sk_live_xxxxxxxx.yyyyyyyyyyyyyyyy node transcribe.mjs
audio can be a Buffer, Uint8Array, base64 string or URL. If you pass a URL, the AI SDK downloads the file first. In AI SDK 5 and 6, the function is called experimental_transcribe.
Which model name to use
Saidwire accepts any model name, but the AI SDK chooses the reply format from the name you pass:
| model name | you get |
|---|---|
whisper-1 | text, segments with start and end times, durationInSeconds and language, because the AI SDK asks for the detailed reply format |
saidwire-en or any other name | text and durationInSeconds only |
For word timestamps, pass providerOptions: { openai: { timestampGranularities: ['word'] } }. result.segments then has one entry per word. The full reply, with words, is in result.responses[0].body.
Troubleshooting
| you see | fix |
|---|---|
401 Incorrect API key provided | Check that SAIDWIRE_API_KEY is set and that you passed it as apiKey. Without it, the provider falls back to OPENAI_API_KEY. |
404 | Set baseURL to exactly https://api.saidwire.com/v1. |
400 ... unsupported_language | Saidwire transcribes English only. Leave out language or set it to en. |
429 | Too many files at once for your key (trial keys allow 4), or your free hours are used up. |
Good to know
- Use a separate provider instance named
saidwire, as shown above, so your OpenAI key and your Saidwire key don't get mixed up. - Files can be up to 100 MB and 60 minutes. WAV, MP3, FLAC, Ogg/Opus, WebM and M4A/MP4 work. For M4A/MP4 files, the index has to be at the start of the file. For ffmpeg output, add
-movflags +faststart. - This sends complete files. For live audio, use the WebSocket API in the API docs.
- Saidwire processes the audio in memory and does not store it.
- After the free hours, Saidwire costs $0.30 per audio hour, billed per second.
Stuck? Email support@saidwire.com with the x-request-id from the failed call.
OpenAI is a trademark of OpenAI. Open WebUI, n8n, LiteLLM, Dify, Flowise, Vercel and the AI SDK belong to their respective owners. Saidwire is not affiliated with OpenAI or with these projects.