Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Llama.StartContext

Initializes a context.

Component Version macOS Windows Linux Server iOS SDK
Llama 16.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Llama.StartContext"; LlamaSession { ; Parameters } )   More

Parameters

Parameter Description Example Flags
LlamaSession The session identifier. $$session
Parameters The parameters as JSON. Optional

Result

Returns OK or error.

Description

Initializes a context.
You may pass parameters in the JSON.

KeyDescription
n_ctxtext context, 0 = from model
n_batchlogical maximum batch size that can be submitted to llama_decode
n_ubatchphysical maximum batch size
n_seq_maxmax number of sequences (i.e. distinct states for recurrent models)
n_threadsnumber of threads to use for generation
n_threads_batchnumber of threads to use for batch processing

Examples

Start context:

Set Variable [ $r ; Value: MBS(
    "Llama.StartContext" ;
    $$session ;
    JSONSetElement(
        "{}" ;
        [ "n_ctx" ; 20480 ; JSONNumber ] ;
        [ "n_batch" ; 20480 ; JSONNumber ])
) ]

See also

Example Databases

Blog Entries

Created 10th February 2026, last changed 25th February 2026


Llama.ReleaseAll - Llama.Tokenize