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.model

These functions read and change the provider and model that uji sends turns to, the reasoning effort it asks for, and the decisions it asks a provider for. /models, /effort and /login use them.

uji.model.current()

Returns a table that describes what the next turn uses.

FieldMeaning
providerThe provider’s id, or "" before one is set.
nameThe provider’s name, or nil before one is set.
modelThe model id.
base_urlThe API root the request goes to.
effortThe reasoning effort the next turn sends, or nil when the model does not reason.
imagestrue or false when uji knows whether the model takes images, and nil when it does not.
local current = uji.model.current()
uji.notify(current.provider .. "/" .. current.model)

uji.model.use(opts)

Changes the provider, model, API root or effort, saves the choice for the next time uji starts, and fires model_changed.

FieldTypeMeaning
providerstringThe id of the provider to switch to.
modelstringThe model to use. Switching provider without a model picks the one you used last with that provider, or its first model.
base_urlstringAn API root that overrides the provider’s. "" goes back to the provider’s own. Switching provider clears it unless you give one.
effortstringOne of off, minimal, low, medium, high, xhigh and max. uji saves it, and each turn uses the nearest effort the current model accepts, so medium on a model that offers only low and high sends high.

Fields you leave out stay as they are. Raises an error for an unknown provider or effort.

uji.model.use({ provider = "anthropic", model = "claude-sonnet-4-5", effort = "high" })

uji.model.efforts()

Returns the reasoning efforts the current model accepts, from the least thinking to the most, such as { "off", "low", "medium", "high", "xhigh", "max" }. A model that does not reason gives an empty list. The model’s efforts in uji.provider.add set the list, and the provider’s API supplies it for a model without one.

local efforts = uji.model.efforts()

uji.model.decide(opts)

Asks a decision model how likely yes is the answer to each question about one state, from 0 to 1. Returns { probabilities, calibrated }, with a number for each question it could answer, or nil and a { kind, message } failure. uji ships the jev provider, which answers decisions itself and gives calibrated true; every other provider is asked over chat, as the model in use, and gives false.

FieldTypeMeaning
statestring or tableWhat the questions are about. A list of strings joins as paragraphs.
questionstableInstructions per question id, each a string.
providerstringThe provider to ask. The provider in use by default.
modelstringThe model to ask, when the provider answers decisions itself — its first model by default. Over chat, the model in use answers.
timeoutnumberSeconds for the whole answer, including the provider’s own retries.