# CLI Reference ```bash hk [arguments] hk help ``` `hk` is one executable. It needs no Python, no GPU toolkit and no configuration. Commands that take a model accept a `.hk` file or a Hub reference (`owner/name[:quant]`); a reference is pulled first if it is not cached yet. ## Running models ### `hk run [prompt | -p TEXT] [options]` Generates text. Text goes to standard output, statistics to standard error, so the output can be piped. | Option | Meaning | Default | |:---|:---|:---| | `-p, --prompt TEXT` | text to continue (a bare argument works too; quote it) | none | | `--chat` | wrap the prompt as one user message using the model's chat template | off | | `-n, --max-tokens N` | most tokens to generate | 128 | | `--temp T` | temperature; `0` takes the most likely token | 0.8 | | `--top-k N` | keep the N most likely tokens, `0` for no limit | 40 | | `--top-p P` | nucleus sampling, `1` disables | 0.95 | | `--min-p P` | drop tokens below P times the best one | 0.05 | | `--repeat-penalty X` | penalty for recent tokens, `1` disables | 1.0 | | `--seed N` | random seed, `0` uses the clock | 0 | | `--threads N` | compute threads | physical cores | | `-ngl, --gpu-layers N` | run on a GPU (Vulkan) when N > 0; also `HK_GPU=1` | CPU | Every flag is checked before the model is opened, and an unknown or malformed one is an error, never a silent default. With `--temp 0` the output is deterministic. ### `hk chat [options]` An interactive session with the model's chat template and history kept across turns. Takes the sampling options of `run` (not `-p` or `--chat`) and `-n` (default 1024). An empty line ends the session. ### `hk serve [options]` An OpenAI compatible HTTP server. See [Inference and Serving](Inference-and-Serving.md). ## Getting models | Command | | |:---|:---| | `hk pull [:quant] [--force] [--revision REF]` | download and convert, see [Downloading Models](Downloading-Models.md) | | `hk search [--limit N] [--all]` | search the Hub | | `hk list` | show cached models | | `hk rm ` | delete a cached model | | `hk convert-gguf ` | convert a GGUF file; block formats are carried over byte for byte | | `hk convert-safetensors [f32\|q4_0\|q8_0]` | convert one safetensors file, optionally quantizing | | `hk export -f gguf ` | write a GGUF v3 file | | `hk export -f safetensors ` | write safetensors; float tensors keep their type, quantized ones are decoded and stored as F16 | Tensor names are kept as they are in the container, so a model converted from GGUF exports with GGUF names. ## Looking at a container | Command | | |:---|:---| | `hk inspect ` | header, metadata and the tensor table | | `hk dump ` | the header field by field, with offsets | | `hk verify ` | check the magic, version and the alignment of the payload | | `hk hash ` | SHA-256 of the container and of every tensor | | `hk eval ` | parameter count, value range, NaN and Inf count | | `hk tokenize "text"` | token ids using the vocabulary stored in the file | | `hk detokenize ...` | text from token ids | | `hk metadata list ` / `get` / `set ` | read or change metadata in place; the weights are not rewritten | | `hk hardware-profile` | what the processor offers, which kernels are in use, whether a GPU is usable | | `hk benchmark ` | time to open the file, resolve tensors, touch every page, decode a tensor | ## Editing containers (research features) | Command | | |:---|:---| | `hk expand [--vocab N] [--width R]` | grow the vocabulary and the MLP width of a float model; see [Dynamic Architecture Growth](Dynamic-Architecture-Growth.md) | | `hk prune [ratio]` | magnitude pruning | | `hk retile [tile_16x16\|row_major]` | change the layout of 2-D tensors | | `hk appendix ` | list the version history stored in the file | | `hk rollback [generation]` | cut the version history back; this truncates the file | | `hk convert-endian ` | byte swap a container | | `hk gui [file.hk]` | the Tk model editor (needs Python and Tk) | `hk expand` refuses quantized models, and says so when no tensor name matched (it looks for Hugging Face style names). ## Environment | Variable | Effect | |:---|:---| | `HK_HOME` | model cache directory | | `HF_TOKEN`, `HF_ENDPOINT`, `HK_HTTP_BACKOFF_MS` | downloads, see [Downloading Models](Downloading-Models.md) | | `HK_GPU=1` | use the GPU when possible, without `-ngl` | | `HK_KERNELS=` | force an instruction set level (for example `avx2` or `generic`); useful for testing and measuring | | `HK_THREADS=N` | thread count for the developer tools | | `HK_API_KEY` | API key for `hk serve` | ## Exit status Zero on success, non-zero on any error. Messages for the user go to standard error.