Back to Docs
Ex

Elixir SDK

Drop-in ex_openai wrapper with Meridian base URL

The Meridian Elixir SDK wraps ex_openai with our base URL pre-configured. Use the full OpenAI-compatible API — chat completions, streaming, embeddings, and function calling — routed through Meridian's infrastructure.

mix.exs
defp deps do
  [
    {:ex_openai, "~> 1.7"},
    {:meridian, "~> 0.3"}
  ]
end
config.exs
config :meridian,
  api_key: System.get_env("MERIDIAN_API_KEY"),
  base_url: "https://api.getnimbus.net/v1",
  timeout: 30_000
Basic Completion
alias Meridian.{Chat, Models}

{:ok, response} = Chat.completion(
  model: Models.gpt_4o(),
  messages: [
    %{role: "system", content: "You are a helpful assistant."},
    %{role: "user", content: "Explain Elixir processes in one paragraph."}
  ],
  temperature: 0.7,
  max_tokens: 256
)

IO.puts(response.choices |> List.first() |> Map.get(:message) |> Map.get(:content))
Streaming
{:ok, stream} = Chat.completion_stream(
  model: Models.gpt_4o(),
  messages: [%{role: "user", content: "Write a haiku about recursion."}]
)

stream
|> Stream.each(fn chunk ->
  content = get_in(chunk, [:choices, Access.at(0), :delta, :content])
  if content, do: IO.write(content)
end)
|> Stream.run()

Environment Variable

Set MERIDIAN_API_KEY in your environment or .env file. Grab your key from the dashboard.

Meridian Elixir SDK v0.3.0ex_openai docs →