Llama.StartContext
------------------

Initializes a context.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Llama](component_Llama.md) | [16.1](newinversion161.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Llama.StartContext"; LlamaSession { ; Parameters } ) 

**MBS**( **"Llama.StartContext";** /\* Initializes a context. \*/  
**$LlamaSession**; /\* The session identifier.e.g. $$session \*/   
**$Parameters**) /\* Optional; The parameters as JSON. \*/ 

### 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.  
  
| Key | Description |
|---|---|
| n\_ctx | text context, 0 = from model |
| n\_batch | logical maximum batch size that can be submitted to llama\_decode |
| n\_ubatch | physical maximum batch size |
| n\_seq\_max | max number of sequences (i.e. distinct states for recurrent models) |
| n\_threads | number of threads to use for generation |
| n\_threads\_batch | number 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

- [Llama.CloseContext](LlamaCloseContext.md)
- [Llama.ContextAvailable](LlamaContextAvailable.md)

### Example Databases

- [Llama chat](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Llama%20chat.shtml#10ScriptAnchor_)

### Blog Entries

- [Use Llama.cpp in FileMaker](https://www.mbsplugins.de/archive/2026-02-17/Use_Llamacpp_in_FileMaker/monkeybreadsoftware_blog_filemaker)

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

  
[Llama.ReleaseAll](LlamaReleaseAll.md) - [Llama.Tokenize](LlamaTokenize.md)

[HTML Version](LlamaStartContext.shtml)