Documentation
¶
Overview ¶
Package realtimeclient is a Realtime protocol client.
It exists twice over: the upstream binding needs it to put a remote model behind OpenRealtime's background reasoner, and the measurement program needs it to drive any Realtime-compatible endpoint - including this one - through the same wire the field uses. A client written against the protocol is also the only honest way to test that the protocol is what we say it is.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is one connection to a Realtime endpoint.
type Config ¶
type Config struct {
// URL is the WebSocket endpoint, ws:// or wss://.
URL string
// Token is the bearer credential. Empty sends no Authorization header.
Token string
// Model is appended as a query parameter when the URL has none.
Model string
// Header carries additional headers, such as a provider's beta opt-in.
Header http.Header
// ValidateWire checks inbound server events against the pinned schema.
// It is off by default here: a client that refuses to talk to a slightly
// non-conformant server is less useful than one that reports the problem,
// and the conformance suite is where strictness belongs.
ValidateWire bool
// ReadLimit bounds one inbound message. Zero selects 8 MiB, which is
// generous enough for a large audio delta.
ReadLimit int64
// DialTimeout bounds connection establishment.
DialTimeout time.Duration
// WriteTimeout bounds one send on an established connection. Zero selects
// the shipped default; a negative value removes the bound.
//
// Send takes a context, so a caller can always bound its own call - but
// the callers that matter here hold a session-scoped socket and pass the
// session's context, which ends when the conversation does. A peer that
// stops reading then blocks the send with nothing left to end it, and
// because Send holds the write lock, every later send blocks behind the
// first. The upstream binding forwards a caller's audio through this, so
// what stops is the conversation, with no error anywhere to say why.
//
// Thirty seconds rather than a cadence: this client carries whole Realtime
// events to a Realtime server rather than frames to one provider, and the
// bound only has to be past any stall a congested link produces and short
// of forever. A caller whose traffic has a tighter cadence sets its own.
WriteTimeout time.Duration
// LifetimeContext optionally owns the established connection's receive
// loop independently from the Dial call's setup context. Most callers leave
// it nil. Measurement drivers use it when a task deadline must stop behavior
// before closing a session-scoped inspection capability needed for terminal
// evidence collection.
LifetimeContext context.Context
// EventAliases renames inbound server events onto the names this project
// reads, which are OpenAI's current ones.
//
// Several endpoints implement the Realtime protocol as it stood before
// OpenAI renamed response.audio.delta to response.output_audio.delta at
// general availability. That is the entire difference for some of them, so
// it is a rename table rather than a second client: a vendor whose only
// deviation is a spelling should not cost an adapter.
//
// It renames the delivered event type and leaves the raw bytes untouched,
// because the raw bytes are what the endpoint actually sent and a caller
// decoding them should see the truth.
EventAliases map[string]string
}
Config configures a connection.