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

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

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

# encodeChat

[common]\
fun [encodeChat](encodeChat.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, addSpecialTokens: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = false): [IntArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html)

Render chat [messages](encodeChat.md) with the template and encode the prompt in one step. The template writes its own bos and eos framing, so the ids are encoded without the special tokens by default; pass [addSpecialTokens](encodeChat.md) only for a template that writes no bos itself.

[common]\
fun [encodeChat](encodeChat.md)(inputs: [ChatTemplateInputs](../ChatTemplateInputs/index.md), options: [ChatTemplateOptions](../ChatTemplateOptions/index.md)? = null, addSpecialTokens: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = false): [IntArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html)

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