Skip to main content

Module codex_live

Module codex_live 

Source
Expand description

Codex live calls (internal/client/codex/live): the WebRTC SDP bootstrap request to the ChatGPT realtime calls endpoint, its sideband and standard Realtime WebSockets, and hangup.

Request shaping ports live.go, client_secret.go and websocket.go byte for byte, including Go’s error texts; expected values come from tests/fixtures/codex_live/vectors.json, generated by running the Go functions. Routes, client secrets and call state live in cpa-server’s realtime module.

Structs§

Call
A call request on its way upstream.
DialError
A failed upstream WebSocket dial.
Endpoints
Where live requests go. Tests point both at local mocks.
HandshakeResponse
A non-101 handshake answer, its body capped like gorilla’s.
LiveSocket
A connected upstream WebSocket.
LiveTarget
The credential and client context of one live upstream exchange.
SecretRequest
clientSecretCreateRequest as json.Unmarshal decodes it: the raw session (empty when absent) and expires_after (None when absent or null). None is any decode error; Go answers every one with the same message.

Enums§

BodyError
readLimitedBody outcome.
SessionError
Why a client-secret session was refused.
ShapeError
Why a call request could not be shaped.
Sideband
The three sideband URL shapes (sidebandStyle).

Constants§

API_BASE
defaultSidebandAPIBaseURL: sideband, standard Realtime WebSocket and hangup.
CALL_URL
upstreamCallURL.
DEFAULT_MODEL
defaultLiveModel.
DEFAULT_STANDARD_MODEL
defaultStandardRealtimeModel.
MAX_BODY
maxBodySize: call requests, upstream responses and rejected handshakes.
MAX_WS_MESSAGE
Largest relayed WebSocket message.
PROTOCOL_HEADERS
liveProtocolHeaders: client headers forwarded to every live upstream request.

Functions§

apply_client_secret
applyClientSecretCallSession: the ephemeral key’s session replaces the request’s.
bearer_token
bearerToken: the trimmed token after a case-insensitive Bearer .
call_id_from_location
callIDFromLocation: a bare ID, ?call_id=, or the last segment after live or calls.
call_response_headers
callResponseHeaders: what request logs keep of a live upstream response.
client_secret_lifetime
clientSecretLifetime: ten minutes by default, else 10 s to 2 h from created_at.
codex_model
codexRealtimeModel: OpenAI Realtime model names map to the Codex live model.
decode_secret_request
direct_headers
directRealtimeHeaders: no OpenAI-Alpha, and Originator defaults to Codex Desktop.
direct_url
directRealtimeURL.
http_base
realtimeHTTPBaseURL: where hangup goes.
http_url
websocketHTTPURL: ws→http, wss→https.
model_from_json
modelFromJSON: session.model, else model, trimmed; empty when Go’s decode into struct{Model; Session struct{Model}} fails at all.
normalize_client_secret_session
normalizeClientSecretSession: the session shown to the client and the one sent upstream (Codex model), both as Go’s map[string]any marshals them.
prepare
prepareCallRequest: multipart SDP + session becomes {"sdp","session"} JSON; any other body passes through with its model (default gpt-live-1-codex).
protocol_headers
protocolHeaders: the forwarded client headers, canonical names, every value.
read_limited
readLimitedBody: at most MAX_BODY bytes, keeping what arrived on error.
redact_sdp
A request log copy of a live body without SDP ICE credentials: each a=ice-ufrag: and a=ice-pwd: value becomes [REDACTED], whether the SDP is raw, a multipart field or a JSON string. Go logs these bodies unchanged.
replace_sdp
replaceCallRequestSDP: the relay’s own offer replaces the client’s.
request_sdp
callRequestSDP: the client’s offer, for the media relay.
response_sdp
callResponseSDP: the upstream answer, JSON-wrapped or raw.
rewrite_model
rewriteCallRequestModel: the upstream model replaces session.model, or a top-level model when there is no session. Returns the upstream model.
session_response
realtimeSessionResponse: the client session with id, object and expires_at.
session_update
realtimeSessionUpdate: the key’s session minus the fields a session.update may not carry.
sideband_url
buildSidebandURL.
valid_call_id
callIDPattern: ^[A-Za-z0-9_-]{1,128}$.