Transcription API to SRT and VTT Subtitles
Turn audio into SRT or VTT subtitles with a transcription API: the multipart request, response_format values, verbose_json timestamps and a fallback script.
By OceanToken Team

Editor's note: A subtitle pipeline written around one model's
srtoutput can break the day someone swaps the speech-to-text model. The format field looks like a promise, but our own docs say plainly that models differ in which formats they return. We would rather own the subtitle file ourselves: ask for timestamps, build the SRT and VTT in a few lines of code, and let the model be a replaceable part.
Short answer: To get SRT subtitles from a transcription API, upload the audio to POST /v1/audio/transcriptions with response_format set to srt or vtt. Not every model returns those formats, so the safer route is verbose_json, which adds timestamped segments, and a short script that writes the SRT and VTT files for you.
Key takeaways:
- On OceanToken, one key and the standard OpenAI SDK reach several transcription models, including
openai/whisper-1andmicrosoft/mai-transcribe-2, so you can compare their subtitles by changing one model string (docs.oceantoken.ai, checked November 26, 2026). - The endpoint takes a multipart file upload. A URL in place of the file is not fetched, and requests should stay under 10 MB where you can.
response_formatacceptsjson,text,verbose_json,srtandvtt, but each model offers its own subset. Send one short clip per model before you build on any format.- Long recordings need splitting, and split files need their timestamps shifted before you merge them into one subtitle file.
01 · Transcription API SRT subtitles: the request
The request is a multipart form upload, not JSON. That surprises people who come from chat completions, where everything is a JSON body. Our speech guide describes the transcription endpoint as following OpenAI's Audio API, so client.audio.transcriptions in the OpenAI SDKs works once you change the base URL and key.
Here is the smallest request that asks for subtitles directly. It uses curl because the -F flags make the multipart shape easy to see.
curl https://api.oceantoken.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $OCEANTOKEN_API_KEY" \
-F model="openai/whisper-1" \
-F file=@interview.mp3 \
-F language="en" \
-F response_format="srt" \
-o interview.srt
Each form field has a job, and two of them are optional but worth sending on almost every subtitle request.
| Field | Required | What it does (docs, checked 2026-11-26) | Subtitle advice |
|---|---|---|---|
file |
Yes | The audio: mp3, m4a, wav, webm and other common formats | Upload the file itself; a URL is not fetched |
model |
Yes | The ID of a transcription model | Keep it in config so you can swap it |
language |
No | Spoken language as an ISO-639-1 code such as en or zh; improves accuracy when you know it |
Set it whenever you know the language of the source |
prompt |
No | Names and spellings to expect | Put speaker names, product names and jargon here |
response_format |
No | json (default), text, verbose_json, srt, vtt; models differ in which they offer |
Prefer verbose_json for a pipeline that must survive model changes |
The prompt field is the simplest accuracy fix you have. Subtitles are read by people who know how the host's name is spelled, and a wrong spelling repeated forty times is the kind of error viewers notice. OpenAI's guide adds a limit worth knowing: for whisper-1, prompts have a 224-token cap. Keep the prompt to a list of names and terms rather than a paragraph of context.
02 · The five response_format values, and why "models differ" matters
response_format decides what comes back, and our docs list five values for every transcription model we checked. The catch is the sentence right after the list: "Models differ in which they offer." The per-model API references for openai/whisper-1, microsoft/mai-transcribe-2, openai/gpt-transcribe and openai/gpt-4o-mini-transcribe all print the same five values with that same note, so the reference page alone cannot tell you which model returns a real SRT file.
| Value | What our docs say it returns | Useful for subtitles? |
|---|---|---|
json |
{"text": "..."} |
No timing, so no |
text |
The plain transcript | No timing, so no |
verbose_json |
The transcript plus segments with timestamps | Yes, and you control the output format |
srt |
SubRip subtitles | Yes, if the model offers it |
vtt |
WebVTT subtitles | Yes, if the model offers it |
There is a concrete reason to be careful. OpenAI's own API reference says that for gpt-4o-transcribe and gpt-4o-mini-transcribe, "the only supported format is json." The transcription sample in our speech guide uses openai/gpt-4o-mini-transcribe for a plain transcript. If you copy that sample and add response_format="srt", OpenAI's documentation suggests you should not expect subtitles from that model, and what you actually receive is the first thing to check. Maybe it is an error, maybe it is plain text. Either way, you want to find out on a ten-second clip, not after a two-hour batch.
So the practical rule is simple. Treat srt and vtt as conveniences that some models offer, and treat verbose_json as the contract your pipeline depends on. If a model returns neither subtitles nor segments, it is the wrong model for timed captions, however good its plain text is.
03 · Speech to text API timestamps with verbose_json
verbose_json is the format to ask for when you need timestamps from a speech to text API, because our docs say it "adds segments with timestamps" to the transcript. Each segment is a stretch of speech with a start time, an end time and its text, which maps almost one-to-one onto a subtitle cue.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.oceantoken.ai/v1",
api_key=os.environ["OCEANTOKEN_API_KEY"],
)
MODEL = "openai/whisper-1" # swap for microsoft/mai-transcribe-2 to compare
with open("interview.mp3", "rb") as audio:
result = client.audio.transcriptions.create(
model=MODEL,
file=audio,
language="en",
prompt="Speakers: Dana Ruiz, Marco Ilic. Terms: OKR, Kubernetes.",
response_format="verbose_json",
)
data = result.model_dump() if hasattr(result, "model_dump") else result
segments = data.get("segments") or []
print(len(segments), "segments")
for seg in segments[:3]:
print(seg["start"], seg["end"], seg["text"])
The model_dump() line turns the SDK object into a plain dictionary, which keeps the rest of the script independent of how a given model fills optional fields. Print the first few segments the first time you run a new model. You are checking three things: that segments exists at all, that start and end are numbers in seconds, and that the segment lengths look like something a person could read on screen.
On OpenAI's API, whisper-1 also accepts timestamp_granularities[] for word-level timing, and OpenAI's reference notes that response_format must be verbose_json to use it. Our docs do not list that parameter for the models on our endpoint, so treat word timestamps as something to test rather than something to plan around. Segment timing is enough for ordinary subtitles. Word timing matters mostly for karaoke-style highlighting and for tight editing in a timeline.
04 · Build SRT and VTT yourself from verbose_json
Writing the subtitle file yourself takes about twenty lines and removes the dependency on any one model's srt output. The two formats differ in small, strict ways. SRT numbers each cue and uses a comma before the milliseconds. WebVTT starts with the string WEBVTT and uses a full stop before the milliseconds, as the W3C specification defines.

def fmt_ts(seconds: float, sep: str) -> str:
ms = int(round(seconds * 1000))
h, ms = divmod(ms, 3_600_000)
m, ms = divmod(ms, 60_000)
s, ms = divmod(ms, 1000)
return f"{h:02}:{m:02}:{s:02}{sep}{ms:03}"
def to_srt(segments, offset: float = 0.0) -> str:
cues = []
for i, seg in enumerate(segments, 1):
start = fmt_ts(seg["start"] + offset, ",")
end = fmt_ts(seg["end"] + offset, ",")
cues.append(f"{i}\n{start} --> {end}\n{seg['text'].strip()}\n")
return "\n".join(cues)
def to_vtt(segments, offset: float = 0.0) -> str:
lines = ["WEBVTT", ""]
for seg in segments:
start = fmt_ts(seg["start"] + offset, ".")
end = fmt_ts(seg["end"] + offset, ".")
lines += [f"{start} --> {end}", seg["text"].strip(), ""]
return "\n".join(lines)
with open("interview.srt", "w", encoding="utf-8") as f:
f.write(to_srt(segments))
with open("interview.vtt", "w", encoding="utf-8") as f:
f.write(to_vtt(segments))
The offset argument is there for section 07, where split files need their times shifted. Write the files as UTF-8, because subtitle files for names with accents or for non-Latin languages break quietly in players that guess the encoding.
This approach also gives you a place to fix things the model does not care about. You can split a long segment into two cues, merge a one-word cue into its neighbor, or strip filler words, all before the file is written. A model's own srt output gives you none of those hooks unless you parse it back into segments first.
05 · Whisper API VTT subtitles
Yes, you can ask the Whisper API for VTT subtitles directly with response_format="vtt" on openai/whisper-1. OpenAI's reference lists vtt among the format options and only restricts the gpt-4o transcribe models to JSON, so Whisper is the obvious first candidate when you want a subtitle file in one call. On our endpoint, the model's API reference lists the same five values, so the same request shape applies.
with open("lecture.m4a", "rb") as audio:
vtt_text = client.audio.transcriptions.create(
model="openai/whisper-1",
file=audio,
language="en",
response_format="vtt",
)
with open("lecture.vtt", "w", encoding="utf-8") as f:
f.write(vtt_text if isinstance(vtt_text, str) else str(vtt_text))
When the format is srt, vtt or text, the SDK hands back the body as a string rather than an object, which is why the sample checks the type before writing. Open the file and confirm the first line reads WEBVTT before you load it into a player.
There is a planning reason not to build everything on this one call. OpenAI's speech-to-text guide states that whisper-1, gpt-4o-transcribe, gpt-4o-mini-transcribe and gpt-4o-transcribe-diarize are deprecated on its API and will shut down on February 26, 2027, and it recommends gpt-transcribe as the starting point. We have not seen a statement about how long those ids stay available on our endpoint, so the safe reading is that Whisper's one-call VTT is a convenience with a horizon.
A pipeline that asks for verbose_json and writes its own VTT can move to the next model without touching the subtitle code. You can find openai/gpt-transcribe in our docs with the same five-value format note, which means its subtitle support is also something to check on a short clip.
06 · MAI-Transcribe subtitles
For MAI-Transcribe subtitles, call microsoft/mai-transcribe-2 on the same endpoint and ask for verbose_json first. Its API reference on our docs lists the same five response_format values with the "models differ" note, and its sample shows only the default {"text": ...} response, so we cannot tell you from the documentation alone whether it returns srt or vtt. One short test answers that.
The MAI-Transcribe 2 model page describes it as a speech-to-text model from Microsoft AI, released September 3, 2026, with meeting and call transcripts listed among its uses, and it is billed per minute of audio. That profile fits subtitle work for recorded meetings, webinars and interviews, where the speech is conversational and names matter.
Here is how we would approach it in practice. Send the same two-minute clip to microsoft/mai-transcribe-2 three times, once each with verbose_json, srt and vtt, and save all three responses. If verbose_json comes back with segments, you can use the script from section 04 and you never need to depend on the other two. If only srt works, parse it into segments so the rest of your pipeline still deals with one shape. If neither returns timing, use MAI-Transcribe for the plain transcript and take the timing from a model that does return segments.
The comparison worth making is not which model is "better" in general. It is which one spells your speakers' names correctly, splits sentences where a viewer would expect a cue to end, and keeps up with crosstalk on your own recordings. Run both models on the same clip, using the prompt field with the same names, and read the two subtitle files side by side.
07 · Long recordings: split under 10 MB and shift timestamps
Long recordings need to be split before upload, and the timestamps from each piece need shifting before you merge them. Our limits page asks you to keep each request under 10 MB where you can, and the speech guide gives a useful rule of thumb: a 10 MB MP3 at 64 kbit/s holds about 20 minutes. OpenAI's guide separately says its own file limit is 25 MB and suggests compressing or splitting larger recordings.

Compress first, because it may make splitting unnecessary for a typical meeting. Then split into pieces comfortably below the size target.
# mono, 64 kbit/s: about 20 minutes per 10 MB
ffmpeg -i talk.wav -ac 1 -b:a 64k talk.mp3
# 15-minute pieces, copied without re-encoding
ffmpeg -i talk.mp3 -f segment -segment_time 900 -c copy part_%03d.mp3
Each piece starts its timestamps at zero, so a naive merge stacks every cue at the start of the video. The fix is a running offset. Measure each piece's real duration instead of assuming 900 seconds, because copying without re-encoding cuts at frame boundaries and the pieces drift slightly from the nominal length.
import glob
import subprocess
def duration(path: str) -> float:
out = subprocess.run(
["ffprobe", "-v", "error", "-show_entries", "format=duration",
"-of", "default=nw=1:nk=1", path],
capture_output=True, text=True, check=True,
)
return float(out.stdout.strip())
merged, offset = [], 0.0
for part in sorted(glob.glob("part_*.mp3")):
with open(part, "rb") as audio:
r = client.audio.transcriptions.create(
model=MODEL, file=audio, language="en",
response_format="verbose_json",
)
data = r.model_dump() if hasattr(r, "model_dump") else r
for seg in data.get("segments") or []:
merged.append({"start": seg["start"] + offset,
"end": seg["end"] + offset,
"text": seg["text"]})
offset += duration(part)
with open("talk.srt", "w", encoding="utf-8") as f:
f.write(to_srt(merged))
Fixed-length cuts have one weakness: a cut can land mid-word. OpenAI's guide warns that splitting in the middle of a sentence removes context and can reduce accuracy. If the seams in your merged file show a broken word or a duplicated phrase, move the cut points to pauses. FFmpeg's silencedetect filter can list silent stretches, and cutting at the nearest one is usually enough. Check every seam in the first few files you produce, since that is where errors cluster.
08 · Subtitle delivery checklist
A transcript with timestamps is not yet a good subtitle file. These are editorial checks, drawn from common subtitle practice rather than from any measurement of ours, and the exact limits should come from the platform or client you deliver to.
- Line length. Take the maximum characters per line from your platform's style guide and wrap or split cues that exceed it. Long segments from a model are the most common problem.
- Two lines at most. If a cue needs three lines, split it into two cues at a natural pause and divide the time between them.
- Reading time. A cue that flashes for a fraction of a second is unreadable. Merge very short cues with a neighbor.
- Break at phrase boundaries. Split after a comma or between clauses, not between an article and its noun.
- Names and terms. Search the file for each name in your
promptand confirm the spelling held across the whole file, especially after a seam. - Encoding and header. UTF-8 for both formats, and
WEBVTTas the first line of every VTT file. - Sync spot-check. Load the file in a player at three points: the start, a seam between pieces, and the end.
If the next step is translation, our Hunyuan-MT translation API guide covers sending text segments through a translation model. Translate the segment text and keep the times, so the translated file stays in sync. For getting the finished file into an editor, our guide to editing clips in CapCut and Premiere covers the timeline side.
How to test this on your workload
We have not run these checks for you. Each one is a single request or a short script, and together they tell you which model and format to build on.
- Format matrix. Pick one clean two-minute clip. Send it to
openai/whisper-1andmicrosoft/mai-transcribe-2with each ofjson,text,verbose_json,srtandvtt. Record what each combination returns: the format you asked for, something else, or an error. - Speech-guide sample model. Repeat the
srtrequest onopenai/gpt-4o-mini-transcribeandopenai/gpt-transcribe, and write down the result next to OpenAI's note that thegpt-4otranscribe models only support JSON on its own API. - Segment shape. For each model that returns
verbose_json, print the first five segments and confirmstart,endandtextare present and that times are in seconds. - Round trip. Build SRT from
verbose_jsonwith the section 04 script and compare it, cue by cue, with the model's ownsrtoutput where one exists. - Language and prompt. Run the same clip with and without
languageand with and without apromptlisting names. Count misspelled names in each output. - Seams. Transcribe a 40-minute file split into three pieces. Check the two seams for broken or repeated words and for timing jumps.
- Size. Send one piece just under 10 MB and note the response time, so you know what a full batch will take.
- Player check. Load the VTT in a browser
<track>element and the SRT in your editor, and watch the first minute of each.
Our take: Ask for verbose_json and write the SRT and VTT yourself. It is twenty lines of code, it lets you fix cue length and names before the file exists, and it keeps your subtitle output identical when you change models. Use a model's own srt or vtt output only for one-off jobs where you will never swap the model.
Running it on OceanToken
The base URL is https://api.oceantoken.ai/v1 and the endpoint is POST /v1/audio/transcriptions, with model ids such as openai/whisper-1 and microsoft/mai-transcribe-2. What helps for subtitle work, from our docs and model pages as of November 26, 2026:
- One key for every transcription model. The same key and balance call Whisper, MAI-Transcribe and the other speech-to-text models listed in the model catalog, so the format matrix above is a loop over model ids rather than several accounts.
- OpenAI SDK, unchanged. The transcription endpoint follows OpenAI's Audio API, so existing
client.audio.transcriptionscode moves by changing the base URL and key. - Switching models is the model string. Your subtitle script stays the same when you try a new transcription model, which is the point of building on
verbose_json. - Prepaid, billed by audio length on most models. Our docs say most transcription models charge by audio length and a few by token; each model page shows the unit. There is no subscription.
Price: see the current rate on /whisper-api and on the Whisper 1 and MAI-Transcribe 2 model pages.
FAQ
Can a transcription API return SRT directly? Some models can, with response_format="srt". Our docs list the value for every transcription model but say models differ in which formats they offer, so test each model on a short clip.
What is the difference between SRT and VTT? SRT numbers each cue and uses a comma before the milliseconds. WebVTT starts with WEBVTT and uses a full stop, and browsers read it natively through the <track> element.
Can I send an audio URL instead of uploading the file? No. Our speech guide says the file must be uploaded and a URL in its place is not fetched. Download the audio first, then upload it.
How long can one transcription request be? Keep each request under 10 MB where you can. At 64 kbit/s, a 10 MB MP3 holds about 20 minutes; split longer recordings and shift the timestamps when you merge.
Is this the same as subtitles inside a generated video? No. Burning text into AI-generated video frames is a different task, covered in our guide to on-screen text and subtitles in Seedance. This guide transcribes real audio into a separate subtitle file.
Does MAI-Transcribe 2 return VTT? Our docs do not say for that model specifically. Send one clip with response_format="vtt" and one with verbose_json, and build from whichever returns timing.
Sources
- OceanToken docs: Speech and transcription (checked 2026-11-26)
- OceanToken docs: Limits (checked 2026-11-26)
- OceanToken docs: Whisper 1 API reference (checked 2026-11-26)
- OceanToken docs: MAI-Transcribe 2 API reference (checked 2026-11-26)
- OceanToken: MAI-Transcribe 2 model page (checked 2026-11-26)
- OpenAI: Speech to text guide (checked 2026-11-26)
- OpenAI: Create transcription API reference (checked 2026-11-26)
- W3C: WebVTT specification (checked 2026-11-26)
Get your OceanToken API key
- Create an OceanToken account and an API key.
- Copy the snippet below, paste your key, and run it.
- Check the current rate on /whisper-api.
curl https://api.oceantoken.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $OCEANTOKEN_API_KEY" \
-F model="openai/whisper-1" \
-F file=@interview.mp3 \
-F response_format="verbose_json"
The transcription endpoint takes a multipart upload, so this snippet uses -F fields instead of a JSON body. The model id matches the examples above.
More from the blog
Veo 3.1 Reference Images API Guide
How to send reference images to Veo 3.1 through the API: input_references vs first frame, which tiers take them, two-shot Python script and a consistency test.
LLM Function Calling API Across Models
Write one LLM function calling API loop that works across GPT, Claude, Gemini, Qwen, GLM and DeepSeek: tool_choice, streaming and the silent no-call trap.
LLM Image Input API: Screenshots and Scans
Send screenshots, photos and scans to a chat model with one LLM image input API: URL vs base64 data URL, per-model image limits, the 400 error and token costs.