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

음성-음성 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

요청 예시

자바스크립트/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()