Skip to content

smelt.model

Tier: Mixed - Contains both Host and UiHost functions; each function below lists its exact tier.

Classification: Supported - Primary alpha facade for user config and plugins.

Model selector. smelt.model.current() reads the active model key, smelt.model.set(v) switches, and smelt.model.list() returns the available models.

smelt.model.capabilities

fun(): table?

Tier: UiHost - Requires a terminal UI; calling these from headless mode raises.

Resolved capabilities for the active model/provider as { input_modalities, supports_image, supports_pdf, supports_video, supports_reasoning, tool_calling, max_tokens, context_window, transport = { ... }, sources = { ... } }.

smelt.model.current

fun(): string?

Tier: UiHost - Requires a terminal UI; calling these from headless mode raises.

Return the active model key, or nil when no active model exists.

smelt.model.list

fun(): table

Tier: Host - Available in every runtime, including headless mode.

Return an array of { key, name, display_name?, provider, api_base, provider_type } records for every model the active config can switch to.

smelt.model.preferred

fun(name: string, ...: string?): string?

Tier: Host - Available in every runtime, including headless mode.

Read or update a named model preference. With only name, returns the stored model key or nil. Passing a second argument stores that model key; passing nil explicitly clears it. Preferences survive Lua reloads through smelt.state.persistent("model_preferred").

smelt.model.pricing

fun(): table?

Tier: UiHost - Requires a terminal UI; calling these from headless mode raises.

Resolved pricing for the active model as { input, output, cache_read, cache_write, source }. source is one of "config override", "models.dev", or "none". Prices are USD per 1M tokens.

smelt.model.set

fun(name: string): nil

Tier: UiHost - Requires a terminal UI; calling these from headless mode raises.

Switch the active model by key. Errors when the name cannot be resolved.

smelt.model.status

fun(): table

Tier: UiHost - Requires a terminal UI; calling these from headless mode raises.

Return { current, requested, availability, reason?, providers } for model selection. availability is available, stale_catalog, unavailable, pending, or none; unavailable reasons are stable snake-case strings. Each managed provider reports sanitized authenticated, status, error, request_id, auth_revision, and desired_revision fields.

smelt.model.supports_input

fun(modality: string): boolean?

Tier: UiHost - Requires a terminal UI; calling these from headless mode raises.

Return whether the active model supports the named input modality, for example image or pdf.