Immutable handle carrying the configuration used by every LiveKit call.
A client is plain data: it starts no process, holds no connection, and can be freely shared between processes or stored in application state.
iex> {:ok, client} = LiveKit.Client.new(
...> url: "https://example.livekit.cloud",
...> api_key: "api-key",
...> api_secret: "api-secret"
...> )
iex> client.config.url
"https://example.livekit.cloud"Injecting HTTP options
:request_options are merged into every Req request made by
LiveKit.Twirp. This is the seam used by tests to route requests to a local
plug instead of the network:
LiveKit.Client.new!(
url: "http://localhost:7880",
api_key: "devkey",
api_secret: "secret",
request_options: [plug: {Req.Test, MyStub}]
)
Summary
Functions
Builds a client from configuration options.
Same as new/1 but raises LiveKit.Error on invalid options.
Types
@type t() :: %LiveKit.Client{config: LiveKit.Config.t(), request_options: keyword()}
Functions
@spec new(keyword()) :: {:ok, t()} | {:error, LiveKit.Error.t()}
Builds a client from configuration options.
Accepts every option supported by LiveKit.Config.new/1, plus:
:request_options- keyword list merged into eachReqrequest.
Examples
iex> {:ok, client} = LiveKit.Client.new(
...> url: "https://example.livekit.cloud/",
...> api_key: "api-key",
...> api_secret: "api-secret"
...> )
iex> client.request_options
[]
iex> {:error, error} = LiveKit.Client.new(url: "https://example.livekit.cloud", api_key: "k")
iex> error.type
:configuration
Same as new/1 but raises LiveKit.Error on invalid options.
Examples
iex> client = LiveKit.Client.new!(url: "https://example.livekit.cloud", api_key: "k", api_secret: "s")
iex> client.config.api_key
"k"