Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
<!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Add transcription to your own API | FunASR</title><meta name="description" content="Start with one recording and a text response. Connect a local application, then check authentication, response formats and deployment boundaries."><meta name="keywords" content="openai whisper api alternative, self-hosted speech to text api, openai audio transcriptions api, whisper api self-hosted, /v1/audio/transcriptions, openai compatible asr, replace openai whisper api, local whisper api, private speech to text api, funasr server">
<link rel="icon" href="/logo.png"><meta property="og:title" content="Add transcription to your own API"><meta property="og:description" content="Start with one recording and a text response. Connect a local application, then check authentication, response formats and deployment boundaries.">
<meta property="og:type" content="article"><meta property="og:url" content="https://www.funasr.com/en/blog/self-hosted-openai-whisper-api-alternative.html"><meta property="og:image" content="https://www.funasr.com/logo.png">
<link rel="canonical" href="https://www.funasr.com/en/blog/self-hosted-openai-whisper-api-alternative.html"><link rel="alternate" hreflang="en" href="https://www.funasr.com/en/blog/self-hosted-openai-whisper-api-alternative.html"><link rel="alternate" hreflang="zh" href="https://www.funasr.com/blog/self-hosted-openai-whisper-api-alternative.html"><link rel="alternate" hreflang="x-default" href="https://www.funasr.com/en/blog/self-hosted-openai-whisper-api-alternative.html">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<script type="application/ld+json">{"@context":"https://schema.org","@type":"BlogPosting","headline":"Add transcription to your own API","description":"Start with one recording and a text response. Connect a local application, then check authentication, response formats and deployment boundaries.","datePublished":"2026-06-18","dateModified":"2026-11-12","author":{"@type":"Organization","name":"FunASR / Tongyi Lab"},"publisher":{"@type":"Organization","name":"FunASR","logo":{"@type":"ImageObject","url":"https://www.funasr.com/logo.png"}},"mainEntityOfPage":{"@type":"WebPage","@id":"https://www.funasr.com/en/blog/self-hosted-openai-whisper-api-alternative.html"},"image":"https://www.funasr.com/logo.png"}</script>
<style>:root{--primary:#2563eb;--primary-dark:#1d4ed8;--bg:#fff;--surface:#f8fafc;--border:#e2e8f0;--text:#0f172a;--text-soft:#475569;--text-muted:#94a3b8;--radius:12px}
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:'Inter',-apple-system,sans-serif;color:var(--text);line-height:1.7}
a{color:var(--primary);text-decoration:none}a:hover{text-decoration:underline}
.container{max-width:800px;margin:0 auto;padding:0 24px}
.nav{position:fixed;top:0;left:0;right:0;z-index:100;background:rgba(255,255,255,0.9);backdrop-filter:blur(12px);border-bottom:1px solid var(--border);padding:14px 0}
.nav .container{max-width:1120px;display:flex;align-items:center;gap:24px}
.nav-logo{font-size:1.2rem;font-weight:800;color:var(--text)}.nav-logo span{color:var(--primary)}
.nav-links{display:flex;gap:20px;margin-left:auto;flex-wrap:wrap}
.nav-links a{font-size:0.85rem;font-weight:500;color:var(--text-soft)}
.nav-btn{padding:7px 16px;background:var(--primary);color:#fff;border-radius:7px;font-size:0.83rem;font-weight:600}
article{padding:120px 0 80px}
h1{font-size:2rem;font-weight:800;line-height:1.3;margin-bottom:14px}
h2{font-size:1.3rem;font-weight:700;margin:36px 0 14px;padding-top:16px;border-top:1px solid var(--border)}
h3{font-size:1.05rem;font-weight:700;margin:22px 0 10px}
p{margin-bottom:14px;color:var(--text-soft)}
ul,ol{margin:0 0 14px 22px;color:var(--text-soft)}li{margin-bottom:6px}
table{width:100%;border-collapse:collapse;margin:16px 0;font-size:0.86rem}
th,td{padding:10px 12px;text-align:left;border-bottom:1px solid var(--border)}
th{font-weight:600;background:var(--surface);font-size:0.78rem;color:var(--text-muted)}
pre{background:#1e293b;color:#e2e8f0;padding:18px;border-radius:10px;overflow-x:auto;font-size:0.82rem;line-height:1.7;margin:14px 0}
code{font-family:ui-monospace,Menlo,monospace}
p code,li code{background:var(--surface);padding:2px 6px;border-radius:5px;font-size:0.85em;color:var(--primary-dark)}
.post-meta{color:var(--text-muted);font-size:0.85rem;margin-bottom:24px}
.cta{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px;margin:28px 0;text-align:center}
.cta a.btn{display:inline-block;padding:10px 24px;background:var(--primary);color:#fff;border-radius:8px;font-weight:600}
.post-list{list-style:none;margin:0;padding:0}
.post-list li{margin:0 0 8px}
.post-card{display:block;border:1px solid var(--border);border-radius:var(--radius);padding:20px 22px;margin-bottom:14px}
.post-card:hover{border-color:var(--primary);text-decoration:none}
.post-card h2{border:none;padding:0;margin:0 0 6px;font-size:1.15rem;color:var(--text)}
.post-card p{margin:0;color:var(--text-soft);font-size:0.9rem}
.post-card .date{color:var(--text-muted);font-size:0.8rem}
footer{background:#0f172a;color:#94a3b8;padding:28px 0;text-align:center;font-size:0.8rem}
footer a{color:#94a3b8}
@media(max-width:900px){.nav-links{display:none}.nav .container{gap:16px}.nav-logo{margin-right:auto}h1{font-size:1.75rem}table{table-layout:fixed;font-size:0.78rem}th,td{padding:8px 4px;overflow-wrap:anywhere}p code,li code{overflow-wrap:anywhere;word-break:break-word}}
article p a,article li a{color:#006a57;text-decoration:underline;text-underline-offset:.15em}
</style></head><body>
<nav class="nav"><div class="container"><a href="/" class="nav-logo">Fun<span>ASR</span></a><div class="nav-links"><a href="/en/#capabilities">Capabilities</a><a href="/en/#usage">How to Use</a><a href="/en/#benchmark">Benchmark</a><a href="/en/#demo">Demo</a><a href="https://modelscope.github.io/FunASR/" target="_blank">Docs</a><a href="/en/quickstart.html">Quickstart</a><a href="/en/models.html">Models</a><a href="/en/ecosystem.html">Ecosystem</a><a href="/en/blog/">Blog</a><a href="/en/vs-whisper.html">vs Whisper</a><a href="/en/donors.html">Donors</a></div><a href="https://www.funasr.com/blog/self-hosted-openai-whisper-api-alternative.html" style="font-size:0.83rem;font-weight:600;color:var(--text-soft)">中文</a><a href="/go/github" target="_blank" class="nav-btn">GitHub ★</a></div></nav>
<article><div class="container">
<h1>Add transcription to your own API</h1>
<p class="post-meta">FunASR Blog · 2026-06-18 · Updated 2026-09-09</p>
<p class="lead" data-editorial="opening">If your application needs to upload a recording and receive its text, start with that single round trip. A local transcription endpoint lets your team check the request and response before adding real traffic or a public gateway.</p>
<p data-editorial="example">The example uses an authorized <code>audio.wav</code>: a client uploads the file to a local SenseVoice service, then reads the JSON <code>text</code> field. It supplies a callable path, not a fabricated transcript or a speed comparison.</p>
<p data-editorial="boundary">This article covers the packaged <code>funasr-server</code> in FunASR 1.4.15. It offers part of the OpenAI transcription interface, not every hosted feature or response format; a working URL alone does not complete a migration.</p>
<aside class="limitation-callout" id="security-boundary" data-http-contract="security">
<p><strong>Choose the access boundary first.</strong> <span data-risk="authentication">The packaged service defaults to <code>0.0.0.0</code> and has no built-in authentication.</span> <span data-risk="upload-limit">This FunASR entry point implements no application-level total-upload-size limit.</span> The command below explicitly uses <code>--host 127.0.0.1</code> for a local check where client and backend share the same host network namespace.</p>
<p data-risk="backend-bypass">Before sharing the service, enforce TLS, authentication, upload limits, capacity and timeout policies at the gateway, and block direct backend access that bypasses it. CORS is not access control; a placeholder API key is not authentication. Read the <a href="/en/docs/security.html">service security guide</a>. This describes deployment risks, not evidence that a particular running service is exposed.</p>
</aside>
<h2>Start with one local JSON transcription</h2>
<section data-http-contract="prerequisites">
<p><strong>Prerequisite: a separate, already prepared and verified FunASR 1.4.15 environment.</strong> This is not a from-scratch installation tutorial. The Python and <code>funasr-server</code> commands must use the same activated environment, with <code>funasr==1.4.15</code>, PyTorch, audio dependencies, FastAPI, Uvicorn, python-multipart, model-weight access and an audio file ready. Use the <a href="/en/docs/installation.html">installation guide</a> for platform dependencies; other versions require a fresh behavior check.</p>
<pre><code>python -c 'from importlib.metadata import version; assert version("funasr") == "1.4.15", version("funasr")'
python -m pip check</code></pre>
<p>The version assertion and <code>pip check</code> inspect package metadata; they do not prove working CUDA, audio decoding or acoustic inference. The command below explicitly selects SenseVoice CPU for an integration check, not a performance recommendation. Do not start two servers on the same port. The separate <a href="/en/docs/http-server.html">repository example HTTP service guide</a> is an implementation comparison: it prepares and starts the example server, not the packaged 1.4.15 environment required here.</p>
</section>
<pre><code>funasr-server --host 127.0.0.1 --port 8000 --model sensevoice --device cpu</code></pre>
<p>From another terminal on the same host, upload an <code>audio.wav</code> file you are authorized to process. The command prints transcript content; keep private audio results out of public logs.</p>
<pre><code>curl --fail --show-error --silent --max-time 120 \
http://127.0.0.1:8000/v1/audio/transcriptions \
-F "[email protected]" \
-F "model=sensevoice" \
-F "response_format=json"</code></pre>
<p>The response is a JSON object containing <code>text</code>. Its content depends on the recording and model. The 120-second client timeout is an example, not a duration guarantee or proof that timed-out inference is cancelled.</p>
<h2>OpenAI Python SDK: specify the model and format</h2>
<p>The following basic call uses an environment with the separate <code>openai</code> client installed. A migration must still check model names, fields, response parsing, errors and gateway authentication, not just URL reachability.</p>
<pre><code>from openai import OpenAI
client = OpenAI(
base_url="http://127.0.0.1:8000/v1",
api_key="not-needed",
timeout=120.0,
max_retries=0,
)
with open("audio.wav", "rb") as audio:
result = client.audio.transcriptions.create(
model="sensevoice", file=audio, response_format="json"
)
print(result.text)</code></pre>
<p>The basic JSON call above does not produce subtitles. The packaged handler does not generate SRT/VTT; its <code>text</code> format returns a JSON string rather than plain text. Check the exact format contract in the appendix before changing the application parser.</p>
<h2>Before connecting Open WebUI or another application</h2>
<ul>
<li>Inspect the application's actual model alias, file type and <code>response_format</code>, plus how it handles success, empty text, errors and timeouts.</li>
<li>A container's <code>127.0.0.1</code> is the container itself. A host loopback listener does not become reachable merely by changing a URL to <code>host.docker.internal</code>. Cross-container setups need a restricted private network and matching gateway authentication.</li>
<li>Basic, Bearer and OIDC credentials are not interchangeable. Do not reuse the local placeholder as a production credential. Preloading one model is not a model-admission policy.</li>
<li>Verify the entire path with controlled audio before admitting real traffic. Follow the <a href="https://github.com/modelscope/FunASR/blob/main/examples/openai_api/CLIENTS.md">maintained client recipes</a>.</li>
</ul>
<h2>Compare complete deployments, not just API prices</h2>
<p>Self-hosting has compute, storage, bandwidth, maintenance and monitoring costs. Data control depends on the client, proxy, temporary files, logs and retention policy; neither no-disk handling nor leak-free transcripts are automatic. Review model-weight licenses separately from the toolkit's code license.</p>
<p>Choose by language, latency, hardware and speaker requirements using <a href="/en/docs/model-selection.html">model selection</a>, <a href="/en/docs/moss-transcribe-diarize.html">MOSS transcription and diarization</a> and the <a href="/en/deploy/">deployment matrix</a>. This article supplies no new accuracy or performance ranking. For acceptance criteria, see the <a href="/en/blog/meeting-transcript-acceptance.html">meeting-audio checklist</a>.</p>
<section data-editorial="appendix"><h2>Appendix: verify the response contract</h2>
<h2>Compatibility of the packaged handler</h2>
<p data-http-contract="version-boundary"><strong>Version boundary:</strong> The pinned 1.4.15 recipe returns an <code>application/json</code> encoded string for <code>response_format=text</code>; the table below describes that historical version. Current main returns a bare <code>text/plain</code> transcript after <a href="https://github.com/modelscope/FunASR/pull/3874">#3874</a> (<a href="https://github.com/modelscope/FunASR/blob/be264e9382b4fef735536f3d278ee14514098a1a/funasr/bin/_server_app.py">merged handler source</a>). This does not automatically upgrade an installed service: check its installed version and response bytes before choosing JSON decoding.</p>
<table id="api-contract" data-http-contract="formats"><thead><tr><th>Item</th><th>Current behavior and integration requirement</th></tr></thead><tbody>
<tr><td>Request</td><td>Multipart upload. The route declares <code>file</code>, <code>model</code>, <code>language</code>, <code>response_format</code> and the FunASR extension <code>spk</code>. Language and speaker capabilities depend on the selected model.</td></tr>
<tr data-response-format="json"><td><code>json</code></td><td>A JSON object with <code>text</code>, suitable for a first basic transcription check.</td></tr>
<tr data-response-format="verbose_json"><td><code>verbose_json</code></td><td>Returns structured JSON with fields including <code>segments</code> and <code>duration</code>. Actual timing and speaker information depend on the model and result.</td></tr>
<tr data-response-format="text"><td><code>text</code></td><td>The packaged handler returns a JSON string, not a standard plain-text response. Do not assume identical cloud-client parsing.</td></tr>
<tr data-response-format="srt"><td><code>srt</code></td><td>Does not produce SRT subtitles; this value reaches the JSON text-object branch. HTTP 200 does not prove that a subtitle file was returned.</td></tr>
<tr data-response-format="vtt"><td><code>vtt</code></td><td>Does not produce VTT subtitles; this value also reaches the JSON text-object branch.</td></tr>
<tr><td>Other fields and protocols</td><td><code>prompt</code>, <code>temperature</code> and <code>timestamp_granularities</code> are not declared capabilities of this route. It is not a streaming WebSocket, translation or complete cloud API. An extra field causing no error does not prove it was applied.</td></tr>
</tbody></table>
<p data-http-contract="schema-authority">For the packaged service, verify fields against its running <code>/openapi.json</code> over a private or restricted operational path and the <a href="https://github.com/modelscope/FunASR/blob/dff96b69f1679953ac53c6643c82c74b43c70db2/funasr/bin/_server_app.py">pinned packaged handler source</a>. The <a href="/en/docs/service-api.html">example-service API schema</a> documents a different implementation, not this packaged handler. Packaged, repository example, vLLM and llama.cpp servers do not share every default, field or response shape.</p>
</section>
<p data-editorial="next-step">Before another user connects, work through the <a href="/en/docs/security.html">service security guide</a> and verify that the gateway cannot be bypassed. Keep the local example private until those deployment checks pass.</p>
</div></article>
<footer><div class="container">FunASR · Open-source speech recognition by Tongyi Lab · <a href="/go/github">GitHub</a></div></footer>
</body></html>