---
title: "applyChatTemplate"
sidebar_label: "applyChatTemplate"
description: "Kotlin binding reference: applyChatTemplate."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Tokenizer](index.md)/[applyChatTemplate](applyChatTemplate.md)

# applyChatTemplate

[common]\
fun [applyChatTemplate](applyChatTemplate.md)(messages: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), addGenerationPrompt: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = true): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)

Render chat [messages](applyChatTemplate.md) (a JSON array of `{"role", "content"}` turns, as text) into a prompt with the model's chat template; [addGenerationPrompt](applyChatTemplate.md) appends the assistant-turn priming. A tokenizer with no template, malformed messages or a render error fails typed.

[common]\
fun [applyChatTemplate](applyChatTemplate.md)(inputs: [ChatTemplateInputs](../ChatTemplateInputs/index.md), options: [ChatTemplateOptions](../ChatTemplateOptions/index.md)? = null): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)

Render with the full input set and, when given, per-render [options](applyChatTemplate.md).