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

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

//[clika-runtime](../../../index.md)/[io.clika.modelverse](../index.md)/[GenerationListener](index.md)

# GenerationListener

[common]\
interface [GenerationListener](index.md)

The stream of one generation. The calls arrive in order on the model's own worker thread, never on the thread that called [GenerativeModel.chat](../GenerativeModel/chat.md): [onToken](onToken.md) and [onThinking](onThinking.md) as text is produced, then exactly one of [onDone](onDone.md) or [onError](onError.md). A listener that needs the main thread posts to it.

## Functions

| Name | Summary |
|---|---|
| [onDone](onDone.md) | [common]<br>abstract fun [onDone](onDone.md)(report: [GenerationReport](../GenerationReport/index.md))<br>The generation ended; [report](onDone.md) says how and what it cost. |
| [onError](onError.md) | [common]<br>abstract fun [onError](onError.md)(message: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html))<br>The generation failed before or during decoding; nothing follows. |
| [onThinking](onThinking.md) | [common]<br>open fun [onThinking](onThinking.md)(text: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html))<br>The next piece of the model's reasoning, on a model whose [Capabilities.thinking](../Capabilities/thinking.md) is not [ThinkingControl.NONE](../ThinkingControl/NONE/index.md) and whose channel is on for the request; never called otherwise. |
| [onToken](onToken.md) | [common]<br>abstract fun [onToken](onToken.md)(text: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html))<br>The next piece of the reply's visible text. |
| [onToolCall](onToolCall.md) | [common]<br>open fun [onToolCall](onToolCall.md)(call: [ToolCall](../ToolCall/index.md))<br>One call the reply made, after its text and before [onDone](onDone.md); the same calls ride [GenerationReport.toolCalls](../GenerationReport/toolCalls.md). Never called when the request offered no tools. |