Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

uji.provider

uji ships 22 providers, and /login and /models offer every one you add here as well.

uji.provider.add(spec)

Adds a provider, or merges spec into the provider with the same id.

FieldTypeMeaning
idstringRequired. The provider’s id.
namestringThe name /login shows. Required for a new provider.
wirestringThe request format: "openai-chat", "anthropic", "gemini", or one you added with uji.wire.add. Required for a new provider.
base_urlstringThe API root, such as "https://api.openai.com/v1". Required for a new provider.
auth_envlist of stringsEnvironment variables that may hold the API key.
modelslistModel ids, or tables with id, context, output, reasoning, cache and images. images is true or false when you know whether the model takes images.
context_windowintegerThe context size to assume for a model that does not set one.
compattableOptions for the wire, such as the name of the output limit field. On openai-chat, cache_key = true sends the session id as prompt_cache_key, which the OpenAI API uses to reuse its cache. It is on for api.openai.com. bridge_tool_images = true puts a short assistant message between tool results and the images they returned, which Mistral needs, and it is on for api.mistral.ai.
oauthtableSubscription sign-in settings. The built-in Anthropic and OpenAI providers show the format.

When the provider exists, each field you give replaces the old one, except compat, whose keys merge, and models, which merge by id.

Raises an error for an unknown field, and for a new provider without name, wire and base_url.

uji.provider.add({
  id = "litellm",
  name = "LiteLLM",
  wire = "openai-chat",
  base_url = "http://localhost:4000",
  auth_env = { "LITELLM_API_KEY" },
  models = {
    { id = "claude-sonnet-4-5", context = 200000, output = 64000, reasoning = true },
  },
})

uji.provider.add({ id = "openai", base_url = "https://proxy.example.com/v1" })

uji.provider.remove(id)

Removes a provider and returns true if it existed.

uji.provider.remove("perplexity")

uji.provider.list()

Returns one table per provider with id, name, wire, base_url and models. Each model has id, context and output.

for _, provider in ipairs(uji.provider.list()) do
  if provider.wire == "anthropic" then
    uji.notify(provider.name)
  end
end