Stay organized with collections Save and categorize content based on your preferences.
Chatclass Chat
Representation of a multi-turn interaction with a model.
Captures and stores the history of communication in memory, and provides it as context with each new message.
Note: This object is not thread-safe, and calling sendMessage
multiple times without waiting for a response will throw an InvalidStateException
.
MutableList<Content>
history
The previous content from the chat that has been successfully sent and received from the model.
Public functions sendMessagesuspend fun sendMessage(prompt: Bitmap): GenerateContentResponse
Sends a message using the existing history of this chat as context and the provided image prompt.
If successful, the message and response will be added to the history. If unsuccessful, history will remain unchanged.
Parametersprompt: Bitmap
The input that, together with the history, will be given to the model as the prompt.
sendMessagesuspend fun sendMessage(prompt: Content): GenerateContentResponse
Sends a message using the provided prompt
; automatically providing the existing history
as context.
If successful, the message and response will be added to the history
. If unsuccessful, history
will remain unchanged.
prompt: Content
The input that, together with the history, will be given to the model as the prompt.
sendMessagesuspend fun sendMessage(prompt: String): GenerateContentResponse
Sends a message using the provided text prompt
; automatically providing the existing history
as context.
If successful, the message and response will be added to the history
. If unsuccessful, history
will remain unchanged.
prompt: String
The input that, together with the history, will be given to the model as the prompt.
sendMessageStreamfun sendMessageStream(prompt: Bitmap): Flow<GenerateContentResponse>
Sends a message using the existing history of this chat as context and the provided image 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.
Parametersprompt: Bitmap
The input that, together with the history, will be given to the model as the prompt.
sendMessageStreamfun sendMessageStream(prompt: Content): Flow<GenerateContentResponse>
Sends a message using the existing history of this chat as context and the provided Content
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.
Parametersprompt: Content
The input that, together with the history, will be given to the model as the prompt.
sendMessageStreamfun sendMessageStream(prompt: String): Flow<GenerateContentResponse>
Sends a message using the existing history of this chat as context and the provided text 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.
Parametersprompt: String
The input(s) that, together with the history, will be given to the model as the prompt.
Public properties historyval history: MutableList<Content>
The previous content from the chat that has been successfully sent and received from the model. This will be provided to the model for each message sent (as context for the discussion).
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-21 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-21 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4