Deploy Whisper STT API | (Just Updated) Transcription That Answers the First Request
OpenAI-compatible speech to text, model baked in, threads sized to the box
Just deployed
/home/ubuntu/.cache/huggingface/hub
Deploy and Host a Whisper Speech-to-Text API on Railway
An OpenAI-compatible speech-to-text endpoint — POST /v1/audio/transcriptions — running
Whisper on CPU through Speaches and
faster-whisper. Point any OpenAI client at the URL, change the base URL, and keep the
audio on your own infrastructure.
The transcription model ships inside the image, so the first request after the deploy returns a transcript instead of an error.
About Hosting a Whisper Speech-to-Text API
Speaches serves the OpenAI audio API on top of CTranslate2. Three things decide whether a deployment of it is usable, and they are the three this template fixes.
A model has to be present before the first call. Speaches does not fetch a model on
demand — a deploy with an empty cache answers 404 Model 'Systran/faster-whisper-small' is not installed locally to every transcription request while the container stays healthy
and /v1/models lists only the voice-activity detector. This template bakes
Systran/faster-whisper-small into the image and copies it onto the volume on first boot,
because a Railway volume is a bind mount that would otherwise hide anything the image
build left under its path.
The thread pool should match the container. cpu_threads defaults to 0, which lets
CTranslate2 size its pool from the cores it can see — the host's count, not the
container's quota; this deploy's container saw 32 cores against a quota of 8. The
entrypoint reads /sys/fs/cgroup/cpu.max and pins the pool per deploy. Measured on one
host at --cpus 2 --memory 2g on the same 60.9-second file, warm: 15.03 s and 14.35 s
with the default against 11.54 s and 11.69 s pinned. On Railway itself the same test is a
smaller and noisier win — around 3.2 s pinned against 3.5 s unpinned — so this is a
modest, not a dramatic, difference.
The endpoint has to be closed. Speaches installs its auth dependency only when
API_KEY is set, so an unset key publishes transcription to anyone who finds the URL.
The key is generated per deploy and the container refuses to boot without one. The Gradio
playground, which is served with no authentication of its own, is off.
The volume is mounted as uid 0 by the platform while the image runs as ubuntu
(uid 1000); the entrypoint repairs the ownership and drops privileges rather than running
the server as root.
Common Use Cases
- Transcribe recordings without per-minute billing — meetings, calls, voice notes and podcasts stay on your own instance.
- Give an agent or bot ears — anything that already speaks the OpenAI audio API works
by changing
base_url. - Subtitles and search —
response_format=srt,vtt,jsonorverbose_jsonfrom the same endpoint, in 99 languages, with/v1/audio/translationsfor English output.
Dependencies for Whisper Speech-to-Text Hosting
- Speaches 0.9.0-rc.3 — OpenAI-compatible STT/TTS server (MIT)
- faster-whisper / CTranslate2 — the inference engine
Systran/faster-whisper-small— baked into the image,int8on CPU- A volume at
/home/ubuntu/.cache/huggingface/hubfor the model cache
Deployment Dependencies
- speaches-ai/speaches
- SYSTRAN/faster-whisper
- bon5co/whisper-railway — the wrapper image
used here,
ghcr.io/bon5co/whisper-railway:0.9.0-rc.3
Implementation Details
API_KEYis generated per deploy as a Railway secret and is required on every/v1/*route./healthis the only unauthenticated route, because the platform's healthcheck dials it.- The deploy form asks for nothing. Every other setting has one correct value and lives in the image, since a template variable holding a literal publishes as a blank required field.
- Larger models —
Systran/faster-whisper-medium,…-large-v3— install at runtime withPOST /v1/models/Systran/faster-whisper-mediumand persist on the volume. Kokoro TTS installs the same way if you want/v1/audio/speechfrom the same service. $PORTis honoured, because Railway's HTTP healthcheck dials the injected port rather than the domain's target port.
What to expect on CPU: roughly five times faster than real time for
faster-whisper-small on a two-vCPU container. Good for recordings and queues; a request
long enough to exceed Railway's edge timeout should be split client-side. The volume
belongs to one replica, so this service scales up rather than out.
Why Deploy a Whisper Speech-to-Text API on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying a Whisper speech-to-text API on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
