ChatFutures

abstract classChatFutures


Wrapper class providing Java compatible methods forChat.

See also
Chat

Summary

Public companion functions

ChatFutures
from(chat: Chat)

Public functions

abstractChat

Returns theChat object wrapped by this object.

abstractListenableFuture<GenerateContentResponse>

Sends a message using the existing history of this chat as context and the providedContent prompt.

abstractPublisher<GenerateContentResponse>

Sends a message using the existing history of this chat as context and the providedContent prompt.

Public companion functions

from

fun from(chat: Chat): ChatFutures
Returns
ChatFutures

aChatFutures created around the providedChat

Public functions

getChat

abstract fun getChat(): Chat

Returns theChat object wrapped by this object.

sendMessage

abstract fun sendMessage(prompt: Content): ListenableFuture<GenerateContentResponse>

Sends a message using the existing history of this chat as context and the providedContent prompt.

If successful, the message and response will be added to the history. If unsuccessful, history will remain unchanged.

Parameters
prompt: Content

The input(s) that, together with the history, will be given to the model as the prompt.

Throws
com.google.firebase.ai.type.InvalidStateException: com.google.firebase.ai.type.InvalidStateException

ifprompt is not coming from the 'user' role

com.google.firebase.ai.type.InvalidStateException: com.google.firebase.ai.type.InvalidStateException

if theChat instance has an active request

sendMessageStream

abstract fun sendMessageStream(prompt: Content): Publisher<GenerateContentResponse>

Sends a message using the existing history of this chat as context and the providedContent prompt.

The response from the model is returned as a stream.

If successful, the message and response will be added to the history. If unsuccessful, history will remain unchanged.

Parameters
prompt: Content

The input(s) that, together with the history, will be given to the model as the prompt.

Throws
com.google.firebase.ai.type.InvalidStateException: com.google.firebase.ai.type.InvalidStateException

ifprompt is not coming from the 'user' role

com.google.firebase.ai.type.InvalidStateException: com.google.firebase.ai.type.InvalidStateException

if theChat instance has an active request

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-21 UTC.