fix(route/openai): adapt cookbook to new Astro-based site - #23024
Conversation
The OpenAI Cookbook site migrated from cookbook.openai.com (Next.js + Tailwind) to developers.openai.com/cookbook (Astro). All CSS selectors in the route no longer match, making it return an empty list. - Update URL to developers.openai.com/cookbook - Extract article data from astro-island component props JSON instead of parsing Tailwind CSS card selectors - Add decodeAstroValue() to recursively decode Astro serialization format ([0,value] scalar / [1,[...]] array) - Filter out archived entries, sort by date descending - Use parseDate() for proper Date objects - Add features (antiCrawler: true), parameters (limit), update radar - Add User-Agent header to bypass Vercel bot detection (403) - Detail page selector updated from specific Tailwind classes to generic article element
|
Successfully generated as following: http://localhost:1200/openai/cookbook - Success ✔️<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>OpenAI Cookbook</title>
<link>https://developers.openai.com/cookbook/</link>
<atom:link href="http://localhost:1200/openai/cookbook" rel="self" type="application/rss+xml"></atom:link>
<description>OpenAI Cookbook - Powered by RSSHub</description>
<generator>RSSHub</generator>
<webMaster>contact@rsshub.app (RSSHub)</webMaster>
<language>en</language>
<lastBuildDate>Thu, 13 Aug 2026 06:51:47 GMT</lastBuildDate>
<ttl>5</ttl>
<item>
<title>Migrate from Whisper to GPT-Transcribe and GPT-Live-Transcribe</title>
<description><div> <h2 id="overview" class="group flex items-center gap-2 mt-7 mb-2 scroll-mt-[110px]"><span class="min-w-0">Overview</span><button type="button" class="shrink-0 self-center inline-flex items-center justify-center rounded-md p-0.5 opacity-0 transition-colors transition-opacity duration-200 ease-out text-info hover:text-info focus-visible:opacity-100 group-focus-within:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300 group-hover:opacity-100 dark:focus-visible:outline-gray-600 motion-reduce:transition-none relative -top-0.5" data-anchor-id="overview" aria-label="Copy link to Overview" title="Copy link to Overview"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="h-4 w-4"><path d="M18.2929 5.7071C16.4743 3.88849 13.5257 3.88849 11.7071 5.7071L10.7071 6.7071C10.3166 7.09763 9.68341 7.09763 9.29289 6.7071C8.90236 6.31658 8.90236 5.68341 9.29289 5.29289L10.2929 4.29289C12.8926 1.69322 17.1074 1.69322 19.7071 4.29289C22.3068 6.89255 22.3068 11.1074 19.7071 13.7071L18.7071 14.7071C18.3166 15.0976 17.6834 15.0976 17.2929 14.7071C16.9024 14.3166 16.9024 13.6834 17.2929 13.2929L18.2929 12.2929C20.1115 10.4743 20.1115 7.52572 18.2929 5.7071ZM15.7071 8.29289C16.0976 8.68341 16.0976 9.31658 15.7071 9.7071L9.7071 15.7071C9.31658 16.0976 8.68341 16.0976 8.29289 15.7071C7.90236 15.3166 7.90236 14.6834 8.29289 14.2929L14.2929 8.29289C14.6834 7.90236 15.3166 7.90236 15.7071 8.29289ZM6.7071 9.29289C7.09763 9.68341 7.09763 10.3166 6.7071 10.7071L5.7071 11.7071C3.88849 13.5257 3.88849 16.4743 5.7071 18.2929C7.52572 20.1115 10.4743 20.1115 12.2929 18.2929L13.2929 17.2929C13.6834 16.9024 14.3166 16.9024 14.7071 17.2929C15.0976 17.6834 15.0976 18.3166 14.7071 18.7071L13.7071 19.7071C11.1074 22.3068 6.89255 22.3068 4.29289 19.7071C1.69322 17.1074 1.69322 12.8926 4.29289 10.2929L5.29289 9.29289C5.68341 8.90236 6.31658 8.90236 6.7071 9.29289Z" fill="currentColor"></path></svg></button></h2>
<p>OpenAI’s new transcription models give existing Whisper users two focused upgrade paths. GPT-Transcribe (<code>gpt-transcribe</code>) is designed for accurate transcription of completed audio via uploaded files. GPT-Live-Transcribe (<code>gpt-live-transcribe</code>) is designed for low-latency, continuously streaming transcription.</p>
<p>At a high level, the API endpoints are the same. File requests continue to use POST /v1/audio/transcriptions. Realtime integrations continue to configure a transcription session and handle transcription events. What’s different are the supported request fields, the output formats, and contextual/multilingual hints.</p>
<h3 id="what-stays-the-same" class="group flex items-center gap-1 mt-7 mb-2 scroll-mt-[110px]"><span class="min-w-0">What stays the same</span><button type="button" class="shrink-0 self-center inline-flex items-center justify-center rounded-md p-0.5 opacity-0 transition-colors transition-opacity duration-200 ease-out text-info hover:text-info focus-visible:opacity-100 group-focus-within:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300 group-hover:opacity-100 dark:focus-visible:outline-gray-600 motion-reduce:transition-none relative -top-0.5" data-anchor-id="what-stays-the-same" aria-label="Copy link to What stays the same" title="Copy link to What stays the same"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="h-3.5 w-3.5"><path d="M18.2929 5.7071C16.4743 3.88849 13.5257 3.88849 11.7071 5.7071L10.7071 6.7071C10.3166 7.09763 9.68341 7.09763 9.29289 6.7071C8.90236 6.31658 8.90236 5.68341 9.29289 5.29289L10.2929 4.29289C12.8926 1.69322 17.1074 1.69322 19.7071 4.29289C22.3068 6.89255 22.3068 11.1074 19.7071 13.7071L18.7071 14.7071C18.3166 15.0976 17.6834 15.0976 17.2929 14.7071C16.9024 14.3166 16.9024 13.6834 17.2929 13.2929L18.2929 12.2929C20.1115 10.4743 20.1115 7.52572 18.2929 5.7071ZM15.7071 8.29289C16.0976 8.68341 16.0976 9.31658 15.7071 9.7071L9.7071 15.7071C9.31658 16.0976 8.68341 16.0976 8.29289 15.7071C7.90236 15.3166 7.90236 14.6834 8.29289 14.2929L14.2929 8.29289C14.6834 7.90236 15.3166 7.90236 15.7071 8.29289ZM6.7071 9.29289C7.09763 9.68341 7.09763 10.3166 6.7071 10.7071L5.7071 11.7071C3.88849 13.5257 3.88849 16.4743 5.7071 18.2929C7.52572 20.1115 10.4743 20.1115 12.2929 18.2929L13.2929 17.2929C13.6834 16.9024 14.3166 16.9024 14.7071 17.2929C15.0976 17.6834 15.0976 18.3166 14.7071 18.7071L13.7071 19.7071C11.1074 22.3068 6.89255 22.3068 4.29289 19.7071C1.69322 17.1074 1.69322 12.8926 4.29289 10.2929L5.29289 9.29289C5.68341 8.90236 6.31658 8.90236 6.7071 9.29289Z" fill="currentColor"></path></svg></button></h3>
<ul>
<li>File transcription uses the existing Audio API transcription endpoint.</li>
<li>Realtime transcription uses the existing Realtime transcription session, WebSocket or WebRTC transport, and transcription events.</li>
<li>Applications still provide audio, receive transcription text, and handle API or connection errors.</li>
</ul>
<h3 id="what-changes" class="group flex items-center gap-1 mt-7 mb-2 scroll-mt-[110px]"><span class="min-w-0">What changes</span><button type="button" class="shrink-0 self-center inline-flex items-center justify-center rounded-md p-0.5 opacity-0 transition-colors transition-opacity duration-200 ease-out text-info hover:text-info focus-visible:opacity-100 group-focus-within:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300 group-hover:opacity-100 dark:focus-visible:outline-gray-600 motion-reduce:transition-none relative -top-0.5" data-anchor-id="what-changes" aria-label="Copy link to What changes" title="Copy link to What changes"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="h-3.5 w-3.5"><path d="M18.2929 5.7071C16.4743 3.88849 13.5257 3.88849 11.7071 5.7071L10.7071 6.7071C10.3166 7.09763 9.68341 7.09763 9.29289 6.7071C8.90236 6.31658 8.90236 5.68341 9.29289 5.29289L10.2929 4.29289C12.8926 1.69322 17.1074 1.69322 19.7071 4.29289C22.3068 6.89255 22.3068 11.1074 19.7071 13.7071L18.7071 14.7071C18.3166 15.0976 17.6834 15.0976 17.2929 14.7071C16.9024 14.3166 16.9024 13.6834 17.2929 13.2929L18.2929 12.2929C20.1115 10.4743 20.1115 7.52572 18.2929 5.7071ZM15.7071 8.29289C16.0976 8.68341 16.0976 9.31658 15.7071 9.7071L9.7071 15.7071C9.31658 16.0976 8.68341 16.0976 8.29289 15.7071C7.90236 15.3166 7.90236 14.6834 8.29289 14.2929L14.2929 8.29289C14.6834 7.90236 15.3166 7.90236 15.7071 8.29289ZM6.7071 9.29289C7.09763 9.68341 7.09763 10.3166 6.7071 10.7071L5.7071 11.7071C3.88849 13.5257 3.88849 16.4743 5.7071 18.2929C7.52572 20.1115 10.4743 20.1115 12.2929 18.2929L13.2929 17.2929C13.6834 16.9024 14.3166 16.9024 14.7071 17.2929C15.0976 17.6834 15.0976 18.3166 14.7071 18.7071L13.7071 19.7071C11.1074 22.3068 6.89255 22.3068 4.29289 19.7071C1.69322 17.1074 1.69322 12.8926 4.29289 10.2929L5.29289 9.29289C5.68341 8.90236 6.31658 8.90236 6.7071 9.29289Z" fill="currentColor"></path></svg></button></h3>
<ul>
<li>Use <code>gpt-transcribe</code> for completed files, streamed file transcripts, or committed Realtime turns.</li>
<li>Use <code>gpt-live-transcribe</code> for continuously streaming, low-latency live transcription.</li>
<li>Replace the legacy <code>language</code> hint with the new-model <code>languages</code> array.</li>
<li>Use <code>prompt</code> for free-form context and <code>keywords</code> for literal terms expected in the audio.</li>
<li>Handle detected-language output for GPT-Transcribe, including an empty languages array.</li>
</ul>
<h2 id="1-choose-your-migration-path" class="group flex items-center gap-2 mt-7 mb-2 scroll-mt-[110px]"><span class="min-w-0">1. Choose your migration path</span><button type="button" class="shrink-0 self-center inline-flex items-center justify-center rounded-md p-0.5 opacity-0 transition-colors transition-opacity duration-200 ease-out text-info hover:text-info focus-visible:opacity-100 group-focus-within:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300 group-hover:opacity-100 dark:focus-visible:outline-gray-600 motion-reduce:transition-none relative -top-0.5" data-anchor-id="1-choose-your-migration-path" aria-label="Copy link to 1. Choose your migration path" title="Copy link to 1. Choose your migration path"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="h-4 w-4"><path d="M18.2929 5.7071C16.4743 3.88849 13.5257 3.88849 11.7071 5.7071L10.7071 6.7071C10.3166 7.09763 9.68341 7.09763 9.29289 6.7071C8.90236 6.31658 8.90236 5.68341 9.29289 5.29289L10.2929 4.29289C12.8926 1.69322 17.1074 1.69322 19.7071 4.29289C22.3068 6.89255 22.3068 11.1074 19.7071 13.7071L18.7071 14.7071C18.3166 15.0976 17.6834 15.0976 17.2929 14.7071C16.9024 14.3166 16.9024 13.6834 17.2929 13.2929L18.2929 12.2929C20.1115 10.4743 20.1115 7.52572 18.2929 5.7071ZM15.7071 8.29289C16.0976 8.68341 16.0976 9.31658 15.7071 9.7071L9.7071 15.7071C9.31658 16.0976 8.68341 16.0976 8.29289 15.7071C7.90236 15.3166 7.90236 14.6834 8.29289 14.2929L14.2929 8.29289C14.6834 7.90236 15.3166 7.90236 15.7071 8.29289ZM6.7071 9.29289C7.09763 9.68341 7.09763 10.3166 6.7071 10.7071L5.7071 11.7071C3.88849 13.5257 3.88849 16.4743 5.7071 18.2929C7.52572 20.1115 10.4743 20.1115 12.2929 18.2929L13.2929 17.2929C13.6834 16.9024 14.3166 16.9024 14.7071 17.2929C15.0976 17.6834 15.0976 18.3166 14.7071 18.7071L13.7071 19.7071C11.1074 22.3068 6.89255 22.3068 4.29289 19.7071C1.69322 17.1074 1.69322 12.8926 4.29289 10.2929L5.29289 9.29289C5.68341 8.90236 6.31658 8.90236 6.7071 9.29289Z" fill="currentColor"></path></svg></button></h2>
<ul>
<li>Recorded meetings, calls, or uploaded audio: migrate <code>whisper-1</code> to <code>gpt-transcribe</code> on POST /v1/audio/transcriptions.</li>
<li>Live captions or continuously arriving microphone audio: migrate <code>gpt-realtime-whisper</code> to <code>gpt-live-transcribe</code> in a Realtime transcription session.</li>
<li>Higher-accuracy transcription after a manually committed audio turn: use <code>gpt-transcribe</code> in a Realtime transcription session over WebSocket.
Treat live audio and streaming output as separate decisions. A completed file can produce streamed transcript events, and a Realtime session can wait for an audio turn to be committed before producing deltas.</li>
</ul>
<h2 id="2-migrate-recorded-audio" class="group flex items-center gap-2 mt-7 mb-2 scroll-mt-[110px]"><span class="min-w-0">2. Migrate recorded audio</span><button type="button" class="shrink-0 self-center inline-flex items-center justify-center rounded-md p-0.5 opacity-0 transition-colors transition-opacity duration-200 ease-out text-info hover:text-info focus-visible:opacity-100 group-focus-within:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300 group-hover:opacity-100 dark:focus-visible:outline-gray-600 motion-reduce:transition-none relative -top-0.5" data-anchor-id="2-migrate-recorded-audio" aria-label="Copy link to 2. Migrate recorded audio" title="Copy link to 2. Migrate recorded audio"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="h-4 w-4"><path d="M18.2929 5.7071C16.4743 3.88849 13.5257 3.88849 11.7071 5.7071L10.7071 6.7071C10.3166 7.09763 9.68341 7.09763 9.29289 6.7071C8.90236 6.31658 8.90236 5.68341 9.29289 5.29289L10.2929 4.29289C12.8926 1.69322 17.1074 1.69322 19.7071 4.29289C22.3068 6.89255 22.3068 11.1074 19.7071 13.7071L18.7071 14.7071C18.3166 15.0976 17.6834 15.0976 17.2929 14.7071C16.9024 14.3166 16.9024 13.6834 17.2929 13.2929L18.2929 12.2929C20.1115 10.4743 20.1115 7.52572 18.2929 5.7071ZM15.7071 8.29289C16.0976 8.68341 16.0976 9.31658 15.7071 9.7071L9.7071 15.7071C9.31658 16.0976 8.68341 16.0976 8.29289 15.7071C7.90236 15.3166 7.90236 14.6834 8.29289 14.2929L14.2929 8.29289C14.6834 7.90236 15.3166 7.90236 15.7071 8.29289ZM6.7071 9.29289C7.09763 9.68341 7.09763 10.3166 6.7071 10.7071L5.7071 11.7071C3.88849 13.5257 3.88849 16.4743 5.7071 18.2929C7.52572 20.1115 10.4743 20.1115 12.2929 18.2929L13.2929 17.2929C13.6834 16.9024 14.3166 16.9024 14.7071 17.2929C15.0976 17.6834 15.0976 18.3166 14.7071 18.7071L13.7071 19.7071C11.1074 22.3068 6.89255 22.3068 4.29289 19.7071C1.69322 17.1074 1.69322 12.8926 4.29289 10.2929L5.29289 9.29289C5.68341 8.90236 6.31658 8.90236 6.7071 9.29289Z" fill="currentColor"></path></svg></button></h2>
<p>The smallest file migration preserves the endpoint, SDK call, and file upload. Replace the model identifier, then consume the JSON transcription response.</p>
<h3 id="prerequisites" class="group flex items-center gap-1 mt-7 mb-2 scroll-mt-[110px]"><span class="min-w-0">Prerequisites</span><button type="button" class="shrink-0 self-center inline-flex items-center justify-center rounded-md p-0.5 opacity-0 transition-colors transition-opacity duration-200 ease-out text-info hover:text-info focus-visible:opacity-100 group-focus-within:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300 group-hover:opacity-100 dark:focus-visible:outline-gray-600 motion-reduce:transition-none relative -top-0.5" data-anchor-id="prerequisites" aria-label="Copy link to Prerequisites" title="Copy link to Prerequisites"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="h-3.5 w-3.5"><path d="M18.2929 5.7071C16.4743 3.88849 13.5257 3.88849 11.7071 5.7071L10.7071 6.7071C10.3166 7.09763 9.68341 7.09763 9.29289 6.7071C8.90236 6.31658 8.90236 5.68341 9.29289 5.29289L10.2929 4.29289C12.8926 1.69322 17.1074 1.69322 19.7071 4.29289C22.3068 6.89255 22.3068 11.1074 19.7071 13.7071L18.7071 14.7071C18.3166 15.0976 17.6834 15.0976 17.2929 14.7071C16.9024 14.3166 16.9024 13.6834 17.2929 13.2929L18.2929 12.2929C20.1115 10.4743 20.1115 7.52572 18.2929 5.7071ZM15.7071 8.29289C16.0976 8.68341 16.0976 9.31658 15.7071 9.7071L9.7071 15.7071C9.31658 16.0976 8.68341 16.0976 8.29289 15.7071C7.90236 15.3166 7.90236 14.6834 8.29289 14.2929L14.2929 8.29289C14.6834 7.90236 15.3166 7.90236 15.7071 8.29289ZM6.7071 9.29289C7.09763 9.68341 7.09763 10.3166 6.7071 10.7071L5.7071 11.7071C3.88849 13.5257 3.88849 16.4743 5.7071 18.2929C7.52572 20.1115 10.4743 20.1115 12.2929 18.2929L13.2929 17.2929C13.6834 16.9024 14.3166 16.9024 14.7071 17.2929C15.0976 17.6834 15.0976 18.3166 14.7071 18.7071L13.7071 19.7071C11.1074 22.3068 6.89255 22.3068 4.29289 19.7071C1.69322 17.1074 1.69322 12.8926 4.29289 10.2929L5.29289 9.29289C5.68341 8.90236 6.31658 8.90236 6.7071 9.29289Z" fill="currentColor"></path></svg></button></h3>
<ul>
<li>Python 3.11 or later.</li>
<li>The OpenAI Python SDK: <code>python -m pip install --upgrade openai</code>.</li>
<li>An <code>OPENAI_API_KEY</code> environment variable.</li>
<li>A completed recording named <code>meeting.wav</code>, or update <code>audio_path</code> to point to your own file.</li>
<li>Access to the transcription models used in the example.</li>
</ul>
<p>File examples make live API requests. Realtime examples construct the session payloads. Use WebSocket or WebRTC for <code>gpt-live-transcribe</code>, and use WebSocket for committed-turn <code>gpt-transcribe</code>.</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="background-color:#fff;--shiki-dark-bg:#24292e;color:#24292e;--shiki-dark:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="python"><code><span class="line"><span style="color:#D73A49;--shiki-dark:#F97583">import</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> json</span></span>
<span class="line"><span style="color:#D73A49;--shiki-dark:#F97583">from</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> pathlib </span><span style="color:#D73A49;--shiki-dark:#F97583">import</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> Path</span></span>
<span class="line"></span>
<span class="line"><span style="color:#D73A49;--shiki-dark:#F97583">from</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> openai </span><span style="color:#D73A49;--shiki-dark:#F97583">import</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> OpenAI</span></span>
<span class="line"></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8">client </span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> OpenAI()</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8">audio_path </span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> Path(</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"meeting.wav"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">)</span></span></code></pre>
<p><strong>Before — Whisper file transcription</strong></p>
<pre class="astro-code astro-code-themes github-light github-dark" style="background-color:#fff;--shiki-dark-bg:#24292e;color:#24292e;--shiki-dark:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="python"><code><span class="line"><span style="color:#D73A49;--shiki-dark:#F97583">with</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> audio_path.open(</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"rb"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">) </span><span style="color:#D73A49;--shiki-dark:#F97583">as</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> audio:</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8"> before </span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> client.audio.transcriptions.create(</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> model</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"whisper-1"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> file</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8">audio,</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8"> )</span></span>
<span class="line"></span>
<span class="line"><span style="color:#005CC5;--shiki-dark:#79B8FF">print</span><span style="color:#24292E;--shiki-dark:#E1E4E8">(before.text)</span></span></code></pre>
<p><strong>After — GPT-Transcribe</strong></p>
<pre class="astro-code astro-code-themes github-light github-dark" style="background-color:#fff;--shiki-dark-bg:#24292e;color:#24292e;--shiki-dark:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="python"><code><span class="line"><span style="color:#D73A49;--shiki-dark:#F97583">with</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> audio_path.open(</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"rb"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">) </span><span style="color:#D73A49;--shiki-dark:#F97583">as</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> audio:</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8"> after </span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> client.audio.transcriptions.create(</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> model</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"gpt-transcribe"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> file</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8">audio,</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> response_format</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"json"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8"> )</span></span>
<span class="line"></span>
<span class="line"><span style="color:#005CC5;--shiki-dark:#79B8FF">print</span><span style="color:#24292E;--shiki-dark:#E1E4E8">(after.text)</span></span></code></pre>
<p><strong>Do’s and don’ts</strong></p>
<ul>
<li>Note that the new model returns JSON. If the existing application requests <code>text</code>, <code>verbose_json</code>, <code>srt</code>, or <code>vtt</code>, do not assume the same response_format remains valid. Keep Whisper for those formats or explicitly build and test the downstream conversion your application requires.</li>
</ul>
<h2 id="3-update-language-hints-and-domain-context" class="group flex items-center gap-2 mt-7 mb-2 scroll-mt-[110px]"><span class="min-w-0">3. Update language hints and domain context</span><button type="button" class="shrink-0 self-center inline-flex items-center justify-center rounded-md p-0.5 opacity-0 transition-colors transition-opacity duration-200 ease-out text-info hover:text-info focus-visible:opacity-100 group-focus-within:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300 group-hover:opacity-100 dark:focus-visible:outline-gray-600 motion-reduce:transition-none relative -top-0.5" data-anchor-id="3-update-language-hints-and-domain-context" aria-label="Copy link to 3. Update language hints and domain context" title="Copy link to 3. Update language hints and domain context"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="h-4 w-4"><path d="M18.2929 5.7071C16.4743 3.88849 13.5257 3.88849 11.7071 5.7071L10.7071 6.7071C10.3166 7.09763 9.68341 7.09763 9.29289 6.7071C8.90236 6.31658 8.90236 5.68341 9.29289 5.29289L10.2929 4.29289C12.8926 1.69322 17.1074 1.69322 19.7071 4.29289C22.3068 6.89255 22.3068 11.1074 19.7071 13.7071L18.7071 14.7071C18.3166 15.0976 17.6834 15.0976 17.2929 14.7071C16.9024 14.3166 16.9024 13.6834 17.2929 13.2929L18.2929 12.2929C20.1115 10.4743 20.1115 7.52572 18.2929 5.7071ZM15.7071 8.29289C16.0976 8.68341 16.0976 9.31658 15.7071 9.7071L9.7071 15.7071C9.31658 16.0976 8.68341 16.0976 8.29289 15.7071C7.90236 15.3166 7.90236 14.6834 8.29289 14.2929L14.2929 8.29289C14.6834 7.90236 15.3166 7.90236 15.7071 8.29289ZM6.7071 9.29289C7.09763 9.68341 7.09763 10.3166 6.7071 10.7071L5.7071 11.7071C3.88849 13.5257 3.88849 16.4743 5.7071 18.2929C7.52572 20.1115 10.4743 20.1115 12.2929 18.2929L13.2929 17.2929C13.6834 16.9024 14.3166 16.9024 14.7071 17.2929C15.0976 17.6834 15.0976 18.3166 14.7071 18.7071L13.7071 19.7071C11.1074 22.3068 6.89255 22.3068 4.29289 19.7071C1.69322 17.1074 1.69322 12.8926 4.29289 10.2929L5.29289 9.29289C5.68341 8.90236 6.31658 8.90236 6.7071 9.29289Z" fill="currentColor"></path></svg></button></h2>
<p>Legacy Whisper integrations commonly send a single <code>language</code> value and place domain vocabulary in a free-form prompt. The new models accept multiple expected input languages and separate structured keyword hints from the general prompt.</p>
<p><strong>Before — single-language Whisper request</strong></p>
<pre class="astro-code astro-code-themes github-light github-dark" style="background-color:#fff;--shiki-dark-bg:#24292e;color:#24292e;--shiki-dark:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="python"><code><span class="line"><span style="color:#D73A49;--shiki-dark:#F97583">from</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> openai </span><span style="color:#D73A49;--shiki-dark:#F97583">import</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> OpenAI</span></span>
<span class="line"></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8">client </span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> OpenAI()</span></span>
<span class="line"></span>
<span class="line"><span style="color:#D73A49;--shiki-dark:#F97583">with</span><span style="color:#005CC5;--shiki-dark:#79B8FF"> open</span><span style="color:#24292E;--shiki-dark:#E1E4E8">(</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"meeting.wav"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">, </span><span style="color:#032F62;--shiki-dark:#9ECBFF">"rb"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">) </span><span style="color:#D73A49;--shiki-dark:#F97583">as</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> audio:</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8"> result </span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> client.audio.transcriptions.create(</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> model</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"whisper-1"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> file</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8">audio,</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> language</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"en"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> prompt</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"A support call about AC-42."</span><span style="color:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8"> )</span></span>
<span class="line"></span>
<span class="line"><span style="color:#005CC5;--shiki-dark:#79B8FF">print</span><span style="color:#24292E;--shiki-dark:#E1E4E8">(result.text)</span></span></code></pre>
<p><strong>After — multilingual GPT-Transcribe request</strong></p>
<pre class="astro-code astro-code-themes github-light github-dark" style="background-color:#fff;--shiki-dark-bg:#24292e;color:#24292e;--shiki-dark:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="python"><code><span class="line"><span style="color:#D73A49;--shiki-dark:#F97583">from</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> openai </span><span style="color:#D73A49;--shiki-dark:#F97583">import</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> OpenAI</span></span>
<span class="line"></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8">client </span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> OpenAI()</span></span>
<span class="line"></span>
<span class="line"><span style="color:#D73A49;--shiki-dark:#F97583">with</span><span style="color:#005CC5;--shiki-dark:#79B8FF"> open</span><span style="color:#24292E;--shiki-dark:#E1E4E8">(</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"meeting.wav"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">, </span><span style="color:#032F62;--shiki-dark:#9ECBFF">"rb"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">) </span><span style="color:#D73A49;--shiki-dark:#F97583">as</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> audio:</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8"> result </span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> client.audio.transcriptions.create(</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> model</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"gpt-transcribe"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> file</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8">audio,</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> prompt</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"A customer support call about billing."</span><span style="color:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> extra_body</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#9ECBFF"> "keywords"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">: [</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"AC-42"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">, </span><span style="color:#032F62;--shiki-dark:#9ECBFF">"Premium Plus"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">],</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#9ECBFF"> "languages"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">: [</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"en"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">, </span><span style="color:#032F62;--shiki-dark:#9ECBFF">"fr"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">],</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8"> },</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8"> )</span></span>
<span class="line"></span>
<span class="line"><span style="color:#005CC5;--shiki-dark:#79B8FF">print</span><span style="color:#24292E;--shiki-dark:#E1E4E8">(result.text)</span></span></code></pre>
<p><strong>Do’s and don’ts</strong></p>
<ul>
<li>Use <code>prompt</code> to describe the recording’s topic or setting.</li>
<li>Use <code>keywords</code> for literal product names, medication names, account identifiers, or other domain-specific terms that may actually be spoken.</li>
<li>Use <code>languages</code> to indicate expected spoken languages.</li>
<li>Do not send both <code>language</code> and <code>languages</code>.</li>
<li>Validate keyword input before making the request: each keyword must be a single-line literal and must not include <code>&lt;</code>, <code>&gt;</code>, a carriage return, or a line feed. Invalid keyword input rejects the whole request or session update.</li>
</ul>
<h2 id="4-stream-the-transcription-of-a-completed-file" class="group flex items-center gap-2 mt-7 mb-2 scroll-mt-[110px]"><span class="min-w-0">4. Stream the transcription of a completed file</span><button type="button" class="shrink-0 self-center inline-flex items-center justify-center rounded-md p-0.5 opacity-0 transition-colors transition-opacity duration-200 ease-out text-info hover:text-info focus-visible:opacity-100 group-focus-within:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300 group-hover:opacity-100 dark:focus-visible:outline-gray-600 motion-reduce:transition-none relative -top-0.5" data-anchor-id="4-stream-the-transcription-of-a-completed-file" aria-label="Copy link to 4. Stream the transcription of a completed file" title="Copy link to 4. Stream the transcription of a completed file"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="h-4 w-4"><path d="M18.2929 5.7071C16.4743 3.88849 13.5257 3.88849 11.7071 5.7071L10.7071 6.7071C10.3166 7.09763 9.68341 7.09763 9.29289 6.7071C8.90236 6.31658 8.90236 5.68341 9.29289 5.29289L10.2929 4.29289C12.8926 1.69322 17.1074 1.69322 19.7071 4.29289C22.3068 6.89255 22.3068 11.1074 19.7071 13.7071L18.7071 14.7071C18.3166 15.0976 17.6834 15.0976 17.2929 14.7071C16.9024 14.3166 16.9024 13.6834 17.2929 13.2929L18.2929 12.2929C20.1115 10.4743 20.1115 7.52572 18.2929 5.7071ZM15.7071 8.29289C16.0976 8.68341 16.0976 9.31658 15.7071 9.7071L9.7071 15.7071C9.31658 16.0976 8.68341 16.0976 8.29289 15.7071C7.90236 15.3166 7.90236 14.6834 8.29289 14.2929L14.2929 8.29289C14.6834 7.90236 15.3166 7.90236 15.7071 8.29289ZM6.7071 9.29289C7.09763 9.68341 7.09763 10.3166 6.7071 10.7071L5.7071 11.7071C3.88849 13.5257 3.88849 16.4743 5.7071 18.2929C7.52572 20.1115 10.4743 20.1115 12.2929 18.2929L13.2929 17.2929C13.6834 16.9024 14.3166 16.9024 14.7071 17.2929C15.0976 17.6834 15.0976 18.3166 14.7071 18.7071L13.7071 19.7071C11.1074 22.3068 6.89255 22.3068 4.29289 19.7071C1.69322 17.1074 1.69322 12.8926 4.29289 10.2929L5.29289 9.29289C5.68341 8.90236 6.31658 8.90236 6.7071 9.29289Z" fill="currentColor"></path></svg></button></h2>
<p>Streaming applies to the transcription output, not the audio input. The application first supplies a completed recording; the API then streams text as it transcribes that recording.</p>
<p><strong>Before — blocking Whisper file request</strong></p>
<pre class="astro-code astro-code-themes github-light github-dark" style="background-color:#fff;--shiki-dark-bg:#24292e;color:#24292e;--shiki-dark:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="python"><code><span class="line"><span style="color:#D73A49;--shiki-dark:#F97583">with</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> audio_path.open(</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"rb"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">) </span><span style="color:#D73A49;--shiki-dark:#F97583">as</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> audio:</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8"> before </span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> client.audio.transcriptions.create(</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> model</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"whisper-1"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> file</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8">audio,</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8"> )</span></span>
<span class="line"></span>
<span class="line"><span style="color:#005CC5;--shiki-dark:#79B8FF">print</span><span style="color:#24292E;--shiki-dark:#E1E4E8">(before.text)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#6A737D;--shiki-dark:#6A737D"># whisper-1 does not provide transcript.text.delta events.</span></span></code></pre>
<p><strong>After — streamed GPT-Transcribe file request</strong></p>
<pre class="astro-code astro-code-themes github-light github-dark" style="background-color:#fff;--shiki-dark-bg:#24292e;color:#24292e;--shiki-dark:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="python"><code><span class="line"><span style="color:#D73A49;--shiki-dark:#F97583">with</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> audio_path.open(</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"rb"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">) </span><span style="color:#D73A49;--shiki-dark:#F97583">as</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> audio:</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8"> stream </span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> client.audio.transcriptions.create(</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> model</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"gpt-transcribe"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> file</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8">audio,</span></span>
<span class="line"><span style="color:#E36209;--shiki-dark:#FFAB70"> stream</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#005CC5;--shiki-dark:#79B8FF">True</span><span style="color:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8"> )</span></span>
<span class="line"></span>
<span class="line"><span style="color:#D73A49;--shiki-dark:#F97583"> for</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> event </span><span style="color:#D73A49;--shiki-dark:#F97583">in</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> stream:</span></span>
<span class="line"><span style="color:#D73A49;--shiki-dark:#F97583"> if</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> event.type </span><span style="color:#D73A49;--shiki-dark:#F97583">==</span><span style="color:#032F62;--shiki-dark:#9ECBFF"> "transcript.text.delta"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="color:#005CC5;--shiki-dark:#79B8FF"> print</span><span style="color:#24292E;--shiki-dark:#E1E4E8">(event.delta, </span><span style="color:#E36209;--shiki-dark:#FFAB70">end</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#032F62;--shiki-dark:#9ECBFF">""</span><span style="color:#24292E;--shiki-dark:#E1E4E8">, </span><span style="color:#E36209;--shiki-dark:#FFAB70">flush</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#005CC5;--shiki-dark:#79B8FF">True</span><span style="color:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span class="line"><span style="color:#D73A49;--shiki-dark:#F97583"> elif</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> event.type </span><span style="color:#D73A49;--shiki-dark:#F97583">==</span><span style="color:#032F62;--shiki-dark:#9ECBFF"> "transcript.text.done"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="color:#005CC5;--shiki-dark:#79B8FF"> print</span><span style="color:#24292E;--shiki-dark:#E1E4E8">(</span><span style="color:#032F62;--shiki-dark:#9ECBFF">"</span><span style="color:#005CC5;--shiki-dark:#79B8FF">\n</span><span style="color:#032F62;--shiki-dark:#9ECBFF">Final:"</span><span style="color:#24292E;--shiki-dark:#E1E4E8">, event.text)</span></span></code></pre>
<p><strong>Do’s and don’ts</strong></p>
<ul>
<li>Use transcription events to distinguish in-progress from completed transcripts. Update your transcript or progress UI with <code>transcript.text.delta</code> events, then use <code>transcript.text.done</code> to mark the transcript as final.</li>
<li>Do not label file streaming as live audio capture: the file must already exist.</li>
</ul>
<h2 id="5-migrate-continuous-live-transcription" class="group flex items-center gap-2 mt-7 mb-2 scroll-mt-[110px]"><span class="min-w-0">5. Migrate continuous live transcription</span><button type="button" class="shrink-0 self-center inline-flex items-center justify-center rounded-md p-0.5 opacity-0 transition-colors transition-opacity duration-200 ease-out text-info hover:text-info focus-visible:opacity-100 group-focus-within:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300 group-hover:opacity-100 dark:focus-visible:outline-gray-600 motion-reduce:transition-none relative -top-0.5" data-anchor-id="5-migrate-continuous-live-transcription" aria-label="Copy link to 5. Migrate continuous live transcription" title="Copy link to 5. Migrate continuous live transcription"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="h-4 w-4"><path d="M18.2929 5.7071C16.4743 3.88849 13.5257 3.88849 11.7071 5.7071L10.7071 6.7071C10.3166 7.09763 9.68341 7.09763 9.29289 6.7071C8.90236 6.31658 8.90236 5.68341 9.29289 5.29289L10.2929 4.29289C12.8926 1.69322 17.1074 1.69322 19.7071 4.29289C22.3068 6.89255 22.3068 11.1074 19.7071 13.7071L18.7071 14.7071C18.3166 15.0976 17.6834 15.0976 17.2929 14.7071C16.9024 14.3166 16.9024 13.6834 17.2929 13.2929L18.2929 12.2929C20.1115 10.4743 20.1115 7.52572 18.2929 5.7071ZM15.7071 8.29289C16.0976 8.68341 16.0976 9.31658 15.7071 9.7071L9.7071 15.7071C9.31658 16.0976 8.68341 16.0976 8.29289 15.7071C7.90236 15.3166 7.90236 14.6834 8.29289 14.2929L14.2929 8.29289C14.6834 7.90236 15.3166 7.90236 15.7071 8.29289ZM6.7071 9.29289C7.09763 9.68341 7.09763 10.3166 6.7071 10.7071L5.7071 11.7071C3.88849 13.5257 3.88849 16.4743 5.7071 18.2929C7.52572 20.1115 10.4743 20.1115 12.2929 18.2929L13.2929 17.2929C13.6834 16.9024 14.3166 16.9024 14.7071 17.2929C15.0976 17.6834 15.0976 18.3166 14.7071 18.7071L13.7071 19.7071C11.1074 22.3068 6.89255 22.3068 4.29289 19.7071C1.69322 17.1074 1.69322 12.8926 4.29289 10.2929L5.29289 9.29289C5.68341 8.90236 6.31658 8.90236 6.7071 9.29289Z" fill="currentColor"></path></svg></button></h2>
<p>For a live captioning workflow, preserve the Realtime connection and transcription-session architecture. Change the transcription model and update the model-specific configuration.</p>
<p><strong>Before — GPT-Realtime-Whisper</strong></p>
<pre class="astro-code astro-code-themes github-light github-dark" style="background-color:#fff;--shiki-dark-bg:#24292e;color:#24292e;--shiki-dark:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="python"><code><span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8">legacy_realtime_session </span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> json.loads(</span></span>
<span class="line"><span style="color:#D73A49;--shiki-dark:#F97583"> r</span><span style="color:#032F62;--shiki-dark:#9ECBFF">'''</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF">{</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "type": "session</span><span style="color:#005CC5;--shiki-dark:#79B8FF">.</span><span style="color:#032F62;--shiki-dark:#DBEDFF">update",</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "session": {</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "type": "transcription",</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "audio": {</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "input": {</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "transcription": {</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "model": "gpt-realtime-whisper",</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "language": "en"</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> },</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "turn_detection": null</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> }</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> }</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> }</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF">}</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#9ECBFF">'''</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#005CC5;--shiki-dark:#79B8FF">print</span><span style="color:#24292E;--shiki-dark:#E1E4E8">(json.dumps(legacy_realtime_session, </span><span style="color:#E36209;--shiki-dark:#FFAB70">indent</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#005CC5;--shiki-dark:#79B8FF">2</span><span style="color:#24292E;--shiki-dark:#E1E4E8">))</span></span></code></pre>
<p><strong>After — GPT-Live-Transcribe</strong></p>
<pre class="astro-code astro-code-themes github-light github-dark" style="background-color:#fff;--shiki-dark-bg:#24292e;color:#24292e;--shiki-dark:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="python"><code><span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8">live_transcription_session </span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> json.loads(</span></span>
<span class="line"><span style="color:#D73A49;--shiki-dark:#F97583"> r</span><span style="color:#032F62;--shiki-dark:#9ECBFF">'''</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF">{</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "type": "session</span><span style="color:#005CC5;--shiki-dark:#79B8FF">.</span><span style="color:#032F62;--shiki-dark:#DBEDFF">update",</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "session": {</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "type": "transcription",</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "audio": {</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "input": {</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "transcription": {</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "model": "gpt-live-transcribe",</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "prompt": "A support call about a plan</span><span style="color:#005CC5;--shiki-dark:#79B8FF">.</span><span style="color:#032F62;--shiki-dark:#DBEDFF">",</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "keywords": </span><span style="color:#005CC5;--shiki-dark:#79B8FF">["AC-42", "Premium Plus"]</span><span style="color:#032F62;--shiki-dark:#DBEDFF">,</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "languages": </span><span style="color:#005CC5;--shiki-dark:#79B8FF">["en", "fr"]</span><span style="color:#032F62;--shiki-dark:#DBEDFF">,</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "delay": "low"</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> },</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> "turn_detection": null</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> }</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> }</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF"> }</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#DBEDFF">}</span></span>
<span class="line"><span style="color:#032F62;--shiki-dark:#9ECBFF">'''</span></span>
<span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#005CC5;--shiki-dark:#79B8FF">print</span><span style="color:#24292E;--shiki-dark:#E1E4E8">(json.dumps(live_transcription_session, </span><span style="color:#E36209;--shiki-dark:#FFAB70">indent</span><span style="color:#D73A49;--shiki-dark:#F97583">=</span><span style="color:#005CC5;--shiki-dark:#79B8FF">2</span><span style="color:#24292E;--shiki-dark:#E1E4E8">))</span></span></code></pre>
<p><strong>Do’s and don’ts</strong></p>
<ul>
<li>Continue handling <code>conversation.item.input_audio_transcription.delta</code> and <code>conversation.item.input_audio_transcription.completed</code>.</li>
<li>Preserve the existing item_id-based reconciliation logic.</li>
<li>Use the model’s <code>delay</code> setting to trade off faster partial transcripts against a more accurate final transcript.</li>
<li>Preserve the existing WebSocket or WebRTC transport; Realtime transcription supports both.</li>
</ul>
<h2 id="6-use-gpt-transcribe-in-a-committed-turn-realtime-session" class="group flex items-center gap-2 mt-7 mb-2 scroll-mt-[110px]"><span class="min-w-0">6. Use GPT-Transcribe in a committed-turn Realtime session</span><button type="button" class="shrink-0 self-center inline-flex items-center justify-center rounded-md p-0.5 opacity-0 transition-colors transition-opacity duration-200 ease-out text-info hover:text-info focus-visible:opacity-100 group-focus-within:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300 group-hover:opacity-100 dark:focus-visible:outline-gray-600 motion-reduce:transition-none relative -top-0.5" data-anchor-id="6-use-gpt-transcribe-in-a-committed-turn-realtim |
Auto Review
|
Involved Issue / 该 PR 相关 Issue
Close #
Example for the Proposed Route(s) / 路由地址示例
New RSS Route Checklist / 新 RSS 路由检查表
PuppeteerNote / 说明
The OpenAI Cookbook site has migrated from
cookbook.openai.com(Next.js + Tailwind CSS) todevelopers.openai.com/cookbook(Astro framework). All CSS selectors in the existing route no longer match, resulting in an empty feed.Changes:
developers.openai.com/cookbookastro-islandcomponent's serializedpropsJSON instead of parsing Tailwind CSS card selectorsdecodeAstroValue()to recursively decode the Astro serialization format ([0, value]scalar /[1, [...]]array)parseDate()for proper Date objectsfeatures(antiCrawler: true),parameters(limit), updateradarrulesUser-Agentheader to bypass Vercel bot detection (403)articleelementlimitquery parameter (default 30) to control the number of articles fetched