llm-router::ui-content
functionServe the llm-router worker's injected console UI assets (content function for its console:script / console:style triggers).
pathstring*required
The asset path from the trigger config (e.g. `state/page.js`).
contentstring*required
The asset source, verbatim.
content_typestring*required
MIME type the console should serve the asset with.
Abort an in-flight router::chat/complete by request_id; reports whether a live request was cancelled.
request_idstring*required
Stream a chat completion: route {model, provider?} to a provider, relay assistant frames to writer_ref, and return the terminal response.
max_output_tokensinteger· uint64min 0
session_idstring
Stable conversation identity, forwarded separately from the per-turn request id.
writer_refall of*required
The caller's write channel (direction "write"); frames are relayed here.
all of (1)
variant 1
access_keystring*required
channel_idstring*required
directionstring*requiredenum: read, write
errorany of
any of (2)
variant 1
detailstring
Provider/transport diagnostics for logs and expandable UI details. `message` remains the stable, user-facing explanation.
kindany of
… expand 2 nestedcollapse
any of (2)
variant 1
valuestringenum: auth_expired, rate_limited, context_overflow, transient, permanent
stop_reasonany of
any of (2)
variant 1
valuestringenum: end, length, function_call, aborted, error
usageany of
any of (2)
variant 1
cache_readinteger· uint64min 0
cache_writeinteger· uint64min 0
inputinteger· uint64min 0
outputinteger· uint64min 0
reasoninginteger· uint64min 0
Non-streaming convenience over router::chat: run the turn on an internal channel and return the final assistant message + usage.
max_output_tokensinteger· uint64min 0
session_idstring
Stable conversation identity, forwarded separately from the per-turn request id.
messageobject*required
contentone of[]*required
one of (6)
variant 1
typestring*requiredenum: text
variant 2
typestring*requiredenum: image
variant 3
typestring*requiredenum: thinking
variant 4
typestring*requiredenum: redacted_thinking
variant 5
argumentsunknown*required
function_idstring*required
typestring*requiredenum: function_call
variant 6
contentunknown[]*required
function_call_idstring*required
typestring*requiredenum: function_result
error_kindany of
any of (2)
variant 1
valuestringenum: auth_expired, rate_limited, context_overflow, transient, permanent
rolestring*requiredenum: assistant
stop_reasonstring*requiredenum: end, length, function_call, aborted, error
timestampinteger· int64*required
usageany of
any of (2)
variant 1
cache_readinteger· uint64min 0
cache_writeinteger· uint64min 0
inputinteger· uint64min 0
outputinteger· uint64min 0
reasoninginteger· uint64min 0
usageany of
any of (2)
variant 1
cache_readinteger· uint64min 0
cache_writeinteger· uint64min 0
inputinteger· uint64min 0
outputinteger· uint64min 0
reasoninginteger· uint64min 0
router::count_tokens
functionCount prompt tokens for {model, provider?, system_prompt?, tools?, messages} through the resolved provider's provider::<id>::count_tokens surface; never runs the model and costs nothing.
messagesany of[]*required
Wire agent messages, the same shape `router::chat` accepts. Must be non-empty.
any of (4)
variant 1
contentone of[]*required
… expand 6 nestedcollapse
one of (6)
variant 1
typestring*requiredenum: text
variant 2
typestring*requiredenum: image
variant 3
typestring*requiredenum: thinking
variant 4
typestring*requiredenum: redacted_thinking
variant 5
argumentsunknown*required
function_idstring*required
typestring*requiredenum: function_call
variant 6
contentunknown[]*required
function_call_idstring*required
typestring*requiredenum: function_result
error_kindany of
… expand 2 nestedcollapse
any of (2)
variant 1
valuestringenum: auth_expired, rate_limited, context_overflow, transient, permanent
rolestring*requiredenum: assistant
stop_reasonstring*requiredenum: end, length, function_call, aborted, error
timestampinteger· int64*required
usageany of
… expand 2 nestedcollapse
any of (2)
variant 1
cache_readinteger· uint64min 0
cache_writeinteger· uint64min 0
inputinteger· uint64min 0
outputinteger· uint64min 0
reasoninginteger· uint64min 0
variant 2
contentone of[]*required
… expand 6 nestedcollapse
one of (6)
variant 1
typestring*requiredenum: text
variant 2
typestring*requiredenum: image
variant 3
typestring*requiredenum: thinking
variant 4
typestring*requiredenum: redacted_thinking
variant 5
argumentsunknown*required
function_idstring*required
typestring*requiredenum: function_call
variant 6
contentunknown[]*required
function_call_idstring*required
typestring*requiredenum: function_result
function_call_idstring*required
function_idstring*required
rolestring*requiredenum: function_result
timestampinteger· int64*required
variant 3
contentone of[]*required
… expand 6 nestedcollapse
one of (6)
variant 1
typestring*requiredenum: text
variant 2
typestring*requiredenum: image
variant 3
typestring*requiredenum: thinking
variant 4
typestring*requiredenum: redacted_thinking
variant 5
argumentsunknown*required
function_idstring*required
typestring*requiredenum: function_call
variant 6
contentunknown[]*required
function_call_idstring*required
typestring*requiredenum: function_result
custom_typestring*required
rolestring*requiredenum: custom
timestampinteger· int64*required
variant 4
contentone of[]*required
… expand 6 nestedcollapse
one of (6)
variant 1
typestring*requiredenum: text
variant 2
typestring*requiredenum: image
variant 3
typestring*requiredenum: thinking
variant 4
typestring*requiredenum: redacted_thinking
variant 5
argumentsunknown*required
function_idstring*required
typestring*requiredenum: function_call
variant 6
contentunknown[]*required
function_call_idstring*required
typestring*requiredenum: function_result
rolestring*requiredenum: user
Single-variant role tags: exact-match on deserialize, correct wire string on serialize, and they let `AgentMessage` be an untagged union.
timestampinteger· int64*required
modelstring
Model id the prompt targets; routes exactly like `router::chat` and selects the provider's tokenizer. Optional only when `provider` pins the destination.
providerstring
Pin an explicit provider, bypassing heuristics (optional).
system_promptstring
System prompt counted as part of the request (optional).
toolsobject[]
Function invocation schemas the turn would carry; their serialized schemas count toward the total (optional).
descriptionstring*required
parametersunknown*required
estimatorstring*required
`provider` when a provider metering API produced the count, `tiktoken` when a local tokenizer estimated it.
tokensinteger· uint64*requiredmin 0
Prompt tokens the provider counted for the assembled request.
Batch text embeddings through a provider's provider::<id>::embed surface. Names a provider or discovers the first embed-capable one from the live registry; one vector per input, order preserved.
inputstring[]*required
Texts to embed, one vector returned per input, order preserved.
modelstring
Embedding model id; the provider's default when omitted.
providerstring
Provider id (e.g. `openai`); the first embed-capable provider in the live registry when omitted.
embeddingsnumber[][]*required
One embedding per input, in input order.
router::models::budget
functionResolve the effective model output budget using the same precedence as router::chat.
idstring
Model id to budget.
max_output_tokensinteger· uint64min 0
Optional caller-requested output budget. When absent, the same provider and router defaults used by `router::chat` apply.
providerstring
Provider id that owns the model. Empty resolves an unambiguous model id.
any of (2)
variant 1
effective_max_output_tokensinteger· uint64*requiredmin 0
modelobject*required
The capability record (README § Model descriptor).
context_windowinteger· uint64*requiredmin 0
input_limitinteger· uint64min 0
max_output_tokensinteger· uint64*requiredmin 0
pricingany of
… expand 2 nestedcollapse
any of (2)
variant 1
cache_writenumber· double
reasoning_effortsobject[]
… expand 2 nestedcollapse
supports_structured_outputboolean
router::models::get
functionRead one catalog model by {provider, id}; null when the model is not registered.
idstring
Model id to look up.
providerstring
Provider id that owns the model.
any of (2)
variant 1
modelobject*required
The capability record (README § Model descriptor).
context_windowinteger· uint64*requiredmin 0
input_limitinteger· uint64min 0
max_output_tokensinteger· uint64*requiredmin 0
pricingany of
… expand 2 nestedcollapse
any of (2)
variant 1
cache_writenumber· double
reasoning_effortsobject[]
… expand 2 nestedcollapse
supports_structured_outputboolean
router::models::list
functionList catalog models, optionally filtered by provider and/or a capability flag.
capabilitystring
Keep only models that support this capability flag (optional).
providerstring
Filter to a single provider id (optional).
modelsobject[]*required
context_windowinteger· uint64*requiredmin 0
input_limitinteger· uint64min 0
max_output_tokensinteger· uint64*requiredmin 0
pricingany of
any of (2)
variant 1
cache_writenumber· double
reasoning_effortsobject[]
supports_structured_outputboolean
Replace a provider's catalog slice — the only catalog write path (token-gated).
modelsobject[]
The full replacement set of models for this provider.
context_windowinteger· uint64*requiredmin 0
input_limitinteger· uint64min 0
max_output_tokensinteger· uint64*requiredmin 0
pricingany of
any of (2)
variant 1
cache_writenumber· double
reasoning_effortsobject[]
supports_structured_outputboolean
providerstring
Provider whose catalog slice is being replaced.
tokenstring
Registration token gating the write (optional).
countinteger· uint*requiredmin 0
router::models::supports
functionCheck whether a model supports a capability flag (fails open for unknown models).
capabilitystring
Capability flag to check (e.g. `structured_output`, `vision`).
idstring
Model id to check.
providerstring
Provider id that owns the model.
supportedboolean*required
Internal: reactively reload the in-memory configuration snapshot and fan out provider model discovery after configuration changes.
idstring
Configuration id that changed (advisory).
Internal: a worker's function registrations changed — re-discover live providers and nudge them to re-declare, so a provider that reconnected is resolvable again without waiting for its own catalog timer.
eventstring
Engine event tag (advisory).
worker_idstring
Worker whose registered functions changed (advisory).
router::provider::list
functionList registered providers with their configured/available status.
providersobject[]*required
availableboolean*required
configuredboolean*required
credential_env_varstring
Environment variable declared by API-key providers. `None` means the provider owns authentication (OAuth, local app login, device flow).
display_namestring*required
icon_svgstring
The provider's mark as inline SVG, copied from its declaration. Absent when the provider declared none.
supports_model_listingboolean*required
Provider self-declaration at attach time (token-gated upsert); composes the configuration entry schema and reconciles static models.
defaultsany of
any of (2)
variant 1
max_tokensinteger· uint64min 0
icon_svgstring
The provider's mark: one self-contained `<svg>` document, monochrome, drawn with a square `viewBox` and no fixed size. Consoles paint it as a `currentColor` mask next to the provider's models, so colour and scripts are ignored. Keep it under [`PROVIDER_ICON_SVG_MAX_BYTES`]; the router drops anything larger or not starting with `<svg`.
modelsobject[]
context_windowinteger· uint64*requiredmin 0
input_limitinteger· uint64min 0
max_output_tokensinteger· uint64*requiredmin 0
pricingany of
any of (2)
variant 1
cache_writenumber· double
reasoning_effortsobject[]
supports_structured_outputboolean
supports_model_listingboolean
tokenstring
Registration token proving ownership on re-register (omit on first declare).
registration_tokenstring*required
Resolve a provider's effective credential + api_url + max_tokens (token-gated).
idstring
Provider id to resolve credentials/config for.
tokenstring
Registration token gating the resolve (optional).
configuredboolean*required
credentialany of
any of (2)
variant 1
one of (2)
variant 1
typestring*requiredenum: api_key
variant 2
access_tokenstring*required
typestring*requiredenum: oauth
max_tokensinteger· uint64min 0
sourcestring*requiredenum: config, env, none
OAuth write-back: store a provider credential in the configuration entry under the entry write lock (token-gated).
credentialunknown
The credential object to store (provider-specific shape).
idstring
Provider id whose credential slice is being written.
tokenstring
Registration token gating the write (optional).
Read-only routing preview: resolve {model, provider?} to the chosen provider + ordered candidates without streaming.
modelstring
Model id to route.
providerstring
Pin an explicit provider, bypassing heuristics (optional).
candidatesstring[]*required