Portkey supports both Transcription and Translation methods for STT models and follows the OpenAI signature where you can send the file (in flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm formats) as part of the API request.
Here’s an example:
OpenAI NodeJSOpenAI PythonREST
Copy
Ask AI
import fs from "fs";import OpenAI from "openai";import { PORTKEY_GATEWAY_URL, createHeaders } from 'portkey-ai'const openai = new OpenAI({ apiKey: "PORTKEY_API_KEY", baseURL: PORTKEY_GATEWAY_URL});// Transcriptionasync function transcribe() { const transcription = await openai.audio.transcriptions.create({ file: fs.createReadStream("/path/to/file.mp3"), model: "@openai/whisper-1", }); console.log(transcription.text);}transcribe();// Translationasync function translate() { const translation = await openai.audio.translations.create({ file: fs.createReadStream("/path/to/file.mp3"), model: "@openai/whisper-1", }); console.log(translation.text);}translate();
Copy
Ask AI
import fs from "fs";import OpenAI from "openai";import { PORTKEY_GATEWAY_URL, createHeaders } from 'portkey-ai'const openai = new OpenAI({ apiKey: "PORTKEY_API_KEY", baseURL: PORTKEY_GATEWAY_URL});// Transcriptionasync function transcribe() { const transcription = await openai.audio.transcriptions.create({ file: fs.createReadStream("/path/to/file.mp3"), model: "@openai/whisper-1", }); console.log(transcription.text);}transcribe();// Translationasync function translate() { const translation = await openai.audio.translations.create({ file: fs.createReadStream("/path/to/file.mp3"), model: "@openai/whisper-1", }); console.log(translation.text);}translate();
The following providers are supported for speech-to-text with more providers getting added soon. Please raise a request or a PR to add model or provider to the AI gateway.