Expand description
Raw FFI bindings for the BaseRT C API.
These are unsafe, low-level bindings. Prefer the baseRT crate for safe usage.
Structs§
- BaseRT
Generation Stats - Generation result statistics.
- BaseRT
Model Config - Model configuration extracted from weight file metadata.
- BaseRT
Prefix Match - Result of a prefix-cache lookup (
baseRT_prefix_match).blockspoints into engine-owned storage valid untilbaseRT_prefix_unlock(handle)/baseRT_prefix_release(handle).handle == 0means miss / cache disabled — nothing to unlock. - BaseRT
Sampling Config - Sampling configuration for text generation.
- BaseRT
Transcribe Segment - One segment of the last transcription (verbose_json surface).
textis borrowed from the engine — valid until the next transcription or model free. - BaseRT
Transcribe Stats - Transcription result statistics.
Functions§
- baseRT_
abi_ ⚠version - The library’s BASERT_ABI_VERSION (since 0.3.1).
- baseRT_
argmax_ ⚠logits_ row - baseRT_
batch_ ⚠logits_ stride - baseRT_
batch_ ⚠step - baseRT_
batch_ ⚠step_ fused - baseRT_
batch_ ⚠step_ fused_ logits - baseRT_
batch_ ⚠warmup - baseRT_
bos_ ⚠id - baseRT_
capabilities ⚠ - baseRT_
chain_ ⚠decode - baseRT_
chat_ ⚠template - baseRT_
chat_ ⚠template_ jinja - Raw Jinja
chat_templatesource folded in from the HF tokenizer (empty if the bundle carries none). - baseRT_
context_ ⚠window_ fits - 1 = the window fits the co-resident set, 0 = it does not, -1 = unknown.
- baseRT_
decode_ ⚠step - baseRT_
decode_ ⚠token - baseRT_
decode_ ⚠token_ raw - Length-preserving stateless decode (byte-level tokens can contain
NUL); returns the true byte length, which may exceed
max_bytes. - baseRT_
device_ ⚠memory_ budget - Device memory budget in bytes (Metal: recommended working set; CUDA: total device memory). 0 when no supported device is present.
- baseRT_
embed ⚠ - baseRT_
embed_ ⚠text - baseRT_
embedding_ ⚠dim - baseRT_
encode ⚠ - baseRT_
encode_ ⚠pieces n_piecestexts encoded as one: pieceiparses marker strings whenplain[i]is zero and keeps them as text otherwise, with the pre-tokenizer seeing the concatenation. See the header.- baseRT_
encode_ ⚠plain - Special-token strings in
textare ordinary text (client content), never control ids. See the header. - baseRT_
eos_ ⚠token_ id - baseRT_
format_ ⚠chat - baseRT_
free_ ⚠model - baseRT_
gdn_ ⚠snapshot_ size - baseRT_
generate ⚠ - baseRT_
generate_ ⚠continue - baseRT_
get_ ⚠config - baseRT_
get_ ⚠config_ into - The configuration copied into a caller-sized buffer, zero-filled past the library’s struct; returns the library’s sizeof (since 0.4.0).
- baseRT_
get_ ⚠error - baseRT_
get_ ⚠error_ code - baseRT_
get_ ⚠position - baseRT_
gpu_ ⚠repetition_ penalty - baseRT_
gpu_ ⚠temperature_ scale - baseRT_
grammar_ ⚠accept_ token - Step a grammar by one token; 0 = the grammar REJECTS it. Lets a test assert what a compiled grammar actually admits, not merely that it compiled — the difference between “the tag parses” and “the tag permits the calls this dialect must be able to make”.
- baseRT_
grammar_ ⚠create - Create a grammar from a GBNF string; NULL on parse error.
- baseRT_
grammar_ ⚠create_ from_ schema - Create a grammar from a JSON Schema (converted to GBNF internally); NULL on error. Used to validate that a codec’s tool-call grammar compiles in the engine (the runtime constrained-decode path).
- baseRT_
grammar_ ⚠create_ from_ structural_ tag - Create a grammar from an xgrammar STRUCTURAL TAG document (JSON, not a
grammar string); NULL on error. The tag’s content formats reach past
JSON Schema —
sequence,const_string,regex,or— which is how a dialect whose call body is not JSON (Gemma 4’scall:fn{k:v}) still gets an enforceabletool_choice. - baseRT_
grammar_ ⚠free - Free a grammar.
- baseRT_
grammar_ ⚠reset - Reset a grammar’s acceptance state to its initial stacks, so one handle can check several candidate strings.
- baseRT_
is_ ⚠embedding_ model - baseRT_
is_ ⚠eos_ token - baseRT_
is_ ⚠whisper - baseRT_
kv_ ⚠bits_ effective - baseRT_
load_ ⚠model - baseRT_
load_ ⚠tokenizer_ only - Tokenizer-only load: metadata + vocab, no GPU tensors. Only the tokenizer surface is valid on the returned handle.
- baseRT_
logits_ ⚠row_ logprobs - baseRT_
mask_ ⚠logits_ row - baseRT_
max_ ⚠prefill_ chunk - baseRT_
model_ ⚠config_ sizeof - baseRT_
model_ ⚠memory - baseRT_
page_ ⚠size - baseRT_
prefill ⚠ - baseRT_
prefix_ ⚠cache_ stats - baseRT_
prefix_ ⚠discard - baseRT_
prefix_ ⚠evict - baseRT_
prefix_ ⚠insert - baseRT_
prefix_ ⚠match - baseRT_
prefix_ ⚠release - baseRT_
prefix_ ⚠unlock - baseRT_
profile_ ⚠decode_ step - baseRT_
profile_ ⚠label - baseRT_
read_ ⚠batch_ logits - baseRT_
reset ⚠ - baseRT_
sample_ ⚠logits_ row - baseRT_
sequence_ ⚠create - baseRT_
sequence_ ⚠free - baseRT_
sequence_ ⚠gdn_ capture - baseRT_
sequence_ ⚠gdn_ restore - baseRT_
sequence_ ⚠rollback - baseRT_
sequence_ ⚠seed_ prefix - baseRT_
set_ ⚠baked_ decode - baseRT_
set_ ⚠condition_ on_ previous_ text - baseRT_
set_ ⚠initial_ prompt - baseRT_
set_ ⚠kv_ bits - baseRT_
set_ ⚠max_ batch_ size - baseRT_
set_ ⚠paged_ kv - baseRT_
set_ ⚠prefill_ chunk - baseRT_
set_ ⚠prefix_ cache - baseRT_
set_ ⚠speculation - baseRT_
set_ ⚠task - baseRT_
set_ ⚠timestamps - baseRT_
set_ ⚠verbose - baseRT_
special_ ⚠token - The
index-th special token string; writes its id toid_out. - baseRT_
special_ ⚠token_ count - Number of added/special tokens the model declares.
- baseRT_
strerror ⚠ - baseRT_
suggest_ ⚠max_ context - A
max_contextsized for this device and this bundle. Metadata-only, so it is safe to call before loading. 0 = could not size. - baseRT_
suggest_ ⚠max_ context_ multi - As above for a set of models that will be resident at the same time: weights and KV pools add up, and the trained-window cap is the shortest among them.
- baseRT_
suggest_ ⚠max_ context_ spec - As above, plus the speculators loading beside those models:
speculator_embedded[i]non-zero is the target bundle’s embedded head (its KV pool only); zero (or a null array) a sidecar / draft model (weights and KV pool), even when also served.speculator_target[i] - baseRT_
tensor_ ⚠count - baseRT_
tensor_ ⚠dtype - baseRT_
tensor_ ⚠name - baseRT_
tensor_ ⚠raw_ dtype - baseRT_
token_ ⚠count - baseRT_
transcribe ⚠ - baseRT_
transcribe_ ⚠audio_ duration_ ms - baseRT_
transcribe_ ⚠language - baseRT_
transcribe_ ⚠pcm - baseRT_
transcribe_ ⚠pcm_ stream - baseRT_
transcribe_ ⚠segment - baseRT_
transcribe_ ⚠segment_ count - baseRT_
transcribe_ ⚠stream - baseRT_
weights_ ⚠identity
Type Aliases§
- baseRT_
model_ t - Opaque model handle.
- baseRT_
segment_ callback - Callback for streaming transcription segments. Return
falseto stop transcription. - baseRT_
sequence_ t - Opaque per-sequence handle (independent KV state on the model’s shared
paged-KV pool). Mirrors
baseRT_sequence_tin baseRT.h. - baseRT_
token_ callback - Callback for streaming token output. Return
falseto stop generation.