Mojentic.Realtime.OpenAIGateway (Mojentic v1.5.0)

Copy Markdown View Source

Gateway against OpenAI's Realtime API over WebSocket.

Each open/3 call provisions a new transport process. The returned pid is the only stateful surface; subscribers receive {:realtime_message, parsed} and {:realtime_close, reason} tuples.

Summary

Functions

Construct a new gateway. If :api_key is omitted, falls back to the OPENAI_API_KEY environment variable.

Pure helper to validate and parse a server event payload. Re-exported so tests can drive the gateway with scripted messages.

Types

t()

@type t() :: %Mojentic.Realtime.OpenAIGateway{
  api_key: String.t() | nil,
  base_url: String.t(),
  transport: module()
}

Functions

new(opts \\ [])

Construct a new gateway. If :api_key is omitted, falls back to the OPENAI_API_KEY environment variable.

open(gateway, model, config, correlation_id)

parse_message(map)

Pure helper to validate and parse a server event payload. Re-exported so tests can drive the gateway with scripted messages.