Skip to content
mlx-bun 1.0.0 is beta and actively developed. APIs may change; breaking changes will be called out in release notes.

Configuration reference

Generated at build time from apps/mlx-bun/src and packages/*/src without running them; tests and scripts are not scanned. These are the current settings on main; released versions can differ.

Read: value is the raw string; flag treats 1 as on, 0 as off, and anything else as the default; number takes a finite number, else the fallback; process.env is read directly rather than through the runtime configuration. Default is the fallback at each read site, so a key read at several sites lists each; computed means the code at the source link decides.

The serve flags and their descriptions are in the CLI reference. This table adds what the parser enforces: literal defaults, numeric ranges, and accepted values.

FlagDefaultAcceptsSource
--thinkingon | off | 1 | 0 | true | falsecli/serve.ts:42
--kv-quant (note)offoff | config | 4 | 8cli/serve.ts:48
--prompt-cache (note)number ≥ 0cli/serve.ts:54
--ssd-cache-maxnumber ≥ 0cli/serve.ts:67
--ssd-demote-idlenumber ≥ 0cli/serve.ts:67
--generation-checkpointinteger ≥ 1cli/serve.ts:67
--temperaturenumber in [0, 5]cli/serve.ts:73
--tempnumber in [0, 5]cli/serve.ts:73
--top-pnumber in [0, 1]cli/serve.ts:74
--top-knumber in [0, 1000000]cli/serve.ts:74
--hlg-samplingon | off | 1 | 0 | true | falsecli/serve.ts:75
--hlg-width4number in [0, 100]cli/serve.ts:85
--hlg-shoulder4number in [0, 100]cli/serve.ts:85
--hlg-toe6number in [0, 100]cli/serve.ts:86
--hlg-pivot-offset6number in [0, 100]cli/serve.ts:86
--draft-kinddspark | deepspec | assistant | two-model | ngram | mtpcli/serve.ts:100
--mtpon | off | 1 | 0 | true | falsecli/serve.ts:116
--paged-kv-block-sizeinteger ≥ 1cli/serve.ts:135
--memory-budgetnumber ≥ 0cli/serve.ts:140
--model-budgetnumber ≥ 0cli/serve.ts:141
--context-lengthinteger ≥ 1cli/serve.ts:143
--host127.0.0.1cli/serve.ts:144
--kv-budgetnumber ≥ 0cli/serve.ts:146
--max-tokensnumber in [1, 10000000]cli/serve.ts:147
--port8080integer in [0, 65535]cli/serve.ts:153
--batch8integer ≥ 1cli/serve.ts:155
--decode-concurrency8integer ≥ 1cli/serve.ts:155

When serve starts a model host it writes these keys from its flags; a written value replaces the environment’s.

KeyFromSource
MLX_BUN_FORCE_WIRE--force-wirecli/serve-host.ts:95
MLX_BUN_ALLOW_PRIVATE_MEDIA--allow-private-mediacli/serve-host.ts:96

MLX_BUN_* keys read under apps/mlx-bun/src and in the module and host-library packages it installs (packages/module-*, packages/app-*), including environment mirrors of flags.

KeyReadDefaultSource
MLX_BUN_CACHE_RETENTIONvalueunset (only cost-size changes it)engine/cache-services.ts:107
MLX_BUN_EVAL_KV_QUANTvalueunset (only 1 changes it)cli/inference.ts:156, cli/inference.ts:158
MLX_BUN_EVAL_THINKvalueunset (only 1 changes it)cli/inference.ts:173
MLX_BUN_GRAMMARvalueunset (only 0 changes it)server/request-prep.ts:136
MLX_BUN_HOME (note)valuecomputedapp-services/src/home.ts:19, module-memory/src/paths.ts:8
MLX_BUN_JOB_PARENT_PIPEflagset at jobs/runner.ts:115cli/job-entry.ts:41
MLX_BUN_JOBS_DBvalueset at jobs/runner.ts:113cli/job-entry.ts:46
MLX_BUN_JOBS_DIRvalueset at jobs/runner.ts:114cli/job-entry.ts:47
MLX_BUN_LANE_DEBUGvalueunset (only 1 changes it)server/inference-request.ts:56
MLX_BUN_MEMORY_BATCHvalue1module-memory/src/model.ts:154
MLX_BUN_MIC_CAPTUREvaluecomputedmodule-transcription/src/mic-capture.ts:28
MLX_BUN_PAGED_KV (note)valueunset (only 1 changes it)cli/serve.ts:134
MLX_BUN_PI_DEBUGvaluecomputedmodule-chat/src/pi-backend.ts:171, module-chat/src/pi-backend.ts:628, module-chat/src/pi-backend.ts:654, module-chat/src/pi-backend.ts:742, module-chat/src/pi-backend.ts:823
MLX_BUN_RD_CONTEXT_LIMITvaluecomputedcli/serve.ts:175
MLX_BUN_SESSION_CACHEvalueunset (only 0 changes it)server/routes.ts:71
MLX_BUN_SHUTDOWN_TIMEOUT_MSvaluecomputedcli/serve-options.ts:104
MLX_BUN_SSD_LAYOUTvalueunset (only blocks changes it)engine/cache-services.ts:95
MLX_BUN_SSD_PREFETCHvalueunset (only 0 changes it)engine/cache-services.ts:98
MLX_BUN_SSD_SEGMENTEDvalueunset (only 0 changes it)engine/cache-services.ts:96
MLX_BUN_SSD_SPILL_QUEUE_GBvaluecomputedengine/cache-services.ts:88
MLX_BUN_SSD_WRITEBEHINDvalueunset (only 0 changes it)engine/cache-services.ts:97
MLX_BUN_WIKIvaluecomputedstorage/paths.ts:59, module-memory/src/vault.ts:14

These keys are library tuning and diagnostics, not app options; none is promoted to a flag. Grouped by the package that reads them.

KeyReadDefaultSource
MLX_BUN_ALLOW_PRIVATE_MEDIAvalueset by serve from --allow-private-media (cli/serve-host.ts:96)input/media-fetch.ts:72
MLX_BUN_ANE_DYLIBprocess.envcomputedruntime/native.ts:16
MLX_BUN_BATCH_EXTENDvalueunset (only 0 changes it)state/batched-mask.ts:385, state/batched-quant.ts:333
MLX_BUN_BATCH_NO_PIPELINEvalueunset (only 1 changes it)execution/batch-group.ts:173
MLX_BUN_BATCH_STEP_TRACEvalueunset (only 1 changes it)execution/batch-group.ts:174
MLX_BUN_DSPARK_MINCONFvaluecomputedgeneration/speculative/sources/dflash-source.ts:53
MLX_BUN_EARLY_FIRST_TOKENflagonexecution/batch-group.ts:374, execution/batch-group.ts:558, generation/autoregressive.ts:565
MLX_BUN_EXPERT_IO_DYLIBvaluecomputedartifacts/experts/io.ts:71
MLX_BUN_EXPERT_IO_DYLIBprocess.envcomputedruntime/native.ts:14
MLX_BUN_EXPERT_OFFLOADvaluecomputedartifacts/expert-offload.ts:88
MLX_BUN_EXPERT_TRACEvaluecomputedruntime/expert-trace.ts:65
MLX_BUN_FILLvalueoffgeneration/autoregressive.ts:81
MLX_BUN_FILLvaluecomputedgeneration/fill/session.ts:122
MLX_BUN_FILL_APPEND_CHUNK_SIZEnumber0generation/fill/session.ts:137
MLX_BUN_FILL_CANDIDATESnumber24generation/fill/session.ts:148
MLX_BUN_FILL_INDEX_MAXnumber131072generation/fill/session.ts:149
MLX_BUN_FILL_Knumber8generation/fill/session.ts:146
MLX_BUN_FILL_MAX_SPANnumber32generation/fill/session.ts:131
MLX_BUN_FILL_TRACE (note)flagoffgeneration/fill/session.ts:157
MLX_BUN_FILL_TRACE (note)valuecomputedgeneration/fill/session.ts:168
MLX_BUN_FORCE_WIREvalueset by serve from --force-wire (cli/serve-host.ts:95)generation/autoregressive.ts:120, generation/denoising.ts:27, generation/scopes.ts:59
MLX_BUN_FRAME_EXTRACTvaluecomputedinput/vision/video-frames.ts:16
MLX_BUN_FRAME_EXTRACTprocess.envcomputedruntime/native.ts:15
MLX_BUN_GRAMMARvalueunset (only 0 changes it)sampling/grammar.ts:629
MLX_BUN_GRAMMAR_DEBUGvalueunset (only 1 changes it)execution/batch-group.ts:927
MLX_BUN_GRAMMAR_DRAFT_TOKENSnumber3execution/gateway-binding.ts:100
MLX_BUN_HOME (note)valuecomputedartifacts/identity.ts:50
MLX_BUN_MEDIA_PREFIX_CACHEflagonexecution/gateway-binding.ts:158
MLX_BUN_P2R_SYNCvalueunset (only 1 changes it)execution/batch-group.ts:493, execution/batch-group.ts:545, generation/autoregressive.ts:520
MLX_BUN_P2R_TRACEvalueunset (only 1 changes it)runtime/trace.ts:158
MLX_BUN_PREFILL_MEM_LOGvalueunset (only 1 changes it)generation/autoregressive.ts:510
MLX_BUN_RD_PREFILL_CHUNK (note)valuecomputedgeneration/bindings/prefill-policy.ts:20, models/composition.ts:21
MLX_BUN_RD_PREFILL_CHUNK (note)number2048generation/bindings/prefill-policy.ts:21, models/composition.ts:22
MLX_BUN_SAMPLER_WINDOW_FILTERSflagonsampling/step.ts:196
MLX_BUN_SPEC_DEVICE_ROUNDflagongeneration/speculative/round.ts:130
MLX_BUN_SPEC_DRAFT_FILTERflagongeneration/speculative/draft-policy.ts:38
MLX_BUN_SPEC_DRAFT_TEMPERATUREvaluecomputedgeneration/speculative/draft-policy.ts:35
MLX_BUN_SPEC_DRAFT_VOCABvaluecomputedgeneration/speculative/draft-vocab.ts:43
MLX_BUN_SPEC_LAYER_PROFILEflagoffgeneration/speculative/round.ts:155
MLX_BUN_SPEC_OP_INVENTORYflagoffgeneration/speculative/round.ts:134
MLX_BUN_SPEC_PHASE_TIMINGflagoffgeneration/speculative/round.ts:18
MLX_BUN_TOKEN_MASKvalueunset (only metal changes it)sampling/grammar.ts:227
MLX_BUN_TURBOQUANT_FUSED_DECODEflagonstate/turboquant-codec.ts:8
KeyReadDefaultSource
MLX_BUN_LIBMLXCprocess.envcomputednative.ts:15
KeyReadDefaultSource
MLX_BUN_CALIBRATION_JSONLvaluecomputedcalibration.ts:39
KeyReadDefaultSource
MLX_BUN_CCE_BWD_BLOCK_EPSvalue1e-5trainer.ts:221
MLX_BUN_CCE_BWD_FILTER_EPSvalue1e-5trainer.ts:220
MLX_BUN_CCE_BWD_NOSTEELvalueunset (only 1 changes it)trainer.ts:216
MLX_BUN_CCE_BWD_SCALARvalueunset (only 1 changes it)trainer.ts:217
MLX_BUN_CCE_BWD_SKIP_P2valueunset (only 1 changes it)trainer.ts:219
MLX_BUN_CCE_BWD_SKIP_P2DQvalueunset (only 1 changes it)trainer.ts:218
MLX_BUN_CCE_LANEvalueunset (only 1 changes it)trainer.ts:213
MLX_BUN_CCE_NOSTEELvalueunset (only 1 changes it)trainer.ts:212
MLX_BUN_CCE_SCALARvalueunset (only 1 changes it)trainer.ts:214
MLX_BUN_CCE_SG_SKIPDQvalueunset (only 1 changes it)trainer.ts:215
MLX_BUN_FLASH_MIN_Mvalue1024trainer.ts:211
MLX_BUN_MEM_LOGvalueunset (only 1 changes it)trainer.ts:15
MLX_BUN_SEG_HEADvaluecheckpointsegmented.ts:73
MLX_BUN_SEG_HEAD_CHUNKvalue512segmented.ts:85
MLX_BUN_SEG_MEM_LOGvalueunset (only 1 changes it)segmented.ts:62
MLX_BUN_TRAIN_ATTNvalueunset (only flash changes it)trainer.ts:601
  • --fused-sdpa, --kv-quant: --fused-sdpa on|off picks the read kernels of affine-quantized KV when the model loads: on, the fused quantized-KV attention tiles for windows under a causal mask; off, the unfused path for every read. Without it, fused SDPA is on only when the KV choice (--kv-quant, or --l2’s model-config KV) is config.
  • MLX_BUN_RD_PREFILL_CHUNK: Unset, the model’s prefill policy picks the chunk: 2048 tokens, halved for linear-attention models at long context to bound the attention workspace. The 2048 shown for its number read applies only to a set, non-numeric value.
  • --prompt-cache: --prompt-cache is in GiB (N × 2^30 bytes), but the cap without it is 8e9 bytes (decimal 8 GB, about 7.45 GiB).
  • MLX_BUN_PAGED_KV, --paged-kv: --paged-kv or MLX_BUN_PAGED_KV=1 turns paging on; no flag turns an environment 1 off, and either satisfies --paged-kv-block-size.
  • MLX_BUN_HOME: Root of everything mlx-bun writes by default: models/, adapters/, exports/, datasets/, db/, jobs/, chats, wiki, skills, logs and saved credentials. Unset, ~/.mlx-bun. Explicit paths win; the Hugging Face cache holds only downloads.
  • MLX_BUN_FILL_TRACE: 1 turns fill tracing on. Any other value except empty, 0, and true is a JSONL file path and also turns it on; true turns on neither.