OpenAI-compatible transcription
Synchronous file transcription
Section titled “Synchronous file transcription”https://gptunnel.ru/v1/audio/transcriptionsThis OpenAI-compatible endpoint accepts an audio file as multipart/form-data and returns the transcript in the same request. You can use the official OpenAI SDK with the GPTunneL base_url and API key.
Use multipart/form-data to upload a file. An application/json request instead creates an asynchronous task from a URL.
Request headers
| Parameter | Type | Required? | Description |
|---|---|---|---|
Authorization | string | Required | API key. Support the format "Bearer YOUR_API_KEY" (as in OpenAI SDK) |
Content-Type | string | Required | multipart/form-data |
Form fields
| Parameter | Type | Required? | Description |
|---|---|---|---|
file | file | Required | Audio file up to 25 MB, lasting from 1 second to 2 hours |
model | string | Required | whisper-1 |
language | string | Optional | Language code (e.g. "ru", "en"). If not specified, language is automatically defined |
response_format | string | Optional | json ( default) or verbose_json |
prompt | string | Optional | A hint with a style or dictionary of terms |
temperature | number | Optional | 0 to 1 |
Supported formats
Section titled “Supported formats”Entry file formats: flac, m4a, mp3, mp4, mpeg, mpga, oga, ogg, wav, webm.
The API detects the format from the contents of the file. A filename extension is optional. Unsupported containers such as aiff or wma return unsupported_format before contacting the provider, and the account is not charged.
Containers aiff, wma and amr available in asynchronous mode.
Example request
Section titled “Example request”Download the sample WAV file and set the GPTUNNEL_API_KEY environment variable. The examples read blue-sky.wav from the current directory. For Python or Node.js, install the openai package for that language.
import os
from openai import OpenAI
client = OpenAI( api_key=os.environ['GPTUNNEL_API_KEY'], base_url='https://gptunnel.ru/v1',)
with open('blue-sky.wav', 'rb') as audio: transcription = client.audio.transcriptions.create( model='whisper-1', file=audio, language='en', )
print(transcription.text)curl --request POST \ --url https://gptunnel.ru/v1/audio/transcriptions \ --header "Authorization: Bearer $GPTUNNEL_API_KEY" \ --form 'file=@blue-sky.wav' \ --form 'model=whisper-1' \ --form 'language=en'import fs from 'fs'import OpenAI from 'openai'
const client = new OpenAI({ apiKey: process.env.GPTUNNEL_API_KEY, baseURL: 'https://gptunnel.ru/v1',})
const transcription = await client.audio.transcriptions.create({ model: 'whisper-1', file: fs.createReadStream('blue-sky.wav'), language: 'en',})
console.log(transcription.text)Example response
Section titled “Example response”The examples show excerpts from the response for the sample WAV file. With verbose_json, the API returns timestamped segments along with the full transcript.
{ "text": "The sky is blue today."}{ "task": "transcribe", "language": "english", "duration": 1.8799999952316284, "text": "The sky is blue today.", "segments": [ { "id": 0, "start": 0, "end": 2, "text": " The sky is blue today." } ]}Errors
Section titled “Errors”For whisper-1, this endpoint returns HTTP 400 for the text, srt, and vtt response formats. The example below shows the error for response_format=text.
{ "error": { "message": "Unsupported response_format \"text\". Only \"json\" and \"verbose_json\" are supported.", "type": "invalid_request_error", "param": "file", "code": "provider_rejected" }}Errors return in OpenAI format:
{ "error": { "message": "Insufficient quota. Your account balance is too low to complete this request.", "type": "insufficient_quota", "param": null, "code": "insufficient_quota" }}| HTTP | code |
Cause |
|---|---|---|
| 400 | missing_required_parameter |
Not transferred file |
| 400 | file_too_large |
File More Than 25 MB - Use Asynchronous Mode |
| 400 | invalid_value |
Unacceptable model or other parameter |
| 400 | invalid_audio |
File failed to decode (damaged or not audio) |
| 400 | unsupported_format |
Container format not supported |
| 400 | audio_too_long |
Longer than 2 hours |
| 400 | audio_too_short |
Duration less than 1 second |
| 400 | provider_rejected |
The conductor rejected the file or the requested response format |
| 401 | — | Wrong API Key |
| 403 | model_not_allowed |
The model is not on the API key list |
| 404 | model_not_found |
Model unknown or not available key |
| 429 | insufficient_quota |
Insufficient balance funds |
| 429 | api_key_limit_exceeded |
Exceeded API-key spending limit |
| 500 | internal_error |
Internal error |