create

fun create(model: String, config: GenerateContentConfig? = null, history: List<Content> = emptyList(), automaticFunctionCalling: AutomaticFunctionCalling? = null): Chat

Creates a chat session.

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

model

The model to talk to, for example "gemini-3.6-flash".

config

Applied to every turn in the session. A config passed to an individual send replaces this one for that turn rather than merging with it.

history

Turns to seed the session with. The turns are copied, so later changes to the list do not affect the session.

automaticFunctionCalling

Configuration for automatic function calling. Passing this is what turns automatic function calling on for the session.

Throws

if a turn in history has a role other than "user" or "model", or if config declares functions by hand while automaticFunctionCalling is also passed in.