LLM interaction utilities for structured and unstructured outputs.
SVAR = Structured Validated Automated Reasoning
Scope: structured LLM output + provider routing. Main functions:
ask! - Structured output using the spec DSLask-code! - native tool-calling completion (the model acts via tools)models! - Fetch available models from the LLM APIRe-exports the spec DSL (field, spec, str->data, str->data-with-spec,
data->str, validate-data, spec->prompt, build-ref-registry) and
make-router so users can require only this namespace.
Configuration: LLM calls route automatically via the router.
Example: (ask! router {:spec my-spec :messages [(system "Help the user.") (user "What is 2+2?")] :model "gpt-4o"})
LLM interaction utilities for structured and unstructured outputs.
SVAR = Structured Validated Automated Reasoning
Scope: structured LLM output + provider routing. Main functions:
- `ask!` - Structured output using the spec DSL
- `ask-code!` - native tool-calling completion (the model acts via tools)
- `models!` - Fetch available models from the LLM API
Re-exports the spec DSL (`field`, `spec`, `str->data`, `str->data-with-spec`,
`data->str`, `validate-data`, `spec->prompt`, `build-ref-registry`) and
`make-router` so users can require only this namespace.
Configuration:
LLM calls route automatically via the router.
Example:
(ask! router {:spec my-spec
:messages [(system "Help the user.")
(user "What is 2+2?")]
:model "gpt-4o"})Asks the LLM and returns structured Clojure data with token usage and cost. With an explicit session, appends one native completion turn.
Asks the LLM and returns structured Clojure data with token usage and cost. With an explicit session, appends one native completion turn.
Native tool-calling completion. Sibling of ask! (structured :spec).
The model takes action by calling a :tool; no tool call ⇒ its text is the
final answer (:stop-reason :end). Returns {:stop-reason :tool-calls|:end
:tool-calls :content :assistant-message :reasoning :tokens :cost :duration-ms
:rate-limit}. :rate-limit (when the provider sent quota headers) carries
{:resets-at-ms <epoch-ms> :remaining :limit :windows} — the effective reset
clock a status view can render.
Native tool-calling completion. Sibling of `ask!` (structured `:spec`).
The model takes action by calling a `:tool`; no tool call ⇒ its text is the
final answer (`:stop-reason :end`). Returns {:stop-reason :tool-calls|:end
:tool-calls :content :assistant-message :reasoning :tokens :cost :duration-ms
:rate-limit}. `:rate-limit` (when the provider sent quota headers) carries
`{:resets-at-ms <epoch-ms> :remaining :limit :windows}` — the effective reset
clock a status view can render.Builds a registry of referenced specs.
Builds a registry of referenced specs.
Wraps text in a cacheable content block. Anthropic emits cache_control.
GPT-5.6+ Responses emits explicit prompt-cache breakpoints, including a
rolling prior-turn boundary; older OpenAI-compatible styles strip the marker.
Wraps text in a cacheable content block. Anthropic emits `cache_control`. GPT-5.6+ Responses emits explicit prompt-cache breakpoints, including a rolling prior-turn boundary; older OpenAI-compatible styles strip the marker.
Cardinality: Vector of values.
Cardinality: Vector of values.
Closes an explicit LLM session. Idempotent.
Closes an explicit LLM session. Idempotent.
Serializes Clojure data to LLM-compatible string.
Serializes Clojure data to LLM-compatible string.
Field option: Human-readable field description.
Field option: Human-readable field description.
Creates a field definition for a spec.
Creates a field definition for a spec.
Creates an image attachment for use with user messages.
Creates an image attachment for use with `user` messages.
Spec option: Namespace prefix to add to keys during parsing.
Spec option: Namespace prefix to add to keys during parsing.
Creates a router from a vector of provider maps.
Creates a router from a vector of provider maps.
Fetches available models from the LLM API.
Fetches available models from the LLM API.
Field option: Field name as Datomic-style keyword.
Field option: Field name as Datomic-style keyword.
Coerce any accepted spelling to canonical :low|:balanced|:deep. Also accepts :low/:medium/:high aliases for OpenAI-style migrations.
Coerce any accepted spelling to canonical :low|:balanced|:deep. Also accepts :low/:medium/:high aliases for OpenAI-style migrations.
Opens a sequential LLM session. OpenAI Codex uses a persistent Responses
WebSocket and server continuation; close it with close-session! or
with-open.
Opens a sequential LLM session. OpenAI Codex uses a persistent Responses WebSocket and server continuation; close it with `close-session!` or `with-open`.
Sane default base-url svar knows for a provider id (plan-tier aware). Consumers (e.g. vis provider extensions) use it as the preset default and override only for local/custom endpoints.
Sane default base-url svar knows for a provider id (plan-tier aware). Consumers (e.g. vis provider extensions) use it as the preset default and override only for local/custom endpoints.
Sane default model NAMES (vec of strings) svar curates for a provider id
(plan-tier aware). The single source of truth — consumers use it as their
:default-models and override only for a different curated set.
Sane default model NAMES (vec of strings) svar curates for a provider id (plan-tier aware). The single source of truth — consumers use it as their `:default-models` and override only for a different curated set.
Translate abstract level → provider-specific extra-body map (or nil). Returns nil for non-reasoning models; callers can merge the result into their own extra-body.
Translate abstract level → provider-specific extra-body map (or nil). Returns nil for non-reasoning models; callers can merge the result into their own extra-body.
Abstract reasoning depths translated per provider api-style.
See com.blockether.svar.internal.router/REASONING_LEVELS.
Abstract reasoning depths translated per provider api-style. See `com.blockether.svar.internal.router/REASONING_LEVELS`.
Field option: Whether field is required (default: true).
Field option: Whether field is required (default: true).
Resets the router's token/cost budget counters to zero.
Resets the router's token/cost budget counters to zero.
Manually resets a provider's circuit breaker to :closed.
Manually resets a provider's circuit breaker to :closed.
Resolve exact provider-native high|max support and wire evidence.
No abstract reasoning aliases or automatic translations are applied.
Resolve exact provider-native `high|max` support and wire evidence. No abstract reasoning aliases or automatic translations are applied.
Returns cumulative + windowed stats for the router.
Returns cumulative + windowed stats for the router.
Returns an explicit session's canonical replay history.
Returns an explicit session's canonical replay history.
Creates a spec definition from field definitions.
Creates a spec definition from field definitions.
Generates LLM prompt from a spec.
Generates LLM prompt from a spec.
Parses LLM response string to Clojure data.
Parses LLM response string to Clojure data.
Parses LLM response with spec validation.
Parses LLM response with spec validation.
Field option: Reference target for :spec.type/ref fields.
Field option: Reference target for :spec.type/ref fields.
Type: Fixed-size double vector (1 element).
Type: Fixed-size double vector (1 element).
Type: Fixed-size double vector (10 elements).
Type: Fixed-size double vector (10 elements).
Type: Fixed-size double vector (11 elements).
Type: Fixed-size double vector (11 elements).
Type: Fixed-size double vector (12 elements).
Type: Fixed-size double vector (12 elements).
Type: Fixed-size double vector (2 elements).
Type: Fixed-size double vector (2 elements).
Type: Fixed-size double vector (3 elements).
Type: Fixed-size double vector (3 elements).
Type: Fixed-size double vector (4 elements).
Type: Fixed-size double vector (4 elements).
Type: Fixed-size double vector (5 elements).
Type: Fixed-size double vector (5 elements).
Type: Fixed-size double vector (6 elements).
Type: Fixed-size double vector (6 elements).
Type: Fixed-size double vector (7 elements).
Type: Fixed-size double vector (7 elements).
Type: Fixed-size double vector (8 elements).
Type: Fixed-size double vector (8 elements).
Type: Fixed-size double vector (9 elements).
Type: Fixed-size double vector (9 elements).
Type: Fixed-size int vector (1 element).
Type: Fixed-size int vector (1 element).
Type: Fixed-size int vector (10 elements).
Type: Fixed-size int vector (10 elements).
Type: Fixed-size int vector (11 elements).
Type: Fixed-size int vector (11 elements).
Type: Fixed-size int vector (12 elements).
Type: Fixed-size int vector (12 elements).
Type: Fixed-size int vector (2 elements).
Type: Fixed-size int vector (2 elements).
Type: Fixed-size int vector (3 elements).
Type: Fixed-size int vector (3 elements).
Type: Fixed-size int vector (4 elements).
Type: Fixed-size int vector (4 elements).
Type: Fixed-size int vector (5 elements).
Type: Fixed-size int vector (5 elements).
Type: Fixed-size int vector (6 elements).
Type: Fixed-size int vector (6 elements).
Type: Fixed-size int vector (7 elements).
Type: Fixed-size int vector (7 elements).
Type: Fixed-size int vector (8 elements).
Type: Fixed-size int vector (8 elements).
Type: Fixed-size int vector (9 elements).
Type: Fixed-size int vector (9 elements).
Type: Fixed-size string vector (1 element).
Type: Fixed-size string vector (1 element).
Type: Fixed-size string vector (10 elements).
Type: Fixed-size string vector (10 elements).
Type: Fixed-size string vector (11 elements).
Type: Fixed-size string vector (11 elements).
Type: Fixed-size string vector (12 elements).
Type: Fixed-size string vector (12 elements).
Type: Fixed-size string vector (2 elements).
Type: Fixed-size string vector (2 elements).
Type: Fixed-size string vector (3 elements).
Type: Fixed-size string vector (3 elements).
Type: Fixed-size string vector (4 elements).
Type: Fixed-size string vector (4 elements).
Type: Fixed-size string vector (5 elements).
Type: Fixed-size string vector (5 elements).
Type: Fixed-size string vector (6 elements).
Type: Fixed-size string vector (6 elements).
Type: Fixed-size string vector (7 elements).
Type: Fixed-size string vector (7 elements).
Type: Fixed-size string vector (8 elements).
Type: Fixed-size string vector (8 elements).
Type: Fixed-size string vector (9 elements).
Type: Fixed-size string vector (9 elements).
Field option: Set of allowed nil types.
Field option: Set of allowed nil types.
Creates a user message, optionally with images.
Creates a user message, optionally with images.
Validates parsed data against a spec.
Validates parsed data against a spec.
Field option: Enum values as map {value description}.
Field option: Enum values as map {value description}.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |