oi-kit-inference-cli 0.1.0

Command-line interface for running local models with oi-kit-inference
oi-kit-inference-cli-0.1.0 is not a library.

oi-kit-inference CLI

oi-kit-inference-cli is the command-line interface for running local models with oi-kit-inference. The package installs an oi-kit-inference executable and supports both interactive use and script-friendly input, output, planning, and telemetry.

It accepts a local Hugging Face-style model directory, a local GGUF file or canonical shard, or a model identifier already present in the local Hugging Face cache. It does not download models.

Install from crates.io

On macOS, install the default MLX/Metal build with cargo install --locked oi-kit-inference-cli. The executable embeds its Metal shader library. On Linux, install a CPU text CLI with cargo install --locked oi-kit-inference-cli --no-default-features --features mlx. For a supported NVIDIA host with the CUDA toolkit installed, select --no-default-features --features cuda.

On Windows, run these PowerShell commands in an x64 Visual Studio developer environment with CMake and Ninja installed. MLX links to native DLLs. Keep Cargo's release output long enough to copy its DLLs beside the installed executable. Use a dedicated installation directory for the CLI and its runtime.

$install = Join-Path $env:LOCALAPPDATA 'oi-kit-inference\cli'
$build = Join-Path $env:LOCALAPPDATA 'oi-kit-inference\cli-build'
cargo install --locked oi-kit-inference-cli --no-default-features --features mlx --root $install --target-dir $build
if ($LASTEXITCODE -ne 0) { throw 'CLI installation failed' }
Copy-Item "$build\release\*.dll" "$install\bin" -ErrorAction Stop
& "$install\bin\oi-kit-inference.exe" --help

Add the installation's bin directory to PATH to invoke oi-kit-inference from any directory. For MLX CUDA on Windows, use the same procedure with the cuda feature and the supported CUDA runtime installed.

Candle CPU on macOS, Linux and Windows installs with cargo install --locked oi-kit-inference-cli --no-default-features --features candle. It requires Rust 1.94 or newer and runs independently of the MLX DLLs. For Candle Metal on macOS or Candle CUDA on a supported NVIDIA host, select candle-metal or candle-cuda, respectively.

Basic use

oi-kit-inference --model /path/to/model \
  "Write a Rust function that adds two integers."

From a workspace checkout, use cargo run --release -p oi-kit-inference-cli -- in place of oi-kit-inference.

The CLI budgets 32 GiB for prepared weights and uses oi-kit-inference/prepared-checkpoints-v1 under the user cache directory. It uses XDG_CACHE_HOME when set to an absolute path on Unix, otherwise ~/Library/Caches on macOS or ~/.cache on other Unix systems. On Windows it uses LOCALAPPDATA. If the user cache directory cannot be determined, the CLI uses the system temporary directory. The loader creates the cache directory when it first needs a prepared file. Set both --prepared-cache-dir and --prepared-cache-bytes to override the policy.

MLX defaults to a discovered GPU, then CPU. Candle defaults to CPU. Pin a device and select a sampling policy with command-line options:

oi-kit-inference --model /path/to/model --device cpu \
  --temperature 0.7 --top-p 0.9 --max-tokens 512 \
  "Tell me a short story."

Generation settings, including repetition, frequency, and presence penalties, use values from the checkpoint's generation_config.json when supplied there. Only explicit command-line arguments override those values. For example, --presence-penalty 0 disables a checkpoint's presence penalty, and --repeat-penalty 1 disables its repetition penalty. Use --verbose to see the effective settings.

On supported CUDA hosts, disabling the default features and enabling cuda replaces the default Metal/Accelerate backend selection instead of combining native backends.

The executable requires the mlx or candle feature. MLX builds support Rust 1.89 or newer. Any build that enables Candle requires Rust 1.94 or newer. To run a model on Candle CPU:

cargo run -p oi-kit-inference-cli --no-default-features --features candle -- \
  --backend candle --device cpu --model /path/to/model.gguf "Tell me about the ocean."

Add candle-metal or candle-cuda to use --device metal:0 or --device cuda:0 on a supported host. With both backends enabled, the text CLI defaults to MLX. Candle external drafts use the target context by default. With candle-metal, --device metal:0 --speculative-draft-device cpu keeps the draft on CPU, and --device cpu --speculative-draft-device metal:0 puts the draft on Metal. An explicit device creates a separate context even when both devices match. Use --features candle,realtime for the Candle audio subcommands. Add candle-metal and pass --device metal:0 to select Metal for finite audio tasks and duplex realtime speech. In a build with both backends, use oi-kit-inference audio --backend candle … to select Candle. The --decisions command supports Candle and MLX.

The metal and cuda features select MLX accelerators, and nccl implies cuda. A bare --no-default-features build omits the executable.

Converted checkpoints can select independently admitted tower sources with --vision-companion DIRECTORY and --audio-companion DIRECTORY. For example, inspect a text-only Spark conversion with official BF16 media sources:

oi-kit-inference --model /path/to/spark-conversion \
  --vision-companion /path/to/spark-bf16 \
  --audio-companion /path/to/spark-bf16 \
  --auto plan

The architecture validates geometry, token identities, processor assets and provenance before loading. Vision and audio can use different directories. Automatic overrides, benchmark candidates and exact-plan replay preserve these source roles; cached plans require the same requested companion selection.

Run the command with --help for the complete option list.

Input and output

If the positional prompt is absent, the command reads standard input. Generated visible text is written to standard output. Reasoning, diagnostics, timing, memory statistics, and stop reasons are written to standard error, so the response can be piped safely:

printf 'Summarize the purpose of MLX.' | \
  oi-kit-inference --model /path/to/model > response.txt

Chat templates are applied automatically. Use --raw for an untemplated text completion and --thinking on|off to override templates with a standard thinking control.

Use --timing for concise performance statistics, --verbose for execution details, and --telemetry-json PATH for a versioned machine-readable report. Unrecognized templates use literal text generation with TTFT and supported speculative drafting. They retain EOS and caller stop sequences; native tools and parsed reasoning still require a recognized protocol.

Image and video input

Use --image PATH with any checkpoint whose selected processor accepts images. Repeat the flag to append several JPEG or PNG files in argument order. Use --video-frames DIRECTORY --video-fps FPS to append a clip from JPEG or PNG frames in filename order. Zero-pad numeric filenames to preserve temporal order. The checkpoint processor controls resizing, sampling and timestamps.

oi-kit-inference --model /path/to/vision-language-model \
  --image reference.png --video-frames ./frames --video-fps 6 \
  "Compare the image with the clip."

The template receives text, then images, then the clip. Visual inputs use the ordinary chat generation command and the default-enabled vision feature. They require a chat template. Automatic quick planning remains available.

Automatic planning

Normal generation selects a single-device execution plan automatically. The planner considers available memory, checkpoint resources, residency policy, expert caching, and supported embedded drafting.

Inspect the selected plan without loading the model:

oi-kit-inference --model /path/to/model --auto plan > plan.json

Use --auto benchmark to evaluate admitted candidates in isolated child processes. --auto-cache PATH stores reusable plan selections, and repeated --auto-feedback PATH options supply compatible execution telemetry to the planner. Every reused plan is checked against the current artifact, hardware, available memory, and loader admission.

Explicit residency and budget options override the corresponding automatic choice. Use --no-auto when every execution setting should come from explicit flags and defaults.

Loading and memory

Eligible dense checkpoints can be quantized while loading:

oi-kit-inference --model /path/to/model --quantize 4 \
  "Explain quantization."

Large models can use host-layerwise or dense disk-streamed weight residency. Supported mixture-of-experts models can use an independent expert cache. These policies accept explicit host and device budgets and trade transfer or I/O work for a smaller resident parameter set. Eligible on-load quantization composes with these residency policies; exact architecture/backend admission checks support.

See Model loading, quantization, and memory for the policy contracts and accounting model.

Speculative generation

Supported embedded prediction heads are selected by the execution plan. Supply an external compatible assistant with --draft-model:

oi-kit-inference --model /path/to/target \
  --draft-model /path/to/assistant \
  --speculative-draft-device cpu --speculative-draft-tokens 3 \
  "Explain speculative decoding."

Speculative generation requires a recognized executable chat protocol and is not available with --raw. See Speculative decoding and MTP for compatibility and placement rules.

Typed decision reads

Use oi-kit-inference --model MODEL --decisions request.json to evaluate typed questions. Use --decisions - to read JSON from standard input. The decision task uses explicit device and residency settings. Use --timing to report model loading (load_seconds) and decision generation (decision_seconds) separately on stderr. Decision generation includes any on-demand weight transfers.

Read a number and date with d1

Use a local d1 checkpoint or a model identifier in the Hugging Face cache.

oi-kit-inference --model LiquidAI/d1-2B --device cpu --decisions - <<'JSON'
{
  "state": "Invoice total €1.234,50. The package arrived on March 4, 2026.",
  "questions": [
    {
      "id": "total",
      "question": {"type": "read_number", "instructions": "Read the invoice total."}
    },
    {
      "id": "arrival",
      "question": {"type": "read_date", "instructions": "Read the arrival date."}
    }
  ]
}
JSON

The number answer includes the value 1234.5 and unit €. The date answer includes the ISO 8601 value 2026-03-04. Each answer also includes the source span and its calibrated presence probability.

Choose an option with DiffusionGemma

Save the following as request.json and run oi-kit-inference --model /path/to/diffusiongemma --decisions request.json.

{
  "state": "I was charged twice. Please refund the duplicate payment.",
  "refinement_steps": 2,
  "seed": 42,
  "questions": [
    {
      "id": "department",
      "question": {
        "type": "single_choice",
        "instructions": "Which department should handle this?",
        "options": [{"label": "billing"}, {"label": "technical"}, {"label": "sales"}]
      }
    }
  ]
}

Refinement responses include probabilities over the supplied alternatives. label_mass reports the full-vocabulary probability assigned to those alternatives before renormalization.

Media and request fields

For image evidence, include a media entry such as {"type": "image", "path": "delivery.png"} in the top-level media array. A box question can ask a supported model to locate the package in that image.

Media entries retain their array order. Image entries take path, video entries take frames (a directory of images) and fps, and audio entries take a mono WAV path. A question's optional spoken WAV path replaces its written instructions. Paths in the request are relative to the request file or to the working directory when reading stdin. For split checkpoints, pass the projector with --vision-companion or --audio-companion and use the request's assets field to select the sidecar directory if it differs from the backbone directory.

Question types are single_choice, multiple_choice, yes_no, score, extract_text, read_number, read_date, estimate, box, and boxes. Choice options contain a label and optional description. Yes/no can specify two criteria. Scores take ordered levels. Numeric estimates take a two-value range, optional step, and optional unit. Number extraction accepts an optional unit, and multiple boxes accept an optional max.

The model determines which question types and input modalities it can evaluate. Text refinement supports single choice, yes/no, and ordinal score, with optional refinement_steps and seed. Results contain answers in request order with the corresponding IDs, token usage, and the calibration digest when the checkpoint supplies one.

Native tool calls

Pass OpenAI-shaped function definitions with --tools. Tool generation is enabled only when the checkpoint has a recognized rendering, constraint, and parsing profile.

oi-kit-inference --model /path/to/model \
  --tools tools.json --tool-choice required \
  "Look up the weather in Bogota."

Visible text and canonical tool events are written to standard output. See Native tool calling for schemas and event semantics.

Request memory forecasts

Use --estimate-memory-tokens N --max-tokens M to inspect input-dependent memory before loading, or --memory-report PATH to report the actual tokenized request before generation. --memory-budget-bytes is a total model-plus-request planning budget; --memory-policy warn|refuse controls predicted shortfalls. The default reserve is 256 MiB, configurable with --memory-reserve-bytes.

Eligible text prefill automatically sizes chunks with the same memory reserve and uses a 512-token fallback when accounting is unavailable. Set --prefill-chunk-size 0 to remove the caller-imposed chunk limit. Reports preserve unknown costs and identify full-prompt fallbacks. See formulas, coverage and calibration.

Turn-based audio

oi-kit-inference audio selects a task for one request. LFM3 Audio is available through this command with resident MLX execution.

oi-kit-inference audio transcribe --model /models/audio --input speech.wav --timing
oi-kit-inference audio translate --model /models/audio --input speech.wav --source-language English --language French
oi-kit-inference audio speak --model /models/audio --text "Hello there." --output speech.wav
oi-kit-inference audio respond --model /models/audio --input question.wav --output answer.wav

Transcription streams text to stdout as blocks become available. Translation and spoken responses close the utterance before generating. Spoken responses stream answer text to stdout alongside the speech output. Give source and target language names in English for LFM3 Audio translation. Use mono 16-kHz WAV with the current Audio model. Speech WAVs are mono 24 kHz. With system-audio, transcribe, translate, and respond accept --microphone-seconds in place of --input. Use --input-device to select the microphone. For speak and respond, --play plays the speech and can be combined with --output. Use --output-device to select the speaker. --device cpu or --device gpu:0 selects model execution.

Add --timing to any oi-kit-inference audio subcommand for wall-clock timings on stderr. Turn-based commands report model load time, time to the first text fragment or PCM chunk, task time, and total execution time. Task time includes input capture or reading and output writing or playback. realtime reports load, conversation, and total execution times. Conversation time includes input pacing, the response tail, and output finalization.

For a split GGUF, supply the backbone, projector, and publisher assets:

oi-kit-inference audio speak --model /models/audio-backbone.gguf \
  --projector /models/audio-projector.gguf --assets /models/audio-assets \
  --text "Hello there." --output speech.wav

--assets supplies the tokenizer, processor and codec configuration. GGUF execution uses the two GGUF payloads. Build with mlx,realtime for WAV-only operation or with mlx,system-audio for device I/O.

Full-duplex audio

oi-kit-inference audio realtime runs a conversation with microphone and speaker active at the same time, or replays a WAV through the same session. Run oi-kit-inference audio --help to see all audio tasks.

Build with realtime,system-audio for microphone/speaker conversations; both features are enabled by default. system-audio uses CPAL's native platform host. Linux builds require the host audio development libraries used by CPAL (normally ALSA). A WAV-only build uses --no-default-features --features mlx,metal,realtime on Apple silicon. Use candle-metal,realtime with --backend candle --device metal:0 for Candle WAV replay. CUDA hosts using MLX use --no-default-features --features cuda,realtime,system-audio.

System-audio builds include WebRTC echo cancellation and require Meson, Ninja, a C/C++ toolchain and rustup component add llvm-tools-preview. On macOS, brew install meson ninja pkg-config supplies the additional build tools. The bundled library downloads pinned Abseil sources when a suitable system dependency is unavailable.

oi-kit-inference audio realtime --list-audio-devices
MLX_MAX_OPS_PER_BUFFER=25 MLX_MAX_MB_PER_BUFFER=256 \
  oi-kit-inference audio realtime --model /models/voicechat-official \
  --base-assets /models/nemotron-base --device gpu:0 \
  --quantize 8 --speech-weights f16 --speech-compute f16 \
  --seconds 60 --output speech.wav --events events.jsonl

Cached official repositories can be passed directly:

oi-kit-inference audio realtime --model nvidia/NVIDIA-NemotronLabs-VoiceChat-11B \
  --base-assets nvidia/NVIDIA-Nemotron-Nano-9B-v2 \
  --quantize 8 --speech-weights f16 --speech-compute f16

--base-assets supplies config.json, tokenizer.json and tokenizer_config.json from the base model. VoiceChat supplies the backbone weights. The validated revision is 6533e8de2c68e4536bf7c411d7a3ce5734111476. If these files are missing from the cache, download only the assets:

hf download nvidia/NVIDIA-Nemotron-Nano-9B-v2 \
  config.json tokenizer.json tokenizer_config.json \
  --revision 6533e8de2c68e4536bf7c411d7a3ce5734111476

The resulting snapshot directory is also accepted by --base-assets. --official-assets defaults to the --model repository for direct model requests. Text and realtime commands share model/revision, device, allocator cache, quantization, sampling and common residency argument definitions and normalization. Omitted sampling controls preserve each command's defaults or supplied configuration. Both commands default to four cached checkpoint readers.

The command-buffer settings above identify the measured M3 Ultra configuration; other hardware can need different batching.

The default microphone and speaker are selected automatically. Use exact names from --list-audio-devices with --input-device and --output-device to select other devices. Headphones avoid acoustic feedback. First Ctrl-C closes capture and drains the response tail; a second Ctrl-C cancels. Queue storage is bounded by --audio-buffer-ms; capture overflow reports a continuity error.

Live microphone-and-speaker sessions enable WebRTC AEC3 echo cancellation by default. The reference is PCM actually sent to the speaker, including playback silence, clipping, underruns and interruptions. Cancellation runs in 10 ms host frames after microphone resampling, while capture stays live for user barge-in. --no-echo-cancellation disables it, for example when comparing headphone input. File input and --no-playback do not use echo cancellation. Automatic gain control is disabled. Cancellation needs time to adapt to the acoustic path; it does not guarantee removal of all speaker leakage.

Push-to-talk, noise suppression and speech admission are opt-in. They configure host input processing; the ordinary controlled conversation driver continues to receive timed PCM, including silence when input is muted.

  • --push-to-talk or --push-to-talk toggle starts muted. Tap Space to alternate between listening and muted; do not hold it in toggle mode because ordinary terminals can report autorepeat as repeated presses. --ptt-key enter or a single ASCII letter/digit selects a different key. PTT requires interactive stdin, stdout and stderr.
  • --push-to-talk hold admits capture while the key is held. Unix terminals must support keyboard-enhancement key-release events; unsupported terminals report an error before model loading. Windows console key-release events are native. Terminal focus loss closes admission when reported. The CLI restores terminal mode on normal exit, cancellation and errors. Ctrl-C retains its two-stage close/cancel behavior. Permission follows captured samples through buffering; the echo/noise filters continue operating on real microphone PCM while muted.
  • --noise-suppression enables WebRTC moderate suppression. Choose off, low, moderate, high or very-high explicitly to compare strengths. It operates after microphone resampling, in the same processor as echo cancellation, and works with --no-playback or --no-echo-cancellation. It is microphone-only; stronger suppression can distort speech and does not identify the intended speaker.
  • --speech-admission enables a sustained-level gate for microphone or WAV input. --speech-threshold-dbfs sets the opening RMS level after filtering (default -40), and --speech-hysteresis-db sets the reduction in closing level (default 6). --speech-min-ms rejects shorter peaks (default 80); --speech-preroll-ms retains preceding audio (default 160); --speech-hangover-ms retains quieter endings (default 300). Pre-roll and hangover use whole 10 ms windows. Admission adds pre-roll plus minimum-duration lookahead, 240 ms with these settings, and preserves the exact source sample count at shutdown. Rejected windows become silence. Distant speech above the threshold still passes; this is level admission, not speaker recognition.

These options combine, so speech admission can reject quiet material while PTT is open. Tune the threshold using --record-input with admission disabled and separate quiet-background and normal-speaking recordings; a whole-session RMS includes silence and cannot identify a useful speech threshold by itself.

--system-prompt overrides the conversation's system prompt, including one from --config, without changing input processing. Prompts must contain ASCII text. For example:

oi-kit-inference audio realtime \
  --model nvidia/NVIDIA-NemotronLabs-VoiceChat-11B \
  --base-assets nvidia/NVIDIA-Nemotron-Nano-9B-v2 \
  --quantize 8 --speech-weights f16 --speech-compute f16 \
  --noise-suppression moderate --speech-admission --speech-threshold-dbfs -35 \
  --system-prompt 'You are a helpful voice assistant. Wait silently until the user makes a clear request addressed to you. Do not respond to background conversation or incomplete fragments. If a request is unclear, ask a brief clarifying question.'

Add --push-to-talk for manual admission. Prompt instructions are an experiment; the model may not follow them reliably and they do not replace audio admission.

In an interactive terminal, conversation text appears on stderr as separate Heard: and Agent: lines. Token fragments are joined into readable chunks; transcription is flushed after an 800 ms pause, at a turn boundary or at shutdown. Long chunks are split at word boundaries where available, with a 240-byte limit. Agent text is flushed at sentence and turn boundaries. Redirected stdout preserves the raw streaming agent text for scripts; transcription remains on stderr.

Transcription is shown by default. It uses the model's existing perception output and requires no additional inference. --no-transcription hides it. The transcription is the model's speech recognition output, not an explanation of its response. The model can initiate an agent turn without recognized user speech; transcription is not an admission gate for generated responses. The backbone consumes audio features directly, so a response preceding transcript text does not imply that the model has received no audio.

For microphone diagnostics, use --record-input microphone.wav to save the resampled and filtered source audio accepted by the session as mono 16 kHz float32 WAV. The recording includes PTT/admission silence in place of rejected input. The recording excludes injected silence and response-tail padding. The CLI reports the selected microphone device and native format at startup, and accepted sample count, RMS level and peak level at shutdown. Background dialogue can reach the model even when the operator is silent.

To distinguish live capture from model behavior, record a run with --record-input microphone.wav --events microphone.jsonl, then listen to the recording and replay it with the same model/precision options plus --input microphone.wav --offline --no-playback --events replay.jsonl. JSONL preserves individual text deltas and source-frame attribution regardless of terminal grouping.

On-load quantization targets eligible backbone/readout, function-head and causal speech-transformer projections, uses the bounded prepared-checkpoint cache, and keeps sensitive floating operations intact. --quantize-components selects a subset. Quantized causal projections retain F32 arithmetic. Released packed checkpoints load without --quantize; re-quantization is rejected.

Startup reports planned memory for device-side weights, separate host-side weight pools, loading/conversion workspace, and cached computations. These are admission allowances, not measured process RAM usage. Conversation history and temporary computation buffers require additional memory. On Apple silicon, device and host allocations share physical RAM; the loading workspace is a loading reservation, not an additional permanent weight copy.

Use --config voicechat.json for tool declarations, split GGUF sources and precise resource configuration. Device, sampling, seed, mixed precision, parameter budgets and bounded host/disk residency have command-line overrides. Model identifiers must already be cached; auxiliary assets are admitted from the exact official and base tokenizer/configuration sources described in VoiceChat validation.

Recorded input and unattended measurements use the same controlled driver:

oi-kit-inference audio realtime --config voicechat.json --input conversation.wav \
  --offline --no-playback --quantize 8 \
  --speech-weights f16 --speech-compute f16 \
  --output speech.wav --events events.jsonl

Input WAV must be mono 16 kHz; output is mono 22.05 kHz float32. Output paths must be new. Redirected agent text is written to stdout; terminal conversation text, diagnostics and warm execution percentiles are written to stderr. JSONL records committed text, transcription, tools, turns, wall time and invocation execution time. Execution timing excludes input pacing and output delivery; it does not measure complete microphone-to-speaker latency.

Run oi-kit-inference audio realtime --help for the complete option list.