smelt.provider¶
Tier: Host — Available in every runtime, including headless mode.
List built-in model providers and register custom ones. Headless-safe.
smelt.provider.list¶
Return every registered provider as an array of tables. Each entry has name, type, api_base, api_key_env, and a models array.
smelt.provider.middleware¶
Types: smelt.Reg
Register provider middleware. mw is a table of { on_request = fn?, on_response = fn? }:
on_request(messages)— runs just before the engine calls the provider.messagesis the full conversation history (an array of{ role, content, tool_calls? }rows including the system prompt at index 1). Return a replacement array to mutate it; any other return value leaves the history untouched.on_response(message)— runs after the assistant message is fully assembled but before it's appended to history.messageis the same{ role = "assistant", content?, tool_calls? }shape used everywhere else. Return a replacement table to mutate it; any other return leaves it as-is.
Hooks fire in registration order. Each hook sees the previous hook's replacement. Returns a Reg whose :remove() drops this middleware.
For streaming observation use smelt.cell("stream_delta"):subscribe( ...) — synchronous mutation of mid-stream tokens isn't safe because the parser owns the partial state.
smelt.provider.register¶
Types: smelt.provider.Config, smelt.Reg
Declare a provider named name. Re-registering replaces the previous entry of the same name. Returns a Reg whose :remove() drops the provider.