sendMessage

suspend fun sendMessage(text: String, config: GenerateContentConfig? = null, automaticFunctionCalling: AutomaticFunctionCalling? = null): GenerateContentResponse

Sends text as the next turn and returns the model's response.

The turns so far are sent along with text, so the model has the conversation for context. The message and the response are added to the history once the response arrives.

Parameters

text

The text of the message to send.

config

Replaces the session config for this turn rather than merging with it.

automaticFunctionCalling

Replaces the session setting for this turn. Null uses the session's.


suspend fun sendMessage(content: Content, config: GenerateContentConfig? = null, automaticFunctionCalling: AutomaticFunctionCalling? = null): GenerateContentResponse

Sends content as the next turn and returns the model's response.

The turns so far are sent along with content, so the model has the conversation for context. The message and the response are added to the history once the response arrives.

Parameters

content

The message to send.

config

Replaces the session config for this turn rather than merging with it.

automaticFunctionCalling

Replaces the session setting for this turn. Null uses the session's.


suspend fun sendMessage(contents: List<Content>, config: GenerateContentConfig? = null, automaticFunctionCalling: AutomaticFunctionCalling? = null): GenerateContentResponse

Sends contents as the next turn and returns the model's response.

The turns so far are sent along with contents, so the model has the conversation for context. The message and the response are added to the history once the response arrives.

When automatic function calling is on, one call to this may make several requests: each function the model asks for is run locally and a FunctionResponse is built and sent back to the model, until the model answers or maximumRemoteCalls is reached. The whole exchange is recorded as one turn, and the response returned is the last one the model sent. If the limit is reached the model has not answered yet, a FunctionCall response is returned.

Parameters

contents

The message to send. Several contents are recorded as one turn.

config

Replaces the session config for this turn rather than merging with it.

automaticFunctionCalling

Replaces the session setting for this turn rather than merging with it.