Skip to Content
API 參考OpenAI 相容協議Audio Transcriptions

Audio Transcriptions API

將音訊轉為文字。相容 OpenAI 的 POST /v1/audio/transcriptions,以 multipart/form-data 上傳音訊檔案。

系列模型說明
GPT 轉錄openai/gpt-transcribe、openai/gpt-4o-mini-transcribe、openai/gpt-4o-transcribe-diarize見 GPT 轉錄
ElevenLabselevenlabs/scribe_v2支援逐字時間戳記與說話者分離,見 ElevenLabs

快速開始

base_urlhttps://api.ofox.io/v1
介面網址https://api.ofox.io/v1/audio/transcriptions
模型 IDopenai/gpt-transcribe
transcribe.py
import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"]) with open("meeting.mp3", "rb") as f: result = client.audio.transcriptions.create( model="openai/gpt-transcribe", file=f, language="zh", prompt="以下是普通话的句子,请使用简体中文。", ) print(result.text)

請求參數

file必填file

音訊檔案,如 mp3、wav。非音訊檔案會回傳 400。

model必填string

模型 ID,見上表。

languagestring

音訊的語言,如 zh、en。不傳時自動辨識。

promptstring

提示文字,用於指定用字習慣或專有名詞,適用於 GPT 轉錄模型。轉錄普通話時,建議同時傳入 language: "zh" 與「以下是普通话的句子,请使用简体中文。」,否則可能輸出繁體字。

response_formatstring· 預設 json· 可選jsonverbose_json

僅支援 json 與 verbose_json;text、srt、vtt 會回傳 400。verbose_json 僅適用於 ElevenLabs Scribe。

供應商專屬參數,以 JSON 字串作為表單欄位傳入,例如 {"elevenlabs": {"diarize": true}}。見各系列頁。

回應

{ "text": "今天天气很好,我们下午三点在会议室讨论新功能。", "usage": { "type": "duration", "seconds": 9 } }
textstring

轉錄文字。

usageobject

計費依據。type 為 duration 時依音訊秒數計費(seconds);為 tokens 時依 token 計費(input_tokens、output_tokens)。

ElevenLabs Scribe 另外回傳 words(逐字文字與起訖時間)、language、duration 等欄位,見 ElevenLabs。需要字幕檔時,可依 words 中的時間戳記自行產生。

常見錯誤

HTTP錯誤原文原因處理方式
400Unsupported response_format 'srt'. Only 'json' and 'verbose_json' are supported on this gateway使用了 text、srt、vtt改用 json;字幕請依時間戳記產生
400response_format 'verbose_json' is not compatible with model 'gpt-transcribe'. Use 'json' or 'text' instead.GPT 轉錄模型不支援 verbose_json改用 json
400Unsupported file format txt上傳的不是音訊檔案上傳 mp3、wav 等音訊
400Model 'openai/gpt-5.4' is not supported on /v1/audio/transcriptions. Supported: ...所選模型不是轉錄模型改用錯誤訊息中列出的模型
400You must provide a model parameter.以 JSON 而非表單提交了請求使用 multipart/form-data 上傳檔案

完整的錯誤碼說明見錯誤處理。

最後更新於