Skip to main content
POST
Initiate Speech-to-Speech WebRTC Session

Speech-to-Speech WebRTC セッションを開始する

OpenAI Realtime API を使用して、リアルタイムのスピーチツースピーチ会話のための WebRTC 接続を確立します。

エンドポイント

説明

OpenAI Realtime API を使用して、リアルタイムのスピーチツースピーチ会話のための WebRTC 接続を確立します。このエンドポイントは WebRTC SDP オファーを受け入れ、OpenAI の Realtime API とのピア接続を確立するために使用できる SDP アンサーを返します。

利用の流れ

  1. クライアントが WebRTC オファー (RTCPeerConnection.createOffer) を作成します。
  2. クライアントは SDP オファーをこのエンドポイントに送信します
  3. このエンドポイントは、OpenAI Realtime API へのオファーをプロキシします。
  4. クライアントは SDP 応答を受信し、WebRTC 接続を確立します
  5. クライアントは AI とリアルタイムで音声会話できるようになります

S2S 時間追跡

  • 各ユーザーには、ライセンスに基づいて毎月の S2S 時間割り当てがあります。
  • 時間は分単位で追跡され、セッションが記録されるときに差し引かれます
  • /speech/s2s/statusを使用して残り時間を確認します
  • /speech/s2s/log-session を使用してセッション期間を記録し、時間を差し引きます

SMLTP の統合

  • セキュリティとコンプライアンスのために、すべてのリクエストは SMLTP を通じて処理されます
  • モデル検証は、指定された SMLTP ポリシーに基づいて強制されます。
  • リクエストは監査され、コンプライアンス追跡のために記録されます。

認証

必須: API キー

リクエスト本文

利用可能なモデル

  • gpt-4o-mini-realtime-preview
  • gpt-4o-realtime-preview

利用可能な音声

  • alloy (デフォルト)
  • echo
  • fable
  • onyx
  • nova
  • shimmer
  • ash
  • ballad
  • coral

利用可能な SMLTP ポリシー

  • public
  • internal (デフォルト)
  • internal-strict
  • confidential
  • hipaa
  • gdpr
  • pci-dss

リクエストの例

JavaScript/Node.js

パイソン

応答

成功の応答 (200)

コンテンツ タイプ: application/sdp 応答は、RTCPeerConnection.setRemoteDescription() で使用できる SDP 応答文字列です。

エラー応答

400 不正なリクエスト

403 禁止

S2S 制限時間に達しました

モデルの検証に失敗しました

500 内部サーバーエラー

注意事項

  • SDP オファーは有効な WebRTC SDP オファー文字列である必要があります
  • SDP 回答を受信したら、それを使用して RTCPeerConnection にリモートの説明を設定します。
  • /speech/s2s/status を使用してセッションを開始する前に S2S 時間ステータスを確認します
  • /speech/s2s/log-session を使用して完了後のセッション期間をログに記録します
  • セキュリティとコンプライアンスのために、すべてのリクエストは SMLTP を通じて処理されます
  • user_id パラメータにより、別のユーザー アカウントへの請求が可能になります

承認

Authorization
string
header
必須

API key authentication using Bearer token format. Example: Authorization: Bearer sk-your-api-key-here

ボディ

application/json
sdp
string
必須

WebRTC SDP offer from the client's RTCPeerConnection

:

"v=0\r\no=- 4611731400430051336 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n..."

model
enum<string>
デフォルト:gpt-4o-mini-realtime-preview

OpenAI Realtime model to use

利用可能なオプション:
gpt-4o-mini-realtime-preview,
gpt-4o-realtime-preview
voice
enum<string>
デフォルト:alloy

Voice to use for the AI response

利用可能なオプション:
alloy,
echo,
fable,
onyx,
nova,
shimmer,
ash,
ballad,
coral
smltp_policy
enum<string>
デフォルト:internal

SMLTP policy to apply for this session

利用可能なオプション:
public,
internal,
internal-strict,
confidential,
hipaa,
gdpr,
pci-dss
output_audio
boolean
デフォルト:true

Whether to enable audio output (default: true)

user_id
string

Optional user ID to bill this session to (defaults to API key owner)

:

"60a7c8f5e8b4f5001f7a8c23"

instructions
string

Optional system instructions for the AI assistant

:

"You are a helpful customer service agent."

レスポンス

SDP answer from OpenAI Realtime API

SDP answer that can be used with RTCPeerConnection.setRemoteDescription()