Skip to content

Audio (Speech & Transcription)

テキスト読み上げ(TTS)と文字起こし(STT)を提供します。OpenAI Audio API と互換性があります。

プロンプトからの音楽生成(POST /v1/audio/generations)は専用 ページ /docs/api/music で扱います。

テキスト読み上げ#

POST/v1/audio/speech

POST /v1/audio/speech はテキストを音声オーディオに変換します。 リクエストには plm_ で始まる API キーが必要です。

パラメータ必須説明
modelstring任意TTS モデル ID。デフォルト値 tts-1
inputstring必須変換するテキスト。最大 8,000 文字。
voicestring任意使用する声。デフォルト値 alloy
response_formatstring任意オーディオ形式(例: mp3)。
curl
curl https://apirouter.pleum.ai/v1/audio/speech \
  -H "Authorization: Bearer $PLEUM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "Hello from PleumRouter.",
    "voice": "alloy",
    "response_format": "mp3"
  }' \
  --output out.mp3
OpenAI SDK (Python)
from openai import OpenAI

client = OpenAI(api_key="plm_...", base_url="https://apirouter.pleum.ai/v1")

response = client.audio.speech.create(
    model="tts-1",
    input="Hello from PleumRouter.",
    voice="alloy",
    response_format="mp3",
)
response.write_to_file("out.mp3")
OpenAI SDK (TypeScript)
import OpenAI from "openai";
import fs from "node:fs";

const client = new OpenAI({ apiKey: "plm_...", baseURL: "https://apirouter.pleum.ai/v1" });

const response = await client.audio.speech.generate({
  model: "tts-1",
  input: "Hello from PleumRouter.",
  voice: "alloy",
  response_format: "mp3",
});

fs.writeFileSync("out.mp3", Buffer.from(await response.arrayBuffer()));
このエンドポイントのレスポンスボディは JSON ではなく生のオーディオバイトです。 Content-Type は形式に応じて audio/mpeg(mp3)などに設定されます。 費用はボディではなくレスポンスヘッダー X-Cost-KrwX-Cost-Usd で返されます。課金は入力文字数単位です。

文字起こし#

POST/v1/audio/transcriptions

POST /v1/audio/transcriptions はオーディオファイルをテキストに文字起こしします。 リクエストには plm_ で始まる API キーが必要です。

このエンドポイントは multipart/form-data でリクエストします — JSON ボディ ではなく、ファイルをフォームフィールドとしてアップロードします。

パラメータ必須説明
filefile必須文字起こしするオーディオファイル。フォームフィールドとしてアップロード。
modelstring任意文字起こしモデル ID(フォームフィールド)。デフォルト値 whisper-1
curl
curl https://apirouter.pleum.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer $PLEUM_API_KEY" \
  -F file=@speech.mp3 \
  -F model=whisper-1
OpenAI SDK (Python)
from openai import OpenAI

client = OpenAI(api_key="plm_...", base_url="https://apirouter.pleum.ai/v1")

with open("speech.mp3", "rb") as f:
    response = client.audio.transcriptions.create(model="whisper-1", file=f)
print(response.text)
OpenAI SDK (TypeScript)
import OpenAI from "openai";
import fs from "node:fs";

const client = new OpenAI({ apiKey: "plm_...", baseURL: "https://apirouter.pleum.ai/v1" });

const response = await client.audio.transcriptions.create({
  model: "whisper-1",
  file: fs.createReadStream("speech.mp3"),
});

console.log(response.text);

レスポンスは、文字起こしされた text、使用された model、そして cost(ウォン建て費用・為替レート・ マークアップ)を含む JSON です。課金はオーディオの長さ(分)単位です。

200 OK
{
  "text": "Hello from PleumRouter.",
  "model": "whisper-1",
  "cost": {
    "usd": 0.006,
    "krw": 8,
    "fx_rate": 1525.0,
    "markup_rate": 0.0
  }
}