AutomaticFunctionCalling

class AutomaticFunctionCalling(val functions: List<CallableFunction>, val maximumRemoteCalls: Int = 10, val runFunctionsInParallel: Boolean = false)

The functions the model may ask for during a chat, and the limits on running them.

Passing this is what turns automatic function calling on; there is no separate flag. Leave it out and the model's function calls are returned to you to handle yourself.

val chat = client.chats.create(
model = "gemini-3.6-flash",
automaticFunctionCalling = AutomaticFunctionCalling(getWeather, getForecast),
)

Parameters

functions

a list of CallableFunctions the model may ask for. Names must be unique.

maximumRemoteCalls

how many requests one turn may send before giving up. Your first message counts, so it takes at least two requests for AFC: your initial message, and the FunctionResponse message we send for you after executing your handler. When the limit is reached, handlers are no longer called and you get the model's FunctionCall back.

runFunctionsInParallel

whether several functions asked for in one response may run at the same time. Off by default; turn it on only if your handlers are safe to overlap, which the SDK cannot check for you.

Constructors

Link copied to clipboard
constructor(vararg functions: CallableFunction)
constructor(functions: List<CallableFunction>, maximumRemoteCalls: Int = 10, runFunctionsInParallel: Boolean = false)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard