Inference settings
@happyvertical/smrt-inference ships an inference settings screen (#4754):
InferenceSettingsPanel on ./svelte for the browser, and
InferenceSettingsService on ./server for the load functions and actions
behind it. The panel is presentational; your host decides who may see and
change what.
Where each setting lives
| Setting | Store | Written by |
|---|---|---|
| API keys | smrt-secrets, as the #4756 inference.provider-config secret | the host's onSaveKey action: bindInferenceKey(), then inferenceProviderConfigFromKey() written through the user resolver's write() |
| Mode, provider, base URL, model, default tier (per user, tenant default) | smrt-preferences kind inference | createInferencePreferences(store).write() |
Tier bindings, auto's default tier, aliases, fusions (app and tenant) | _smrt_inference_overrides | InferenceSettingsService set methods (authorizer-gated) |
| Transcripts on/off, sample rate, byte cap (app only) | _smrt_inference_overrides, app row transcripts | InferenceSettingsService.setTranscriptSettings() (authorizer-gated) |
The split is enforced by the API shape. The panel hands a key out only
through onSaveKey({ provider, key }) and never receives one back; it shows
"set" or "not set". Binding rows and preference payloads refuse any member
that looks like a credential. A key is bound to the origin of the endpoint
it was entered for, and the server sends it only to that origin.
Where the master key comes from
smrt-secrets seals the key under an application master key. A server sets
SMRT_SECRET_MASTER_KEY; the variable always wins. A local or desktop app
has no environment for it, so the local runtime creates the key on first run
and keeps it in its vault key store (an owner-only file store, or the desktop
wrapper's OS keychain). The owner never sees or types it, and it is never
generated outside the local profile. Pass the runtime's provider when you
build the secret store:
const secrets = await SecretService.create({
db: await runtime.database(),
masterKeyProvider: () => runtime.secretMasterKey(), // null off the local profile
});
const resolver = createUserInferenceResolver({ secrets, fallback });
See the app-runtime README, "Secrets master key".
Minimal SvelteKit wiring
// +page.server.ts
import {
bindInferenceKey,
inferenceProviderConfigFromKey,
createInferencePreferences,
InferenceSettingsService,
} from '@happyvertical/smrt-inference/server';
export async function load({ locals }) {
const settings = await InferenceSettingsService.create({ db: locals.db });
const prefs = await createInferencePreferences(locals.preferenceStore).read();
return {
defaults: { ...prefs.choices, keySet: await locals.hasInferenceKey() },
providers: settings.listProviderOptions(),
tiers: await settings.listInferenceSettings({ tenantId: locals.tenantId }),
};
}
export const actions = {
saveKey: async ({ request, locals }) => {
// The panel's onSaveKey change: { provider, key, preset?, baseUrl? }.
// Bind to the endpoint the key was entered for, not to saved choices.
const change = await request.json();
const record = bindInferenceKey(change);
// Store it once, as the #4756 provider config the user resolver reads
// (`inference.provider-config`, user level; 'tenant' for a tenant key).
await locals.inferenceResolver.write(
'user',
inferenceProviderConfigFromKey(record, { model: change.model }),
);
},
};
<InferenceSettingsPanel {...data} onSaveKey={saveKey} onSaveDefaults={saveChoices} />
The generated app does this with createInferenceSettingsHost() and
createInferenceSettingsController() from @happyvertical/smrt-inference/server
(the secret store with masterKeyProvider above, the user resolver, the
bind, store and "is it set" steps behind saveKey), wired in
src/lib/server/settings.ts; the app shell uses the same two. Its saveKey
action is owner-only: it refuses a session without
inference.customize before reading the body, writes the key at the user
level, and takes a preset key's model from the owner's saved default
(defaults.model). keySet is read from the resolver's redacted view, so the
panel shows "set" only after a key is really stored, and a store that cannot
be read shows "not set" rather than failing the page.
Register the preference kind and its permissions once at startup:
registerPreferenceKind(inferencePreferenceKind) and
registerPermissionDefinitions([...INFERENCE_PERMISSION_DEFINITIONS]).
Tenant allow-list
A tenant may bind a tier only to a target on that tier's allow-list. The list
is stored on the app row (setTenantAllowList, e.g. ['alias:local', 'model:openai/*']). With no list, tenants can bind nothing. The service's
tenantTargetPolicy option is the code half of the list, for example a cap
on the hosted tier a plan allows. Both halves are checked on every tenant
write and again on every read, so narrowing either one stops an existing
tenant binding from taking effect. Aliases and fusions are defined at the
app scope only, so a tenant cannot change what an allow-listed name means.
Transcripts
Pass transcripts: await settings.getTranscriptSettings() and the panel
shows the app's transcript setting under Advanced: on or off, the success
sample rate, the byte cap, the retention window and which level set it.
Tenants cannot override it, so it is read-only unless the host also passes
appEditable (a platform admin) and onSaveTranscripts. Wire that callback
to an action that calls setTranscriptSettings({ settings }); it always
writes the app row (null reverts to config), asks your authorizer with
{ binding: 'transcripts', scopeType: 'app' }, and takes effect in that
process at once. SMRT_INFERENCE_TRANSCRIPTS still wins over the stored
value. Other processes pick it up through the override resolver within its
cache window; a worker that does not use the resolver calls
loadInferenceTranscriptSettings({ db }) at startup. Retention is the
sweep's retention.aiTranscripts.maxAgeDays and is shown read-only.
In the Usage tab, build the report with
settings.usage({ by, tenantId, transcripts: true }) to show a transcript
count per row, and pass transcriptHref(filters) to link each count and
evaluation label to your own transcript page. filters holds promptKey
and templateHash (when the report is grouped by prompt or template),
label, since and until, which map onto listAiTranscripts(). The
panel never shows transcript text. When transcripts are off, the tab says
so in one line.
<InferenceSettingsPanel
{...data}
appEditable={data.isPlatformAdmin}
onSaveTranscripts={saveTranscripts}
transcriptHref={(f) => `/admin/transcripts?${new URLSearchParams(f)}`}
/>
Applying the bindings
Compose createInferenceOverrideResolver({ db }) as the per-user
resolver's fallback, so stored user and tenant keys still win and the
chain validation of @happyvertical/smrt-inference stays outermost:
registerUserInferenceResolver(
createUserInferenceResolver({ secrets, fallback: createInferenceOverrideResolver({ db }) }),
);
A bare setInferenceResolver() would drop that validation. For each call
the override resolver uses the stored row, or defers to config when nothing
is stored. Run smrt db:migrate to create _smrt_inference_overrides; the
runtime never creates the table. Fusions saved as app rows reach the
executor through the same resolver: an app row replaces a config or
defineFusion() fusion of the same name, and listInferenceFusions() marks
what each entry replaces (shadows) and why the executor would refuse it
(issues, seat prompt keys included). The whole picture (tiers, fallback,
fusions, modes, hosted inference, usage) is in
Inference tiers, bindings and usage.
Which model answers on a local AI or ChatGPT plan
An API key binds tiers through the rows above. Claude Code, Codex and a
ChatGPT plan sign-in have no stored binding: each tier binds to the engine's
own models, ranked strongest first (engineTierModel in
@happyvertical/smrt-inference, #5005):
| Tier | Claude Code | Codex | ChatGPT plan |
|---|---|---|---|
best, great | fable | gpt-6-astra | the strongest ranked model the account offers |
good | opus | gpt-6.1-sol | the next strongest offered |
cheap | sonnet | gpt-6-luna | the lowest ranked offered |
auto | the app's default tier (else good), then as above | same | same |
OpenAI ranks: gpt-6-astra > gpt-6.1-sol > gpt-6.1-terra > gpt-6-luna
(reviewed 2026-11-12); an unranked model is never chosen. The assistant asks
for best, so it answers with fable, gpt-6-astra or the account's
strongest model. When a plan refuses that model before any output, the turn
steps once down the same order (fable → opus → sonnet) and remembers the
step for that connection.
Reasoning effort follows the caller, then the prompt's ai.effort, then the
tier binding's params.reasoning.effort, then the engine's default; nothing
else defaults it. Claude Code takes --effort, Codex
model_reasoning_effort (max is sent as xhigh), an API call
reasoning.effort. A ChatGPT plan records the effort but does not send it:
its provider rejects reasoning options.
What changed (#5005): owner "work profiles" are gone. Which model answers is the tier binding's choice; limits are the budget of the assistant's turn or of the workflow definition; saved profile preferences are dropped. An owner who had picked a custom model or effort per profile now gets the binding's model and the engine's default effort.
Assistant settings
The panel's Assistant section (assistant and onSaveAssistant props) holds
the owner's ordinary assistant settings, stored by smrt-preferences' kind
assistant-settings. Each is on unless turned off:
| Setting | What it does |
|---|---|
escalateToWorkflow | A chat request for a tool limited to workflow runs (structural changes) is handed to a workflow run; off, chat refuses it. |
previewBeforeApply | A workflow run shows its proposed changes before applying them. |
requireRemovalApproval | Chat asks the owner before deleting or removing. |
protectLocalCli | Claude Code and Codex run in the app's protected tool setup. Turning it off needs an explicit confirmation. |
Only the owner, in a browser session, may change them; no assistant or MCP tool can.
Sign in with ChatGPT (local apps)
A local app (one person, on their own computer) can let its owner use their
own ChatGPT plan instead of an API key, through OpenAI's official flow. It is a
preview for open source apps: read OpenAI's
preview limitations
before offering it. @happyvertical/smrt-inference/server ships the pieces;
@happyvertical/ai (0.111.10 or later) is the chatgpt-plan provider and
@happyvertical/auth/local runs the sign-in.
import {
createChatGPTPlanConnection,
createInferenceSettingsHost,
} from '@happyvertical/smrt-inference/server';
const chatgpt = createChatGPTPlanConnection({
appName: 'My app', // shown on OpenAI's page
credentialsPath: join(privateStateDir, 'chatgpt', 'chatgpt.json'),
});
const host = createInferenceSettingsHost({
database, overrides,
chatgptPlan: {
connection: chatgpt,
// Opt in per call. There is no default: a tier is never moved to the plan.
appliesTo: (request) => request.className === 'MyAssistant',
},
});
host.install();
- Sign-in.
chatgpt.start()returns the authorization URL (checked to be https onauth.openai.com); open it in the system browser. The SDK's loopback listener (127.0.0.1, PKCE, dynamic client registration, OIDC validation) receives the callback.status()reportssignedIn,signingIn, an account label and a fixed-vocabulary error;signOut()clears the local credentials and asks OpenAI to revoke them;models()lists the account's models from the plan's catalog (the first is the default). - Credentials. The SDK keeps them in one owner-only file at
credentialsPath(directory0700, file0600, atomic writes). Pass a path in the app's private state area, outside any project. smrt never reads that file, and never logs, returns or copies a token: the provider is handed a{ accessToken(clientId) }handle and nothing else. - Opt in, never fall back. The resolver composes outside the user resolver
and applies only to calls whose
appliesToreturns true. Such a call with nobody signed in isunavailable: 'unconfigured'; it does not run on an API key. Every other call resolves as before. - Calling it. Build the client with
chatgpt.clientOptions({ model, toolNamespace })and usechat()(withonProgressfor text). The preview rejectsmaxTokens, sampling options,user, response formats, reasoning options, a forced single-functiontoolChoice, non-function tools and image tool results withsubscription_sharing_unsupported_capability;stream()rejects tools.classifyChatGPTPlanFailure()names a failureusage_limit,session_revoked,workspace,unavailableorunsupported_capabilityfrom the SDK's class and code. - Claude. There is no equivalent for Claude: its subscription is not
offered by this package (
claude-clistays refused by the app shell).