Mojentic.Realtime.Broker (Mojentic v1.5.0)

Copy Markdown View Source

Realtime voice broker — sibling to Mojentic.LLM.Broker.

The broker holds no session state. Each connect/1 opens a fresh transport via the configured gateway, hands the transport to a new Mojentic.Realtime.Session GenServer, and returns the session pid.

Subscribers receive vendor-neutral {:realtime_event, %Event{}} messages by calling Session.subscribe/2 after connect/1.

Mirrors RealtimeVoiceBroker in mojentic-py / mojentic-ts.

Summary

Functions

Open a new realtime session. Returns {:ok, session_pid} or {:error, reason}. The initial session.update is sent before returning so callers can immediately drive the session.

Build a new broker. opts

Types

t()

@type t() :: %Mojentic.Realtime.Broker{
  config: Mojentic.Realtime.Config.t(),
  gateway: Mojentic.Realtime.OpenAIGateway.t() | module(),
  model: String.t(),
  tool_runner: module(),
  tracer: pid() | atom() | nil,
  transport_module: module()
}

Functions

connect(broker, overrides \\ [])

Open a new realtime session. Returns {:ok, session_pid} or {:error, reason}. The initial session.update is sent before returning so callers can immediately drive the session.

new(model, opts \\ [])

Build a new broker. opts:

  • :gateway — gateway struct (e.g. OpenAIGateway.new(...))
  • :config — vendor-neutral RealtimeVoiceConfig
  • :tracer — tracer pid (optional)
  • :tool_runner — runner module (default: ParallelToolRunner)
  • :transport_module — transport module (default: MintTransport)