chatTemplate property
Optional Jinja chat template that replaces the model's own template.
The value is Jinja source; built-in llama.cpp template names such as
chatml are not recognized.
On llama.cpp (native and WebGPU), LlamaEngine.create and
LlamaEngine.chatTemplate render prompts with it instead of the GGUF
tokenizer.chat_template and its tool_use variant, as llama.cpp's
--chat-template-file does, and detect the tool-call and reasoning
format from it, so output parsing follows the same template. Null or
empty keeps the GGUF template, and LlamaEngine.getMetadata still
reports the GGUF template.
On LiteRT-LM it replaces the built-in template chosen for the bundle,
including an empty string, and drives LlamaEngine.chatTemplate, output
parsing, and prompt rendering on LiteRT-LM web and for requests that
cannot use the native Conversation API. Native LlamaEngine.create
sends eligible chats, including images and audio, through that API,
where the template shapes the prompt only for text-only requests to
filename-matched or positively identified Qwen3 bundles. Unnamed Qwen3
bundles need a Qwen3 model-type declaration or the complete canonical
Qwen3 template in bundle metadata or this override. Legacy bundles with
only generic ChatML metadata cannot be identified after renaming: keep
Qwen3 in the filename or set this to liteRtLmQwen3ChatTemplate, the
public accessor for the installed canonical template. Do not copy its
bytes across package upgrades. Web @litert-lm/core@0.18.0 cannot set a
conversation template and rejects this Qwen3 override at model load with
LlamaUnsupportedException; use native LiteRT-LM for this contract.
Other families keep their native bundle template and content adapter.
A native override receives enable_thinking and must implement it.
A per-call customTemplate takes precedence on every runtime.
Implementation
final String? chatTemplate;