how-tos

Seed Audio 1.5 APIガイド:cURLとPythonによる最初のリクエスト

Poyo.ai Team
4 min read
Share:

Seed Audio 1.5 API開発者ガイド

この Seed Audio 1.5 API ガイドでは、Seed Audio 1.5 の全4モデルID(seed-audio-1.5、seed-audio-1.5-video-translation、seed-audio-1.5-video-dubbing、seed-audio-1.5-stem-separation)を対象に、最初のリクエスト送信、完了ポーリングやWebhookの利用、複数ファイルのダウンロード方法までを順を追って解説します。以下のすべてのJSONボディは、Seed Audio 1.5 APIリファレンス にある最新のPoYo OpenAPIスキーマに準拠しています。

前提条件と認証

  1. PoYoダッシュボードでAPIキーを発行し、POYO_API_KEY としてエクスポートします。
  2. すべてのリクエストはサーバーサイドから https://api.poyo.ai 宛てに送信し、Authorization: Bearer $POYO_API_KEY と Content-Type: application/json ヘッダーを付与します。
  3. 指定するすべての video_url、audio_url、reference_audio_urls、image_urls、subtitle_url は、カスタムヘッダーなしでHTTPまたはHTTPS経由で公開アクセス可能である必要があります。
export POYO_API_KEY="YOUR_POYO_API_KEY_HERE"

1. cURLでの最初のリクエスト:シーン音声生成(seed-audio-1.5)

seed-audio-1.5 は1つのプロンプトから会話、環境音、効果音、BGMを生成し、料金は 0.5クレジット($0.0025)/請求秒 です。話すセリフを引用符で囲み、話者・感情・環境・目標の長さを prompt に直接記述します。

curl -X POST "https://api.poyo.ai/api/generate/submit" \
  -H "Authorization: Bearer $POYO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seed-audio-1.5",
    "input": {
      "prompt": "A warm, rainy evening inside a cozy Tokyo jazz cafe. Soft rain taps on the glass window, an espresso cup clinks gently on a saucer, and mellow lo-fi piano plays softly in the background. A calm young woman speaks warmly in English: \"Rainy nights are the best time to ship. One prompt, dialogue, rain, and jazz, all mixed in ten seconds.\" Keep the clip around 10 seconds.",
      "output_format": "mp3",
      "sample_rate": 44100
    }
  }'

送信リクエストは即座に task_id を返します:

{
  "code": 200,
  "data": {
    "task_id": "0UE7HJQUU96FJZTI",
    "status": "not_started"
  }
}

data.status が "finished" または "failed" になるまでステータスエンドポイントをポーリングします:

curl -X GET "https://api.poyo.ai/api/generate/status/0UE7HJQUU96FJZTI" \
  -H "Authorization: Bearer $POYO_API_KEY"

2026年12月1日の本番実行では、この10秒プロンプトは 30.0秒 で完了し、請求額は 5.1クレジット($0.0255) でした。

2. その他3つのモデルID用 JSONリクエストボディ

4つのモデルすべてが同じ非同期エンドポイントを共有しているため、ワークフローを切り替える際は model と input を変更するだけです。

30言語対応の動画翻訳(seed-audio-1.5-video-translation)

課金は 動画1秒あたり 3クレジット($0.015) です。英語または中国語のMP4/MOV(4–360秒)を入力とし、吹替済み動画、吹替音声、ターゲット言語SRT、ソース言語SRTを返します。

{
  "model": "seed-audio-1.5-video-translation",
  "input": {
    "video_url": "https://storage.poyo.ai/models/seed-audio-1-5/examples/input-memory-scene-3450acdd2b13.mp4",
    "target_language": "ja",
    "dialogue_enhancement": "medium",
    "output_format": "mp3"
  }
}

ブランド名などの訳語を固定したい場合は、glossaries(最大1,000件の {"source": "...", "target": "..."} オブジェクト)を指定します。すでに翻訳済みのSRTファイルがある場合は、glossaries ではなく subtitle_url を渡してください。

台本ベースの動画アフレコ(seed-audio-1.5-video-dubbing)

課金は 動画1秒あたり 2クレジット($0.01) です。prompt に記載した台本を video_url 内の話者のタイミングに合わせて演じます(任意で最大6件の reference_audio_urls による声質ガイドが可能)。

{
  "model": "seed-audio-1.5-video-dubbing",
  "input": {
    "video_url": "https://storage.poyo.ai/models/seed-audio-1-5/examples/input-shell-presenter-1619916465d3.mp4",
    "prompt": "Clear, confident male narrator speaking in English at a steady pace: \"Welcome back. Today we are testing a single API call that replaces every spoken line in sync with the video.\"",
    "output_format": "mp3",
    "sample_rate": 44100
  }
}

ステム分離(seed-audio-1.5-stem-separation)

課金は 返却される全トラックを合計した音声1分あたり 10クレジット($0.05) です。prompt を空にすると、2–360秒のWAV/MP3をデフォルトの3トラック(speaker:ボーカル/話し声、sfx:効果音、bgm:バックグラウンドミュージック)に分離します。

{
  "model": "seed-audio-1.5-stem-separation",
  "input": {
    "audio_url": "https://storage.poyo.ai/models/seed-audio-1-5/examples/input-rain-bookshop-mix-4f3560ae6cfd.mp3",
    "output_format": "mp3",
    "sample_rate": 44100
  }
}

3. 上限付きポーリングと複数ファイルダウンロードを備えた完全なPythonクライアント

単一音声を返すエンドポイントと異なり、seed-audio-1.5-video-translation は最大4ファイル(MP4、MP3、2つのSRT)を返し、seed-audio-1.5-stem-separation は track_type が付与された複数のステム音声を返します。以下のPythonスクリプトは標準ライブラリのみを使用し、上限付きポーリングと安全なダウンロード(ファイルCDNへAPIキーを送信しない設計)で全4モデルに対応します。

import json
import os
import time
import urllib.parse
import urllib.request
from pathlib import Path

API_KEY = os.environ["POYO_API_KEY"]
BASE_URL = "https://api.poyo.ai"
HEADERS = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
}

def api_call(path: str, payload: dict | None = None) -> dict:
    data = json.dumps(payload).encode("utf-8") if payload is not None else None
    req = urllib.request.Request(
        f"{BASE_URL}{path}",
        data=data,
        headers=HEADERS,
        method="POST" if data else "GET",
    )
    with urllib.request.urlopen(req, timeout=60) as resp:
        body = json.loads(resp.read().decode("utf-8"))
    if body.get("code") not in (0, 200):
        raise RuntimeError(f"PoYo API error: {body}")
    return body

def run_seed_audio(payload: dict, out_dir: str = "output") -> dict:
    submitted = api_call("/api/generate/submit", payload)
    task_id = submitted["data"]["task_id"]
    print(f"Submitted {payload['model']} -> {task_id}")

    for attempt in range(1, 121):  # max 10 minutes at 5s intervals
        status_resp = api_call(f"/api/generate/status/{task_id}")
        data = status_resp["data"]
        state = data.get("status")
        print(f"[{attempt}] {state} (progress={data.get('progress')})")
        if state == "failed":
            raise RuntimeError(f"Task failed: {data.get('error_message')}")
        if state == "finished":
            Path(out_dir).mkdir(parents=True, exist_ok=True)
            for idx, item in enumerate(data.get("files") or [], 1):
                url = item["file_url"]
                ext = Path(urllib.parse.urlparse(url).path).suffix or ".mp3"
                label = item.get("track_type") or item.get("name") or item.get("file_type") or str(idx)
                dest = Path(out_dir) / f"{task_id}-{idx}-{label}{ext}"
                # Public CDN URL: do NOT send Authorization header
                with urllib.request.urlopen(url, timeout=120) as r:
                    dest.write_bytes(r.read())
                print(f"Saved {dest} ({dest.stat().st_size:,} bytes)")
            print(f"Credits billed: {data.get('credits_amount')}")
            return data
        time.sleep(5)
    raise TimeoutError(f"Task {task_id} did not finish within timeout")

if __name__ == "__main__":
    run_seed_audio({
        "model": "seed-audio-1.5-video-translation",
        "input": {
            "video_url": "https://storage.poyo.ai/models/seed-audio-1-5/examples/input-memory-scene-3450acdd2b13.mp4",
            "target_language": "ja",
            "dialogue_enhancement": "medium",
            "output_format": "mp3",
        },
    })

本番ワークロードでは、送信ペイロードのトップレベルに "callback_url": "https://your-app.example.com/webhooks/poyo" フィールドを追加すると、ポーリングする代わりに完了時の最終ステータスペイロードをPoYoからサーバーへプッシュ通知させることができます。

バリデーションルールと主なエラーハンドリング

  • 非対応の長さ:4秒未満または360秒超の動画はバリデーションに失敗します。ステム分離の入力は2〜360秒である必要があります。送信前に ffprobe でメディア長を確認してください。
  • 排他的フィールド:seed-audio-1.5-video-translation で glossaries と subtitle_url を同時に渡すと拒否されます。
  • 到達不能なメディアURL:有効期限が5分未満の署名付きURLや、非ブラウザUser-AgentをブロックするURLはタスク失敗の原因になります。メディアURLは最低15分間有効にしておいてください。
  • 残高不足(402):HTTP 402や200以外の code 値を捕捉し、リトライする前にアラートを出してください。

初回請求額の計算方法

PoYoは完了したタスクに対してクレジット(1クレジット = $0.005)で課金し、data.credits_amount に正確な請求額を返します:

  • 10秒の seed-audio-1.5 クリップは約5クレジット($0.025)。
  • 12秒の seed-audio-1.5-video-translation タスクは36クレジット($0.18)。
  • 3トラック(合計約32.4秒の音声)を返す10.8秒の seed-audio-1.5-stem-separation タスクは5.4クレジット($0.027)。

詳細なユニットエコノミクスとバッチコストの計算については、Seed Audio 1.5 API料金 および Seed Audio 1.5 API概要 をご覧ください。

よくある質問

Seed Audio 1.5 APIはどのエンドポイントを使用しますか?

4つのSeed Audio 1.5モデルはすべて、タスク作成に POST https://api.poyo.ai/api/generate/submit、結果取得に GET https://api.poyo.ai/api/generate/status/{task_id} を使用します。

ポーリングの代わりにWebhookを使えますか?

はい。送信するJSONボディのトップレベルに callback_url を含めると、完了通知および失敗通知を直接受け取ることができます。

seed-audio-1.5-stem-separation でどのステムがどれかをどう判別しますか?

data.files 内の各オブジェクトには、file_url と並んで track_type(speaker、sfx、または bgm)と description 文字列が含まれています。

サポートされている音声フォーマットとサンプルレートは?

4つのエンドポイントすべてで mp3(デフォルト)、wav、pcm、ogg_opus に対応し、サンプルレートは 8000、16000、24000、32000、44100(デフォルト)、48000 Hz を指定できます(ogg_opus は常に 48000 Hz を使用します)。

Share: