The models endpoint provides a way for you to programmatically list the available models, and retrieve extended metadata such as supported functionality and context window sizing. Read more inthe Models guide.
Method: models.get
Gets information about a specificModelsuch as its version number, token limits,parametersand other metadata. Refer to theGemini models guidefor detailed model information.
Endpoint
gethttps:``/``/generativelanguage.googleapis.com``/v1beta``/{name=models``/*}
Path parameters
name``string
Required. The resource name of the model.
This name should match a model name returned by themodels.listmethod.
Format:models/{model}It takes the formmodels/{model}.
Request body
The request body must be empty.
Example request
Python
from google import genai
client = genai.Client()
model_info = client.models.get(model="gemini-2.0-flash")
print(model_info)
https://github.com/google-gemini/api-examples/blob/856e8a0f566a2810625cecabba6e2ab1fe97e496/python/models.py#L41-L45
Go
ctx := context.Background()
client, err := genai.NewClient(ctx, &genai.ClientConfig{
APIKey: os.Getenv("GEMINI_API_KEY"),
Backend: genai.BackendGeminiAPI,
})
if err != nil {
log.Fatal(err)
}
modelInfo, err := client.Models.Get(ctx, "gemini-2.0-flash", nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(modelInfo)
https://github.com/google-gemini/api-examples/blob/856e8a0f566a2810625cecabba6e2ab1fe97e496/go/models.go#L55-L69
Shell
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash?key=$GEMINI_API_KEY
https://github.com/google-gemini/deprecated-generative-ai-python/blob/7a7cc5474ddaa0255a4410e05361028a24400abd/samples/rest/models.sh#L9-L10
Response body
If successful, the response body contains an instance ofModel.
Method: models.list
Lists theModelsavailable through the Gemini API.
Endpoint
gethttps:``/``/generativelanguage.googleapis.com``/v1beta``/models
Query parameters
pageSize``integer
The maximum number ofModelsto return (per page).
If unspecified, 50 models will be returned per page. This method returns at most 1000 models per page, even if you pass a larger pageSize.
pageToken``string
A page token, received from a previousmodels.listcall.
Provide thepageTokenreturned by one request as an argument to the next request to retrieve the next page.
When paginating, all other parameters provided tomodels.listmust match the call that provided the page token.
Request body
The request body must be empty.
Example request
Python
from google import genai
client = genai.Client()
print("List of models that support generateContent:\n")
for m in client.models.list():
for action in m.supported_actions:
if action == "generateContent":
print(m.name)
print("List of models that support embedContent:\n")
for m in client.models.list():
for action in m.supported_actions:
if action == "embedContent":
print(m.name)
https://github.com/google-gemini/api-examples/blob/856e8a0f566a2810625cecabba6e2ab1fe97e496/python/models.py#L22-L36
Go
ctx := context.Background()
client, err := genai.NewClient(ctx, &genai.ClientConfig{
APIKey: os.Getenv("GEMINI_API_KEY"),
Backend: genai.BackendGeminiAPI,
})
if err != nil {
log.Fatal(err)
}
// Retrieve the list of models.
models, err := client.Models.List(ctx, &genai.ListModelsConfig{})
if err != nil {
log.Fatal(err)
}
fmt.Println("List of models that support generateContent:")
for _, m := range models.Items {
for _, action := range m.SupportedActions {
if action == "generateContent" {
fmt.Println(m.Name)
break
}
}
}
fmt.Println("\nList of models that support embedContent:")
for _, m := range models.Items {
for _, action := range m.SupportedActions {
if action == "embedContent" {
fmt.Println(m.Name)
break
}
}
}
https://github.com/google-gemini/api-examples/blob/856e8a0f566a2810625cecabba6e2ab1fe97e496/go/models.go#L14-L48
Shell
curl https://generativelanguage.googleapis.com/v1beta/models?key=$GEMINI_API_KEY
https://github.com/google-gemini/deprecated-generative-ai-python/blob/7a7cc5474ddaa0255a4410e05361028a24400abd/samples/rest/models.sh#L4-L5
Response body
Response fromListModelcontaining a paginated list of Models.
If successful, the response body contains data with the following structure:
Fieldsmodels[]``object (Model)
The returned Models.
nextPageToken``string
A token, which can be sent aspageTokento retrieve the next page.
If this field is omitted, there are no more pages.
| JSON representation |
|---|
{ "models": [ { object (https://ai.google.dev/api/models#Model) } ], "nextPageToken": string } |
REST Resource: models
Resource: Model
Information about a Generative Language Model.
Fieldsname``string
Required. The resource name of theModel. Refer toModel variantsfor all allowed values.
Format:models/{model}with a{model}naming convention of:
- "{baseModelId}-{version}"
Examples:
models/gemini-1.5-flash-001baseModelId``string
Required. The name of the base model, pass this to the generation request.
Examples:
gemini-1.5-flashversion``string
Required. The version number of the model.
This represents the major version (1.0or1.5)
displayName``string
The human-readable name of the model. E.g. "Gemini 1.5 Flash".
The name can be up to 128 characters long and can consist of any UTF-8 characters.
description``string
A short description of the model.
inputTokenLimit``integer
Maximum number of input tokens allowed for this model.
outputTokenLimit``integer
Maximum number of output tokens available for this model.
supportedGenerationMethods[]``string
The model's supported generation methods.
The corresponding API method names are defined as Pascal case strings, such asgenerateMessageandgenerateContent.
thinking``boolean
Whether the model supports thinking.
temperature``number
Controls the randomness of the output.
Values can range over[0.0,maxTemperature], inclusive. A higher value will produce responses that are more varied, while a value closer to0.0will typically result in less surprising responses from the model. This value specifies default to be used by the backend while making the call to the model.
maxTemperature``number
The maximum temperature this model can use.
topP``number
ForNucleus sampling.
Nucleus sampling considers the smallest set of tokens whose probability sum is at leasttopP. This value specifies default to be used by the backend while making the call to the model.
topK``integer
For Top-k sampling.
Top-k sampling considers the set oftopKmost probable tokens. This value specifies default to be used by the backend while making the call to the model. If empty, indicates the model doesn't use top-k sampling, andtopKisn't allowed as a generation parameter.
| JSON representation |
|---|
{ "name": string, "baseModelId": string, "version": string, "displayName": string, "description": string, "inputTokenLimit": integer, "outputTokenLimit": integer, "supportedGenerationMethods": [ string ], "thinking": boolean, "temperature": number, "maxTemperature": number, "topP": number, "topK": integer } |
Method: models.predict
Performs a prediction request.
Endpoint
posthttps:``/``/generativelanguage.googleapis.com``/v1beta``/{model=models``/*}:predict
Path parameters
model``string
Required. The name of the model for prediction. Format:name=models/{model}. It takes the formmodels/{model}.
Request body
The request body contains data with the following structure:
Fieldsinstances[]``value (Value format)
Required. The instances that are the input to the prediction call.
parameters``value (Value format)
Optional. The parameters that govern the prediction call.
Response body
Response message for [PredictionService.Predict].
If successful, the response body contains data with the following structure:
Fieldspredictions[]``value (Value format)
The outputs of the prediction call.
| JSON representation |
|---|
{ "predictions": [ value ] } |
Method: models.predictLongRunning
Same as models.predict but returns an LRO.
Endpoint
posthttps:``/``/generativelanguage.googleapis.com``/v1beta``/{model=models``/*}:predictLongRunning
Path parameters
model``string
Required. The name of the model for prediction. Format:name=models/{model}.
Request body
The request body contains data with the following structure:
Fieldsinstances[]``value (Value format)
Required. The instances that are the input to the prediction call.
parameters``value (Value format)
Optional. The parameters that govern the prediction call.
Response body
If successful, the response body contains an instance ofOperation.