Skip to content

smelt.model

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

Visibility: Public - Stable Lua API intended 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?

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?

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

smelt.model.input_modalities

fun(): table?

Resolved input modalities for the active model as an array such as { "text", "image", "pdf" }. Config/provider metadata wins, models.dev fills missing data, and unknown models default to text only.

smelt.model.list

fun(): table

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

fun(): integer?

Resolved maximum output tokens for the active model. Returns the config override if set, otherwise falls back to the models.dev catalog value, then to the provider default. Returns nil when no limit is known.

smelt.model.preferred

fun(name: any, value: any): any

smelt.model.pricing

fun(): table?

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

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

smelt.model.status

fun(): table

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?

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

smelt.model.transport

fun(): table?

Return { provider_type, api_base, api_key_env, multimodal_tool_results } for the active model transport. api_key_env is the environment variable name, never its value.