1. Setup clients
Initialize Freeplay and Google GenAI client SDKs.2. Manage chat history
Maintain a runningmessages list across turns. Pass previous messages as history when fetching the formatted prompt so the model has full conversation context.
3. Fetch prompt from Freeplay
Pull in the formatted prompt with Freeplay. The prompt contains the system instruction and model parameters.4. Call Google GenAI with the tools
When creating a new completion, pass in the tools configuration and formatted prompt contents.5. Handle tool call
When the model responds with a function call, execute the external function in your service. As an example here, we are callingget_current_temperature function. Append both the function call and the function response to the messages list to maintain history.

