Documentation
¶
Overview ¶
Package realtime provides realtime session implementations (OpenAI Realtime API and shim). RealtimeSession (SendText, SendAudio, Events, Close) and RealtimeService (NewSession) align with OpenAI Realtime and WebSocket session abstractions: a long-lived bidirectional session over WebSocket with event-driven input/output. OpenAIRealtimeAPI uses the official OpenAI Realtime WebSocket API; use realtime.NewFromConfig(cfg, "openai") to construct it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFromConfig ¶
NewFromConfig returns a RealtimeService for the given provider, or an error if unsupported. Provider should be one of services.SupportedRealtimeProviders (e.g. "openai", "hume", "inworld"). This lives in the realtime package to avoid an import cycle (services -> realtime -> services).
Types ¶
type OpenAIRealtime ¶
type OpenAIRealtime struct {
// contains filtered or unexported fields
}
OpenAIRealtime provides a minimal OpenAI-backed implementation of services.RealtimeService. It builds on the existing LLM and STT services rather than the dedicated OpenAI Realtime API, but exposes a compatible interface that can be upgraded later.
func NewOpenAIRealtime ¶
func NewOpenAIRealtime(apiKey, model string) *OpenAIRealtime
NewOpenAIRealtime constructs an OpenAIRealtime provider using the given API key and model. If apiKey or model are empty, the defaults from NewService and NewOpenAI are used.
func (*OpenAIRealtime) NewSession ¶
func (r *OpenAIRealtime) NewSession(ctx context.Context, cfg services.RealtimeConfig) (services.RealtimeSession, error)
NewSession creates a new realtime session. The RealtimeConfig is currently used only for model overrides; provider/voice/tools are accepted for future compatibility.
type OpenAIRealtimeAPI ¶
type OpenAIRealtimeAPI struct {
// contains filtered or unexported fields
}
OpenAIRealtimeAPI implements services.RealtimeService using the official OpenAI Realtime WebSocket API. It corresponds to the Python openai_realtime service: single WebSocket, response.audio_transcript.done and response.audio.delta events mapped to RealtimeEvent (Text/Audio).
func NewOpenAIRealtimeAPI ¶
func NewOpenAIRealtimeAPI(apiKey, model string) *OpenAIRealtimeAPI
NewOpenAIRealtimeAPI creates a Realtime service that uses the OpenAI Realtime API (WebSocket).
func (*OpenAIRealtimeAPI) NewSession ¶
func (r *OpenAIRealtimeAPI) NewSession(ctx context.Context, cfg services.RealtimeConfig) (services.RealtimeSession, error)
NewSession opens a WebSocket to the Realtime API and returns a session.