To avoid service disruption, update to anewer model (for example,
gemini-2.5-flash-lite
).Learn more. Function calling using the Gemini API Stay organized with collections Save and categorize content based on your preferences.
Generative models are powerful at solving many types of problems. However, theyare constrained by limitations like:
- They are frozen after training, leading to stale knowledge.
- They can't query or modify external data.
Function calling can help you overcome some of these limitations.Function calling is sometimes referred to astool use because it allows amodel to use external tools such as APIs and functions to generate its finalresponse.
This guide shows you how you might implement a function call setup similar tothe scenario described in the next major section of this page. At a high-level,here are the steps to set up function calling in your app:
Step 1: Write a function that can provide the model with information thatit needs to generate its final response (for example, the function can call anexternal API).
Step 2: Create a function declaration that describes the function and itsparameters.
Step 3: Provide the function declaration during model initialization sothat the model knows how it can use the function, if needed.
Step 4: Set up your app so that the model can send along the requiredinformation for your app to call the function.
Step 5: Pass the function's response back to the model so that the modelcan generate its final response.
Overview of a function calling example
When you send a request to the model, you can also provide the model with a setof "tools" (like functions) that it can use to generate its final response. Inorder to utilize these functions and call them ("function calling"), the modeland your app need to pass information back-and-forth to each other, so therecommended way to use function calling is through the multi-turn chatinterface.
Imagine that you have an app where a user could enter a prompt like:What was the weather in Boston on October 17, 2024?
.
TheGemini models may not know this weather information; however,imagine that you know of an external weather service API that can provide it.You can use function calling to give theGemini model a pathway to thatAPI and its weather information.
First, you write a functionfetchWeather
in your app that interacts with thishypothetical external API, which has this input and output:
Parameter | Type | Required | Description |
---|---|---|---|
Input | |||
location | Object | Yes | The name of the city and its state for which to get the weather. Only cities in the USA are supported. Must always be a nested object of city andstate . |
date | String | Yes | Date for which to fetch the weather (must always be inYYYY-MM-DD format). |
Output | |||
temperature | Integer | Yes | Temperature (in Fahrenheit) |
chancePrecipitation | String | Yes | Chance of precipitation (expressed as a percentage) |
cloudConditions | String | Yes | Cloud conditions (one ofclear ,partlyCloudy ,mostlyCloudy ,cloudy ) |
When initializing the model, you tell the model that thisfetchWeather
function exists and how it can be used to process incoming requests, if needed.This is called a "function declaration".The model does not call the functiondirectly. Instead, as the model is processing the incoming request, itdecides if thefetchWeather
function can help it respond to the request. Ifthe model decides that the function can indeed be useful, the model generatesstructured data that will helpyour app call the function.
Look again at the incoming request:What was the weather in Boston on October 17, 2024?
. The model would likelydecide that thefetchWeather
function can help it generate a response. Themodel would look at what input parameters are needed forfetchWeather
and thengenerate structured input data for the function that looks roughly like this:
{functionName:fetchWeather,location:{city:Boston,state:Massachusetts// the model can infer the state from the prompt},date:2024-10-17}
The model passes this structured input data to your app so that your app cancall thefetchWeather
function. When your app receives the weather conditionsback from the API, it passes the information along to the model. This weatherinformation allows the model to complete its final processing and generate itsresponse to the initial request ofWhat was the weather in Boston on October 17, 2024?
The model might provide a final natural-language response like:On October 17, 2024, in Boston, it was 38 degrees Fahrenheit with partly cloudy skies.
Implement function calling
The following steps in this guide show you how to implement a function callsetup similar to the workflow described inOverview of a function calling example(see the top section of this page).
Before you begin
Click yourGemini API provider to view provider-specific content and code on this page. |
If you haven't already, complete thegetting started guide, which describes how toset up your Firebase project, connect your app to Firebase, add the SDK,initialize the backend service for your chosenGemini API provider, andcreate aGenerativeModel
instance.
This guide assumes you're using the latestFirebase AI Logic SDKs. If you're still using the "Vertex AI in Firebase" SDKs, see themigration guide.
For testing and iterating on your prompts, we recommend usingGoogle AI Studio.Step 1: Write the function
Imagine that you have an app where a user could enter a prompt like:What was the weather in Boston on October 17, 2024?
. TheGeminimodels may not know this weather information; however, imagine that you know ofan external weather service API that can provide it. The scenario in this guiderelies on this hypothetical external API.
Write the function in your app that will interact with the hypothetical externalAPI and provide the model with the information it needs to generate its finalrequest. In this weather example, it will be afetchWeather
function thatmakes the call to this hypothetical external API.
Swift
// This function calls a hypothetical external API that returns// a collection of weather information for a given location on a given date.funcfetchWeather(city:String,state:String,date:String)->JSONObject{// TODO(developer): Write a standard function that would call an external weather API.// For demo purposes, this hypothetical response is hardcoded here in the expected format.return["temperature":.number(38),"chancePrecipitation":.string("56%"),"cloudConditions":.string("partlyCloudy"),]}
Kotlin
// This function calls a hypothetical external API that returns// a collection of weather information for a given location on a given date.// `location` is an object of the form { city: string, state: string }dataclassLocation(valcity:String,valstate:String)suspendfunfetchWeather(location:Location,date:String):JsonObject{// TODO(developer): Write a standard function that would call to an external weather API.// For demo purposes, this hypothetical response is hardcoded here in the expected format.returnJsonObject(mapOf("temperature"toJsonPrimitive(38),"chancePrecipitation"toJsonPrimitive("56%"),"cloudConditions"toJsonPrimitive("partlyCloudy")))}
Java
// This function calls a hypothetical external API that returns// a collection of weather information for a given location on a given date.// `location` is an object of the form { city: string, state: string }publicJsonObjectfetchWeather(Locationlocation,Stringdate){// TODO(developer): Write a standard function that would call to an external weather API.// For demo purposes, this hypothetical response is hardcoded here in the expected format.returnnewJsonObject(Map.of("temperature",JsonPrimitive(38),"chancePrecipitation",JsonPrimitive("56%"),"cloudConditions",JsonPrimitive("partlyCloudy")));}
Web
// This function calls a hypothetical external API that returns// a collection of weather information for a given location on a given date.// `location` is an object of the form { city: string, state: string }asyncfunctionfetchWeather({location,date}){// TODO(developer): Write a standard function that would call to an external weather API.// For demo purposes, this hypothetical response is hardcoded here in the expected format.return{temperature:38,chancePrecipitation:"56%",cloudConditions:"partlyCloudy",};}
Dart
// This function calls a hypothetical external API that returns// a collection of weather information for a given location on a given date.// `location` is an object of the form { city: string, state: string }Future<Map<String,Object?>>fetchWeather(Locationlocation,Stringdate)async{// TODO(developer): Write a standard function that would call to an external weather API.// For demo purposes, this hypothetical response is hardcoded here in the expected format.finalapiResponse={'temperature':38,'chancePrecipitation':'56%','cloudConditions':'partlyCloudy',};returnapiResponse;}
Unity
// This function calls a hypothetical external API that returns// a collection of weather information for a given location on a given date.System.Collections.Generic.Dictionary<string,object>FetchWeather(stringcity,stringstate,stringdate){// TODO(developer): Write a standard function that would call an external weather API.// For demo purposes, this hypothetical response is hardcoded here in the expected format.returnnewSystem.Collections.Generic.Dictionary<string,object>(){{"temperature",38},{"chancePrecipitation","56%"},{"cloudConditions","partlyCloudy"},};}
Step 2: Create a function declaration
Create the function declaration that you'll later provide to the model(next step of this guide).
Note: This guide's example demonstrates providing only one function declarationto the model, but you can provideup to 128 function declarations to themodel for it to choose among.In your declaration, include as much detail as possible in the descriptions forthe function and its parameters.
The model uses the information in the function declaration to determine whichfunction to select and how to provide parameter values for the actual call tothe function. SeeAdditional behaviors and optionslater on this page for how the model may choose among the functions, as well ashow you can control that choice.
Note the following about the schema that you provide:
You must provide function declarations in a schema format that's compatiblewith theOpenAPI schema.Vertex AI offers limited support of the OpenAPI schema.
The following attributes are supported:
type
,nullable
,required
,format
,description
,properties
,items
,enum
.The following attributes arenot supported:
default
,optional
,maximum
,oneOf
.
By default, forFirebase AI Logic SDKs, all fields are consideredrequired unless you specify them as optional in an
optionalProperties
array. For these optional fields, the model can populate the fields or skipthem. Note that this is opposite from the default behavior of the twoGemini API providers if you use their server SDKs or their API directly.
For best practices related to the function declarations, including tips fornames and descriptions, seeBest practices in theGemini Developer API documentation.
Here's how you can write a function declaration:
Swift
letfetchWeatherTool=FunctionDeclaration(name:"fetchWeather",description:"Get the weather conditions for a specific city on a specific date.",parameters:["location":.object(properties:["city":.string(description:"The city of the location."),"state":.string(description:"The US state of the location."),],description:""" The name of the city and its state for which to get the weather. Only cities in the USA are supported. """),"date":.string(description:""" The date for which to get the weather. Date must be in the format: YYYY-MM-DD. """),])
Kotlin
valfetchWeatherTool=FunctionDeclaration("fetchWeather","Get the weather conditions for a specific city on a specific date.",mapOf("location"toSchema.obj(mapOf("city"toSchema.string("The city of the location."),"state"toSchema.string("The US state of the location."),),description="The name of the city and its state for which "+"to get the weather. Only cities in the "+"USA are supported."),"date"toSchema.string("The date for which to get the weather."+" Date must be in the format: YYYY-MM-DD."),),)
Java
FunctionDeclarationfetchWeatherTool=newFunctionDeclaration("fetchWeather","Get the weather conditions for a specific city on a specific date.",Map.of("location",Schema.obj(Map.of("city",Schema.str("The city of the location."),"state",Schema.str("The US state of the location."))),"date",Schema.str("The date for which to get the weather. "+"Date must be in the format: YYYY-MM-DD.")),Collections.emptyList());
Web
constfetchWeatherTool:FunctionDeclarationsTool={functionDeclarations:[{name:"fetchWeather",description:"Get the weather conditions for a specific city on a specific date",parameters:Schema.object({properties:{location:Schema.object({description:"The name of the city and its state for which to get "+"the weather. Only cities in the USA are supported.",properties:{city:Schema.string({description:"The city of the location."}),state:Schema.string({description:"The US state of the location."}),},}),date:Schema.string({description:"The date for which to get the weather. Date must be in the"+" format: YYYY-MM-DD.",}),},}),},],};
Dart
finalfetchWeatherTool=FunctionDeclaration('fetchWeather','Get the weather conditions for a specific city on a specific date.',parameters:{'location':Schema.object(description:'The name of the city and its state for which to get''the weather. Only cities in the USA are supported.',properties:{'city':Schema.string(description:'The city of the location.'),'state':Schema.string(description:'The US state of the location.'),},),'date':Schema.string(description:'The date for which to get the weather. Date must be in the format: YYYY-MM-DD.'),},);
Unity
varfetchWeatherTool=newTool(newFunctionDeclaration(name:"fetchWeather",description:"Get the weather conditions for a specific city on a specific date.",parameters:newSystem.Collections.Generic.Dictionary<string,Schema>(){{"location",Schema.Object(properties:newSystem.Collections.Generic.Dictionary<string,Schema>(){{"city",Schema.String(description:"The city of the location.")},{"state",Schema.String(description:"The US state of the location.")}},description:"The name of the city and its state for which to get the weather. Only cities in the USA are supported.")},{"date",Schema.String(description:"The date for which to get the weather. Date must be in the format: YYYY-MM-DD.")}}));
Step 3: Provide the function declaration during model initialization
The maximum number of function declarations that you can provide with therequest is 128. SeeAdditional behaviors and optionslater on this page for how the model may choose among the functions, as well ashow you can control that choice (using atoolConfig
to set thefunction calling mode).
Swift
importFirebaseAI// Initialize the Gemini Developer API backend service// Create a `GenerativeModel` instance with a model that supports your use caseletmodel=FirebaseAI.firebaseAI(backend:.googleAI()).generativeModel(modelName:"gemini-2.5-flash",// Provide the function declaration to the model.tools:[.functionDeclarations([fetchWeatherTool])])
Kotlin
// Initialize the Gemini Developer API backend service// Create a `GenerativeModel` instance with a model that supports your use casevalmodel=Firebase.ai(backend=GenerativeBackend.googleAI()).generativeModel(modelName="gemini-2.5-flash",// Provide the function declaration to the model.tools=listOf(Tool.functionDeclarations(listOf(fetchWeatherTool))))
Java
// Initialize the Gemini Developer API backend service// Create a `GenerativeModel` instance with a model that supports your use caseGenerativeModelFuturesmodel=GenerativeModelFutures.from(FirebaseAI.getInstance(GenerativeBackend.googleAI()).generativeModel("gemini-2.5-flash",null,null,// Provide the function declaration to the model.List.of(Tool.functionDeclarations(List.of(fetchWeatherTool)))));
Web
import{initializeApp}from"firebase/app";import{getAI,getGenerativeModel,GoogleAIBackend}from"firebase/ai";// TODO(developer) Replace the following with your app's Firebase configuration// See: https://firebase.google.com/docs/web/learn-more#config-objectconstfirebaseConfig={// ...};// Initialize FirebaseAppconstfirebaseApp=initializeApp(firebaseConfig);// Initialize the Gemini Developer API backend serviceconstfirebaseAI=getAI(firebaseApp,{backend:newGoogleAIBackend()});// Create a `GenerativeModel` instance with a model that supports your use caseconstmodel=getGenerativeModel(firebaseAI,{model:"gemini-2.5-flash",// Provide the function declaration to the model.tools:fetchWeatherTool});
Dart
import'package:firebase_ai/firebase_ai.dart';import'package:firebase_core/firebase_core.dart';import'firebase_options.dart';// Initialize FirebaseAppawaitFirebase.initializeApp(options:DefaultFirebaseOptions.currentPlatform,);// Initialize the Gemini Developer API backend service// Create a `GenerativeModel` instance with a model that supports your use case_functionCallModel=FirebaseAI.googleAI().generativeModel(model:'gemini-2.5-flash',// Provide the function declaration to the model.tools:[Tool.functionDeclarations([fetchWeatherTool]),],);
Unity
usingFirebase;usingFirebase.AI;// Initialize the Gemini Developer API backend service// Create a `GenerativeModel` instance with a model that supports your use casevarmodel=FirebaseAI.DefaultInstance.GetGenerativeModel(modelName:"gemini-2.5-flash",// Provide the function declaration to the model.tools:newTool[]{fetchWeatherTool});
Learn how to choose amodelappropriate for your use case and app.
Step 4: Call the function to invoke the external API
If the model decides that thefetchWeather
function can indeed help itgenerate a final response, your app needs to make the actual call to thatfunction using the structured input data provided by the model.
Since information needs to be passed back-and-forth between the model and theapp, the recommended way to use function calling is through the multi-turn chatinterface.
The following code snippet shows how your app is told that the model wants touse thefetchWeather
function. It also shows that the model has provided thenecessary input parameter values for the function call (and its underlyingexternal API).
In this example, the incoming request contained the promptWhat was the weather in Boston on October 17, 2024?
. From this prompt, themodel inferred the input parameters that are required by thefetchWeather
function (that is,city
,state
, anddate
).
Swift
letchat=model.startChat()letprompt="What was the weather in Boston on October 17, 2024?"// Send the user's question (the prompt) to the model using multi-turn chat.letresponse=tryawaitchat.sendMessage(prompt)varfunctionResponses=[FunctionResponsePart]()// When the model responds with one or more function calls, invoke the function(s).forfunctionCallinresponse.functionCalls{iffunctionCall.name=="fetchWeather"{// TODO(developer): Handle invalid arguments.guardcaselet.object(location)=functionCall.args["location"]else{fatalError()}guardcaselet.string(city)=location["city"]else{fatalError()}guardcaselet.string(state)=location["state"]else{fatalError()}guardcaselet.string(date)=functionCall.args["date"]else{fatalError()}functionResponses.append(FunctionResponsePart(name:functionCall.name,// Forward the structured input data prepared by the model// to the hypothetical external API.response:fetchWeather(city:city,state:state,date:date)))}// TODO(developer): Handle other potential function calls, if any.}
Kotlin
valprompt="What was the weather in Boston on October 17, 2024?"valchat=model.startChat()// Send the user's question (the prompt) to the model using multi-turn chat.valresult=chat.sendMessage(prompt)valfunctionCalls=result.functionCalls// When the model responds with one or more function calls, invoke the function(s).valfetchWeatherCall=functionCalls.find{it.name=="fetchWeather"}// Forward the structured input data prepared by the model// to the hypothetical external API.valfunctionResponse=fetchWeatherCall?.let{// Alternatively, if your `Location` class is marked as @Serializable, you can use// val location = Json.decodeFromJsonElement<Location>(it.args["location"]!!)vallocation=Location(it.args["location"]!!.jsonObject["city"]!!.jsonPrimitive.content,it.args["location"]!!.jsonObject["state"]!!.jsonPrimitive.content)valdate=it.args["date"]!!.jsonPrimitive.contentfetchWeather(location,date)}
Java
Stringprompt="What was the weather in Boston on October 17, 2024?";ChatFutureschatFutures=model.startChat();// Send the user's question (the prompt) to the model using multi-turn chat.ListenableFuture<GenerateContentResponse>response=chatFutures.sendMessage(newContent("user",List.of(newTextPart(prompt))));ListenableFuture<JsonObject>handleFunctionCallFuture=Futures.transform(response,result->{for(FunctionCallPartfunctionCall:result.getFunctionCalls()){if(functionCall.getName().equals("fetchWeather")){Map<String,JsonElement>args=functionCall.getArgs();JsonObjectlocationJsonObject=JsonElementKt.getJsonObject(args.get("location"));Stringcity=JsonElementKt.getContentOrNull(JsonElementKt.getJsonPrimitive(locationJsonObject.get("city")));Stringstate=JsonElementKt.getContentOrNull(JsonElementKt.getJsonPrimitive(locationJsonObject.get("state")));Locationlocation=newLocation(city,state);Stringdate=JsonElementKt.getContentOrNull(JsonElementKt.getJsonPrimitive(args.get("date")));returnfetchWeather(location,date);}}returnnull;},Executors.newSingleThreadExecutor());
Web
constchat=model.startChat();constprompt="What was the weather in Boston on October 17, 2024?";// Send the user's question (the prompt) to the model using multi-turn chat.letresult=awaitchat.sendMessage(prompt);constfunctionCalls=result.response.functionCalls();letfunctionCall;letfunctionResult;// When the model responds with one or more function calls, invoke the function(s).if(functionCalls.length>0){for(constcalloffunctionCalls){if(call.name==="fetchWeather"){// Forward the structured input data prepared by the model// to the hypothetical external API.functionResult=awaitfetchWeather(call.args);functionCall=call;}}}
Dart
finalchat=_functionCallModel.startChat();constprompt='What was the weather in Boston on October 17, 2024?';// Send the user's question (the prompt) to the model using multi-turn chat.varresponse=awaitchat.sendMessage(Content.text(prompt));finalfunctionCalls=response.functionCalls.toList();// When the model responds with one or more function calls, invoke the function(s).if(functionCalls.isNotEmpty){for(finalfunctionCallinfunctionCalls){if(functionCall.name=='fetchWeather'){Map<String,dynamic>location=functionCall.args['location']!asMap<String,dynamic>;vardate=functionCall.args['date']!asString;varcity=location['city']asString;varstate=location['state']asString;finalfunctionResult=awaitfetchWeather(Location(city,state),date);// Send the response to the model so that it can use the result to// generate text for the user.response=awaitfunctionCallChat.sendMessage(Content.functionResponse(functionCall.name,functionResult),);}}}else{throwUnimplementedError('Function not declared to the model:${functionCall.name}',);}
Unity
varchat=model.StartChat();varprompt="What was the weather in Boston on October 17, 2024?";// Send the user's question (the prompt) to the model using multi-turn chat.varresponse=awaitchat.SendMessageAsync(prompt);varfunctionResponses=newList<ModelContent>();foreach(varfunctionCallinresponse.FunctionCalls){if(functionCall.Name=="fetchWeather"){// TODO(developer): Handle invalid arguments.varcity=functionCall.Args["city"]asstring;varstate=functionCall.Args["state"]asstring;vardate=functionCall.Args["date"]asstring;functionResponses.Add(ModelContent.FunctionResponse(name:functionCall.Name,// Forward the structured input data prepared by the model// to the hypothetical external API.response:FetchWeather(city:city,state:state,date:date)));}// TODO(developer): Handle other potential function calls, if any.}
Step 5: Provide the function's output to the model to generate the final response
After thefetchWeather
function returns the weather information, your appneeds to pass it back to the model.
Then, the model performs its final processing, and generates a finalnatural-language response like:On October 17, 2024 in Boston, it was 38 degrees Fahrenheit with partly cloudy skies.
Swift
// Send the response(s) from the function back to the model// so that the model can use it to generate its final response.letfinalResponse=tryawaitchat.sendMessage([ModelContent(role:"function",parts:functionResponses)])// Log the text response.print(finalResponse.text??"No text in response.")
Kotlin
// Send the response(s) from the function back to the model// so that the model can use it to generate its final response.valfinalResponse=chat.sendMessage(content("function"){part(FunctionResponsePart("fetchWeather",functionResponse!!))})// Log the text response.println(finalResponse.text?:"No text in response")
Java
ListenableFuture<GenerateContentResponse>modelResponseFuture=Futures.transformAsync(handleFunctionCallFuture,// Send the response(s) from the function back to the model// so that the model can use it to generate its final response.functionCallResult->chatFutures.sendMessage(newContent("function",List.of(newFunctionResponsePart("fetchWeather",functionCallResult)))),Executors.newSingleThreadExecutor());Futures.addCallback(modelResponseFuture,newFutureCallback<GenerateContentResponse>(){@OverridepublicvoidonSuccess(GenerateContentResponseresult){if(result.getText()!=null){// Log the text response.System.out.println(result.getText());}}@OverridepublicvoidonFailure(Throwablet){// handle error}},Executors.newSingleThreadExecutor());
Web
// Send the response from the function back to the model// so that the model can use it to generate its final response.result=awaitchat.sendMessage([{functionResponse:{name:functionCall.name,// "fetchWeather"response:functionResult,},},]);console.log(result.response.text());
Dart
// Send the response from the function back to the model// so that the model can use it to generate its final response.response=awaitchat.sendMessage(Content.functionResponse(functionCall.name,functionResult));
Unity
// Send the response(s) from the function back to the model// so that the model can use it to generate its final response.varfinalResponse=awaitchat.SendMessageAsync(functionResponses);// Log the text response.UnityEngine.Debug.Log(finalResponse.Text??"No text in response.");
Additional behaviors and options
Here are some additional behaviors for function calling that you need toaccommodate in your code and options that you can control.
The model may ask to call a function again or another function.
If the response from one function call is insufficient for the model to generateits final response, then the model may ask for an additional function call, orask for a call to an entirely different function. The latter can only happen ifyou provide more than one function to the model in your function declarationlist.
Your app needs to accommodate that the model may ask for additional functioncalls.
The model may ask to call multiple functions at the same time.
You can provide up to 128 functions in your function declaration list to themodel. Given this, the model may decide that multiple functions are needed tohelp it generate its final response. And it might decide to call some of thesefunctions at the same time – this is calledparallel function calling.
Your app needs to accommodate that the model may ask for multiple functionsrunning at the same time, and your app needs to provide all the responses fromthe functions back to the model.
You can control how and if the model can ask to call functions.
You can place some constraints on how and if the model should use the providedfunction declarations. This is called setting thefunction calling mode.Here are some examples:
Instead of allowing the model to choose between an immediate naturallanguage response and a function call, you can force it to always usefunction calls. This is calledforced function calling.
If you provide multiple function declarations, you can restrict the model tousing only a subset of the functions provided.
You implement these constraints (or modes) by adding a tool configuration(toolConfig
) along with the prompt and the function declarations. In the toolconfiguration, you can specify one of the followingmodes. The most usefulmode isANY
.
Mode | Description |
---|---|
AUTO | The default model behavior. The model decides whether to use a function call or a natural language response. |
ANY | The model must use function calls ("forced function calling"). To limit the model to a subset of functions, specify the allowed function names inallowedFunctionNames . |
NONE | The model must not use function calls. This behavior is equivalent to a model request without any associated function declarations. |
What else can you do?
Try out other capabilities
- Buildmulti-turn conversations (chat).
- Generate text fromtext-only prompts.
- Generate text by prompting with various file types, likeimages,PDFs,video, andaudio.
Learn how to control content generation
- Understand prompt design, including best practices, strategies, and example prompts.
- Configure model parameters like temperature and maximum output tokens (forGemini) or aspect ratio and person generation (forImagen).
- Use safety settings to adjust the likelihood of getting responses that may be considered harmful.
Learn more about the supported models
Learn about themodels available for various use casesand theirquotas andpricing.Give feedback about your experience withFirebase AI Logic
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-03 UTC.