https://api.allmodels.io/oai
OpenAI互換
すでにOpenAI SDKを使っていますか?ベースURLをAllModelsに設定すれば、AllModelsのモデルIDでaudio.transcriptions.createやリアルタイムクライアントをそのまま呼び出せます。
AllModels経由で、複数プロバイダーのSTTモデルを使って文字起こしできます。WebSocketで音声をストリーミングしたり、OpenAI互換・ElevenLabs互換のSDKを使ったりでき、文字起こしパイプラインを作り直さずにモデルを切り替えられます。
AllModelsは独立したサービスであり、ルーティング先のモデルを提供するプロバイダーとは提携関係になく、その承認や後援も受けていません。
統合型の音声認識(STT)APIとは、さまざまなプロバイダーのモデルで音声を文字起こしできる単一のインテグレーションです。Deepgram用、AssemblyAI用、Soniox用、OpenAI用とクライアントを個別に書く代わりに、アプリケーションは1つのエンドポイントと1つのAPIキーでやり取りします。どのプロバイダーが文字起こしするかは、選んだモデルで決まります。AllModelsはこの種の統合型STT APIです。deepgram/nova-3、assemblyai/universal-3-5-pro-realtime、soniox/stt-rt-v5のようなモデルIDを送ると、AllModelsが音声をそのプロバイダーにルーティングし、文字起こし結果を返します。
AllModelsのSTTカタログにあるすべてのモデルにはprovider/model形式のIDがあります。認証はAllModelsのAPIキー1つで済み、プロバイダーごとに管理していた個別のキーや請求アカウントは不要になります。AllModelsでは、同じモデルを次の3つの方法で呼び出せます。
wss://api.allmodels.io/v1/stt。キャプチャした生の音声フレームを順次送り、モデルの背後にどのプロバイダーがあっても、統一された形式のstt.transcript.partialイベントとstt.transcript.finalイベントを受け取ります。https://api.allmodels.io/oai。公式のOpenAI SDKのベースURLをここに向ければ、ファイルにはaudio.transcriptions.createを、ライブ音声にはリアルタイムクライアントをそのまま使えます。https://api.allmodels.io/el。公式のElevenLabs SDKのベースURLをここに向ければ、リアルタイム文字起こしを含む音声認識メソッドをそのまま呼び出せます。3つとも同じカタログにアクセスします。コードベースですでにOpenAIやElevenLabsのSDKを使っている場合は、ベースURLとAPIキーを変えるだけでAllModelsに移行できます。
マイク、通話、音声エージェントでは、WebSocketで音声をストリーミングし、話者が話している最中から途中の文字起こし結果を読み取れます。録音がすでに揃っている場合は、1回のHTTPリクエストでアップロードして全文の文字起こしを受け取ります。別のSTTモデルを使うにはモデルIDを変えるだけで、APIキー、エンドポイント、クライアントのコードはそのままです。
クライアント、モード、言語を選んでください。ハイライトされた行は、AllModelsのベースURLと、別のモデルを試すときに変更するモデルの値です。
wss://api.allmodels.io/v1/sttに接続し、16 kHzのPCM音声をバイナリフレームで送って、途中結果と確定した文字起こしを読み取ります。 STTドキュメント。
import { readFile } from "node:fs/promises";
import WebSocket from "ws";
const url = new URL("wss://api.allmodels.io/v1/stt");
url.searchParams.set("model", "deepgram/nova-3");
url.searchParams.set("audio_format", "pcm_16000");
url.searchParams.set("language", "en");
url.searchParams.set("commit_strategy", "manual");
const ws = new WebSocket(url, {
headers: { Authorization: `Bearer ${process.env.ALLMODELS_API_KEY}` }
});
ws.on("message", (data) => {
const event = JSON.parse(data.toString());
if (event.type === "stt.transcript.partial") console.log("partial:", event.text);
if (event.type === "stt.transcript.final") {
console.log("final:", event.text);
ws.send(JSON.stringify({ type: "stt.session.close" }));
}
});
ws.on("open", async () => {
const audio = await readFile("speech-16khz.pcm");
for (let offset = 0; offset < audio.length; offset += 3200) {
ws.send(audio.subarray(offset, offset + 3200));
}
ws.send(JSON.stringify({ type: "stt.audio.commit" }));
});wss://api.allmodels.io/v1/sttに接続し、16 kHzのPCM音声をバイナリフレームで送って、途中結果と確定した文字起こしを読み取ります。 STTドキュメント。
import asyncio
import json
import os
from pathlib import Path
from urllib.parse import urlencode
import websockets
async def main():
query = urlencode({
"model": "deepgram/nova-3",
"audio_format": "pcm_16000",
"language": "en",
"commit_strategy": "manual",
})
headers = {"Authorization": f"Bearer {os.environ['ALLMODELS_API_KEY']}"}
async with websockets.connect(
f"wss://api.allmodels.io/v1/stt?{query}", additional_headers=headers
) as ws:
audio = Path("speech-16khz.pcm").read_bytes()
for offset in range(0, len(audio), 3200):
await ws.send(audio[offset:offset + 3200])
await ws.send(json.dumps({"type": "stt.audio.commit"}))
async for message in ws:
event = json.loads(message)
if event["type"] == "stt.transcript.partial":
print("partial:", event["text"])
elif event["type"] == "stt.transcript.final":
print("final:", event["text"])
break
asyncio.run(main())録音がすでにある場合は、https://api.allmodels.io/oai/audio/transcriptionsにPOSTして文字起こし結果を読み取ります。 STTドキュメント。
import { readFile } from "node:fs/promises";
const form = new FormData();
form.set("model", "deepgram/nova-3");
form.set("language", "en");
form.set("file", new Blob([await readFile("call.wav")], { type: "audio/wav" }), "call.wav");
const response = await fetch("https://api.allmodels.io/oai/audio/transcriptions", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.ALLMODELS_API_KEY}` },
body: form
});
if (!response.ok) throw new Error(await response.text());
const transcript = await response.json();
console.log(transcript.text);録音がすでにある場合は、https://api.allmodels.io/oai/audio/transcriptionsにPOSTして文字起こし結果を読み取ります。 STTドキュメント。
import os
import requests
with open("call.wav", "rb") as audio:
response = requests.post(
"https://api.allmodels.io/oai/audio/transcriptions",
headers={"Authorization": f"Bearer {os.environ['ALLMODELS_API_KEY']}"},
data={"model": "deepgram/nova-3", "language": "en"},
files={"file": ("call.wav", audio, "audio/wav")},
timeout=60,
)
response.raise_for_status()
print(response.json()["text"])OpenAI SDKのベースURLをhttps://api.allmodels.io/oaiに設定し、リアルタイム文字起こしセッションを開いて24 kHzのPCM音声を送ります。 OpenAIリアルタイムドキュメント。
import { once } from "node:events";
import { readFile } from "node:fs/promises";
import OpenAI from "openai";
import { OpenAIRealtimeWebSocket } from "openai/realtime/websocket";
const client = new OpenAI({
apiKey: process.env.ALLMODELS_API_KEY,
baseURL: "https://api.allmodels.io/oai"
});
const realtime = await OpenAIRealtimeWebSocket.create(client, {
model: "openai/gpt-realtime-whisper"
});
if (realtime.socket.readyState !== 1) await once(realtime.socket, "open");
realtime.on("conversation.item.input_audio_transcription.delta", ({ delta }) => {
process.stdout.write(delta);
});
realtime.on("conversation.item.input_audio_transcription.completed", ({ transcript }) => {
console.log("\nfinal:", transcript);
realtime.close();
});
realtime.send({
type: "session.update",
session: {
type: "transcription",
audio: {
input: {
format: { type: "audio/pcm", rate: 24000 },
transcription: { model: "openai/gpt-realtime-whisper", language: "en" },
turn_detection: null
}
}
}
});
const audio = await readFile("speech-24khz.pcm");
for (let offset = 0; offset < audio.length; offset += 4800) {
realtime.send({
type: "input_audio_buffer.append",
audio: audio.subarray(offset, offset + 4800).toString("base64")
});
}
realtime.send({ type: "input_audio_buffer.commit" });OpenAI SDKのベースURLをhttps://api.allmodels.io/oaiに設定し、リアルタイム文字起こしセッションを開いて24 kHzのPCM音声を送ります。 OpenAIリアルタイムドキュメント。
import asyncio
import base64
import os
from pathlib import Path
from openai import AsyncOpenAI
async def main():
client = AsyncOpenAI(
api_key=os.environ["ALLMODELS_API_KEY"],
base_url="https://api.allmodels.io/oai",
)
async with client.realtime.connect(
model="openai/gpt-realtime-whisper",
extra_query={"intent": "transcription"},
) as connection:
await connection.session.update(session={
"type": "transcription",
"audio": {
"input": {
"format": {"type": "audio/pcm", "rate": 24000},
"transcription": {"model": "openai/gpt-realtime-whisper", "language": "en"},
"turn_detection": None,
}
},
})
audio = Path("speech-24khz.pcm").read_bytes()
for offset in range(0, len(audio), 4800):
chunk = base64.b64encode(audio[offset:offset + 4800]).decode("ascii")
await connection.input_audio_buffer.append(audio=chunk)
await connection.input_audio_buffer.commit()
async for event in connection:
if event.type == "conversation.item.input_audio_transcription.delta":
print(event.delta, end="", flush=True)
elif event.type == "conversation.item.input_audio_transcription.completed":
print("\nfinal:", event.transcript)
break
asyncio.run(main())OpenAI SDKのベースURLをhttps://api.allmodels.io/oaiに設定し、audio.transcriptions.createで完成したファイルを文字起こしします。 OpenAI文字起こしドキュメント。
import { createReadStream } from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.ALLMODELS_API_KEY,
baseURL: "https://api.allmodels.io/oai"
});
const transcript = await client.audio.transcriptions.create({
file: createReadStream("call.wav"),
model: "deepgram/nova-3",
language: "en"
});
console.log(transcript.text);OpenAI SDKのベースURLをhttps://api.allmodels.io/oaiに設定し、audio.transcriptions.createで完成したファイルを文字起こしします。 OpenAI文字起こしドキュメント。
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["ALLMODELS_API_KEY"],
base_url="https://api.allmodels.io/oai",
)
with open("call.wav", "rb") as audio:
transcript = client.audio.transcriptions.create(
file=audio,
model="deepgram/nova-3",
language="en",
)
print(transcript.text)ElevenLabs SDKのベースURLをhttps://api.allmodels.io/elに設定し、リアルタイム音声認識クライアントで16 kHzのPCM音声をストリーミングします。 ElevenLabsリアルタイムドキュメント。
import { readFile } from "node:fs/promises";
import { AudioFormat, CommitStrategy, ElevenLabsClient, RealtimeEvents } from "@elevenlabs/elevenlabs-js";
const client = new ElevenLabsClient({
apiKey: process.env.ALLMODELS_API_KEY,
baseUrl: "https://api.allmodels.io/el"
});
const connection = await client.speechToText.realtime.connect({
modelId: "deepgram/nova-3",
audioFormat: AudioFormat.PCM_16000,
sampleRate: 16000,
languageCode: "en",
commitStrategy: CommitStrategy.MANUAL
});
connection.on(RealtimeEvents.PARTIAL_TRANSCRIPT, ({ text }) => console.log("partial:", text));
connection.on(RealtimeEvents.COMMITTED_TRANSCRIPT, ({ text }) => {
console.log("final:", text);
connection.close();
});
connection.on(RealtimeEvents.SESSION_STARTED, async () => {
const audio = await readFile("speech-16khz.pcm");
for (let offset = 0; offset < audio.length; offset += 3200) {
connection.send({ audioBase64: audio.subarray(offset, offset + 3200).toString("base64") });
}
connection.commit();
});ElevenLabs SDKのベースURLをhttps://api.allmodels.io/elに設定し、リアルタイム音声認識クライアントで16 kHzのPCM音声をストリーミングします。 ElevenLabsリアルタイムドキュメント。
import asyncio
import base64
import os
from pathlib import Path
from elevenlabs import AudioFormat, CommitStrategy, ElevenLabs, RealtimeEvents
async def main():
client = ElevenLabs(
api_key=os.environ["ALLMODELS_API_KEY"],
base_url="https://api.allmodels.io/el",
)
connection = await client.speech_to_text.realtime.connect({
"model_id": "deepgram/nova-3",
"audio_format": AudioFormat.PCM_16000,
"sample_rate": 16000,
"language_code": "en",
"commit_strategy": CommitStrategy.MANUAL,
})
finished = asyncio.Event()
def on_committed(event):
print("final:", event["text"])
finished.set()
connection.on(RealtimeEvents.PARTIAL_TRANSCRIPT, lambda event: print("partial:", event["text"]))
connection.on(RealtimeEvents.COMMITTED_TRANSCRIPT, on_committed)
audio = Path("speech-16khz.pcm").read_bytes()
for offset in range(0, len(audio), 3200):
chunk = base64.b64encode(audio[offset:offset + 3200]).decode("ascii")
await connection.send({"audio_base_64": chunk})
await connection.commit()
await finished.wait()
await connection.close()
asyncio.run(main())ElevenLabs SDKのベースURLをhttps://api.allmodels.io/elに設定し、完成したファイルを文字起こしします。JavaScript SDKはモデルIDを検証するため、scribe_v2のようにSDKが認識するIDを使ってください。 ElevenLabs文字起こしドキュメント。
import { File } from "node:buffer";
import { readFile } from "node:fs/promises";
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
const client = new ElevenLabsClient({
apiKey: process.env.ALLMODELS_API_KEY,
baseUrl: "https://api.allmodels.io/el"
});
const bytes = await readFile("call.wav");
const transcript = await client.speechToText.convert({
file: new File([bytes], "call.wav", { type: "audio/wav" }),
modelId: "scribe_v2",
languageCode: "en"
});
console.log(transcript.text);ElevenLabs SDKのベースURLをhttps://api.allmodels.io/elに設定し、AllModelsの任意のSTTモデルIDで完成したファイルを文字起こしします。 ElevenLabs文字起こしドキュメント。
import os
from elevenlabs.client import ElevenLabs
client = ElevenLabs(
api_key=os.environ["ALLMODELS_API_KEY"],
base_url="https://api.allmodels.io/el",
)
with open("call.wav", "rb") as audio:
transcript = client.speech_to_text.convert(
file=audio,
model_id="deepgram/nova-3",
language_code="en",
)
print(transcript.text)互換インターフェース
https://api.allmodels.io/oai
すでにOpenAI SDKを使っていますか?ベースURLをAllModelsに設定すれば、AllModelsのモデルIDでaudio.transcriptions.createやリアルタイムクライアントをそのまま呼び出せます。
https://api.allmodels.io/el
すでにElevenLabs SDKを使っていますか?ベースURLをAllModelsに設定すれば、AllModelsのモデルIDでconvertやリアルタイムの音声認識メソッドをそのまま使えます。
ElevenLabs文字起こしドキュメントを読む要点まとめ
統合型STT APIは、複数の文字起こしモデルに対する単一のインテグレーション窓口をアプリケーションに提供します。AllModelsでは、選んだモデルIDでプロバイダーが決まり、認証と基本的なリクエストの流れは変わりません。
はい。ネイティブインターフェースは/v1/sttでWebSocket経由のストリーミングを行い、途中結果と確定した文字起こしを統一されたstt.*イベントとして返します。OpenAI SDKとElevenLabs SDKは、それぞれのリアルタイムクライアントでストリーミングします。ストリーミング対応はモデルによって異なります。
はい。共通の設定は標準のフィールドで指定し、話者分離の設定などのプロバイダー固有の設定はprovider_optionsに入れると、そのままプロバイダーに渡されます。
アプリケーションのモデルIDを変更する前に、STTカタログで利用可能なモデル、ストリーミング対応、価格、APIの例を比較してください。
provider/model形式のIDでSTTモデルを選びます。