Insurgently

Obsidian plugin· Active · beta · not yet released

Model Hub

Named roles mapped to provider and model, keys kept in secret storage, and a cost ledger with the billed cost of every call. Other plugins call it for their AI.

Beta. Model Hub is not released yet. These pages describe the build in progress.

Refusal codes

Every code a Hub error can carry, and what to do about each.

The Hub never falls back silently. Every refusal or failure is an error with a code, a message written for the user, and details. Show the message; branch on the code.

try {
  await hub.complete('mine.summarize', messages);
} catch (e) {
  const err = e as Error & { code?: string };
  if (err.code === 'aborted') return;
  new Notice(err.message);
}

Refused and failed calls are written to the ledger at a cost of zero.

Limits

CodeWhenWhat to do
over-ceilingThe call could cost more than a per-call limit. Checked before sending.Show the message. Send less, or lower maxOutputTokens.
over-budgetA monthly budget on the role or its tier is used up.Show the message. The user raises the limit or waits.
unpriced-modelThe model has no listed price, so a limit can't be checked.Show the message.

Models and providers

CodeWhenWhat to do
no-modelsThe role's tier has no models set.Show the message; it points the user to the Hub's settings.
unknown-providerA model's provider isn't set up in the Hub.Show the message.
unknown-modelThe model isn't one the Hub knows.Show the message.
provider-unavailableThe provider has no key, or its server isn't answering.Show the message.
provider-errorThe provider returned an error. details.retryable says whether trying again may help.Retry if retryable; otherwise show the message.
capability-missingThe model can't do what the call needs: tools, structured output, web search, images, embeddings. details.missing lists them.Show the message. Declare needs so this is caught on every model.
model-not-allowedThe call named a tier, model or list for one run, and the role doesn't allow it.Set allowAnyModel on roles where the user picks a model.

Your own calls

CodeWhenWhat to do
invalid-role-nameA role isn't named namespace.name in lowercase.Fix the name.
role-takenThe namespace belongs to another plugin, or you tried to change a role you don't own.Use your own namespace.
unknown-roleNo plugin has registered the role.Register before calling.
unknown-tierdeleteTier named a tier that doesn't exist.Check tiers() first.
invalid-tier-nameA tier's name is taken, empty, over 40 characters or a built-in tier's.Choose another name.
invalid-skillA registered skill has no or a bad SKILL.md, a path outside its folder, a repeated name, or mode: always.Fix the skill.
skill-takenThe skill's name belongs to another plugin or to the Hub.Choose another name.
invalid-requestThe request is malformed.Fix the call.
abortedYour signal stopped the call.Nothing; the user stopped it.

Related