Class Models
-
-
Method Summary
Modifier and Type Method Description RecontextImageResponserecontextImage(String model, RecontextImageSource source, RecontextImageConfig config)Recontextualizes an image. SegmentImageResponsesegmentImage(String model, SegmentImageSource source, SegmentImageConfig config)Segments an image, creating a mask of a specified area. Modelget(String model, GetModelConfig config)Fetches information about a model by name. Modelupdate(String model, UpdateModelConfig config)Updates a tuned model by its name. DeleteModelResponsedelete(String model, DeleteModelConfig config)Fetches information about a model by name. CountTokensResponsecountTokens(String model, List<Content> contents, CountTokensConfig config)Counts tokens given a GenAI model and a list of content. ComputeTokensResponsecomputeTokens(String model, List<Content> contents, ComputeTokensConfig config)Computes tokens given a GenAI model and a list of content. GenerateContentResponsegenerateContent(String model, List<Content> contents, GenerateContentConfig config)Generates content given a GenAI model and a list of content. GenerateContentResponsegenerateContent(String model, Content content, GenerateContentConfig config)Generates content given a GenAI model and a content object. GenerateContentResponsegenerateContent(String model, String text, GenerateContentConfig config)Generates content given a GenAI model and a text string. ResponseStream<GenerateContentResponse>generateContentStream(String model, List<Content> contents, GenerateContentConfig config)Generates content with streaming support given a GenAI model and a list of content. ResponseStream<GenerateContentResponse>generateContentStream(String model, Content content, GenerateContentConfig config)Generates content with streaming support given a GenAI model and a content object. ResponseStream<GenerateContentResponse>generateContentStream(String model, String text, GenerateContentConfig config)Generates content with streaming support given a GenAI model and a text string. CountTokensResponsecountTokens(String model, String text, CountTokensConfig config)Counts tokens given a GenAI model and a text string. ComputeTokensResponsecomputeTokens(String model, String text, ComputeTokensConfig config)Computes tokens given a GenAI model and a text string. GenerateImagesResponsegenerateImages(String model, String prompt, GenerateImagesConfig config)Generates images given a GenAI model and a prompt. EditImageResponseeditImage(String model, String prompt, List<ReferenceImage> referenceImages, EditImageConfig config)Edits an image given a GenAI model, a prompt, and a list of reference images. UpscaleImageResponseupscaleImage(String model, Image image, String upscaleFactor, UpscaleImageConfig config)Upscales an image given a GenAI model and an image and an upscale factor. GenerateVideosOperationgenerateVideos(String model, GenerateVideosSource source, GenerateVideosConfig config)Generates videos given a GenAI model, and a GenerateVideosSource source. GenerateVideosOperationgenerateVideos(String model, String prompt, Image image, Video video, GenerateVideosConfig config)Generates videos given a GenAI model, and an input (text, image, or video). GenerateVideosOperationgenerateVideos(String model, String prompt, Image image, GenerateVideosConfig config)Generates videos given a GenAI model, and an input (text, image). EmbedContentResponseembedContent(String model, String text, EmbedContentConfig config)Embeds content given a GenAI model and a text string. EmbedContentResponseembedContent(String model, Content content, EmbedContentConfig config)Embeds content given a GenAI model and a content object. EmbedContentResponseembedContent(String model, List<String> texts, EmbedContentConfig config)Embeds content given a GenAI model and a list of text strings. Pager<Model>list(ListModelsConfig config)Makes an API request to list the available models. -
-
Constructor Detail
-
Models
Models(ApiClient apiClient)
-
-
Method Detail
-
recontextImage
RecontextImageResponse recontextImage(String model, RecontextImageSource source, RecontextImageConfig config)
Recontextualizes an image.
There is one type of recontextualization currently supported: 1) Virtual Try-On: Generate images of persons modeling fashion products.
- Parameters:
model- the name of the GenAI model to use for image recontextsource- a com.google.genai.types.RecontextImageSource An object containing the source inputs (prompt, personImage, productImages) for image recontext.config- a com.google.genai.types.RecontextImageConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.RecontextImageResponse instance that contains the generated images.
-
segmentImage
SegmentImageResponse segmentImage(String model, SegmentImageSource source, SegmentImageConfig config)
Segments an image, creating a mask of a specified area.
- Parameters:
model- the name of the GenAI model to use for image segmentationsource- a com.google.genai.types.SegmentImageSource An object containing the source inputs (prompt, image, scribbleImmage) for image segmentation.config- a com.google.genai.types.SegmentImageConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.SegmentImageResponse instance that contains the generated mask.
-
get
Model get(String model, GetModelConfig config)
Fetches information about a model by name.
-
update
Model update(String model, UpdateModelConfig config)
Updates a tuned model by its name.
- Parameters:
model- The name of the tuned model to updateconfig- A com.google.genai.types.UpdateModelConfig instance that specifies the optional configurations- Returns:
A com.google.genai.types.Model instance
-
delete
DeleteModelResponse delete(String model, DeleteModelConfig config)
Fetches information about a model by name.
-
countTokens
CountTokensResponse countTokens(String model, List<Content> contents, CountTokensConfig config)
Counts tokens given a GenAI model and a list of content.
- Parameters:
model- the name of the GenAI model to use.contents- a < to send to count tokens for.config- a com.google.genai.types.CountTokensConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.CountTokensResponse instance that contains tokens count.
-
computeTokens
ComputeTokensResponse computeTokens(String model, List<Content> contents, ComputeTokensConfig config)
Computes tokens given a GenAI model and a list of content.
- Parameters:
model- the name of the GenAI model to use.contents- a < to send to compute tokens for.config- a com.google.genai.types.ComputeTokensConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.ComputeTokensResponse instance that contains tokens results.
-
generateContent
GenerateContentResponse generateContent(String model, List<Content> contents, GenerateContentConfig config)
Generates content given a GenAI model and a list of content.
- Parameters:
model- the name of the GenAI model to use for generationcontents- a < to send to the generative modelconfig- a com.google.genai.types.GenerateContentConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.GenerateContentResponse instance that contains response contents and other metadata
-
generateContent
GenerateContentResponse generateContent(String model, Content content, GenerateContentConfig config)
Generates content given a GenAI model and a content object.
- Parameters:
model- the name of the GenAI model to use for generationcontent- a com.google.genai.types.Content to send to the generative modelconfig- a com.google.genai.types.GenerateContentConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.GenerateContentResponse instance that contains response contents and other metadata
-
generateContent
GenerateContentResponse generateContent(String model, String text, GenerateContentConfig config)
Generates content given a GenAI model and a text string.
- Parameters:
model- the name of the GenAI model to use for generationtext- the text string to send to the generative modelconfig- a com.google.genai.types.GenerateContentConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.GenerateContentResponse instance that contains response contents and other metadata
-
generateContentStream
ResponseStream<GenerateContentResponse> generateContentStream(String model, List<Content> contents, GenerateContentConfig config)
Generates content with streaming support given a GenAI model and a list of content.
- Parameters:
model- the name of the GenAI model to use for generationcontents- a < to send to the generative modelconfig- a com.google.genai.types.GenerateContentConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.GenerateContentResponse instance that contains response contents and other metadata
-
generateContentStream
ResponseStream<GenerateContentResponse> generateContentStream(String model, Content content, GenerateContentConfig config)
Generates content with streaming support given a GenAI model and a content object.
- Parameters:
model- the name of the GenAI model to use for generationcontent- a com.google.genai.types.Content to send to the generative modelconfig- a com.google.genai.types.GenerateContentConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.GenerateContentResponse instance that contains response contents and other metadata
-
generateContentStream
ResponseStream<GenerateContentResponse> generateContentStream(String model, String text, GenerateContentConfig config)
Generates content with streaming support given a GenAI model and a text string.
- Parameters:
model- the name of the GenAI model to use for generationtext- the text string to send to the generative modelconfig- a com.google.genai.types.GenerateContentConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.GenerateContentResponse instance that contains response contents and other metadata
-
countTokens
CountTokensResponse countTokens(String model, String text, CountTokensConfig config)
Counts tokens given a GenAI model and a text string.
- Parameters:
model- the name of the GenAI model to use.text- the text string to send to count tokens for.config- a com.google.genai.types.CountTokensConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.CountTokensResponse instance that contains tokens count.
-
computeTokens
ComputeTokensResponse computeTokens(String model, String text, ComputeTokensConfig config)
Computes tokens given a GenAI model and a text string.
- Parameters:
model- the name of the GenAI model to use.text- the text string to send to compute tokens for.config- a com.google.genai.types.ComputeTokensConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.ComputeTokensResponse instance that contains tokens results.
-
generateImages
GenerateImagesResponse generateImages(String model, String prompt, GenerateImagesConfig config)
Generates images given a GenAI model and a prompt.
- Parameters:
model- the name of the GenAI model to use for generating imagesprompt- the prompt to generate imagesconfig- a com.google.genai.types.GenerateImagesConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.GenerateImagesResponse instance that contains the generated images.
-
editImage
EditImageResponse editImage(String model, String prompt, List<ReferenceImage> referenceImages, EditImageConfig config)
Edits an image given a GenAI model, a prompt, and a list of reference images.
- Parameters:
model- the name of the GenAI model to use for editing capabilitiesprompt- the prompt to edit the imagereferenceImages- a < to send to use for editing.config- a com.google.genai.types.EditImageConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.EditImageResponse instance that contains the edited image.
-
upscaleImage
UpscaleImageResponse upscaleImage(String model, Image image, String upscaleFactor, UpscaleImageConfig config)
Upscales an image given a GenAI model and an image and an upscale factor.
- Parameters:
model- the name of the GenAI model to use for upscalingimage- a com.google.genai.types.Image to send to the generative modelupscaleFactor- the factor to upscale the imageconfig- a com.google.genai.types.UpscaleImageConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.UpscaleImageResponse instance that contains the upscaled image.
-
generateVideos
GenerateVideosOperation generateVideos(String model, GenerateVideosSource source, GenerateVideosConfig config)
Generates videos given a GenAI model, and a GenerateVideosSource source.
This method is experimental.
- Parameters:
model- the name of the GenAI model to use for generating videossource- a com.google.genai.types.GenerateVideosSource that specifies the inputs (prompt, image, and/or video) to generate videos.config- a com.google.genai.types.GenerateVideosConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.GenerateVideosOperation instance that contains the generated videos.
-
generateVideos
GenerateVideosOperation generateVideos(String model, String prompt, Image image, Video video, GenerateVideosConfig config)
Generates videos given a GenAI model, and an input (text, image, or video).
This method is experimental.
- Parameters:
model- the name of the GenAI model to use for generating videosprompt- the text prompt for generating the videos.image- the input image for generating the videos.video- the input video for video extension use cases.config- a com.google.genai.types.GenerateVideosConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.GenerateVideosOperation instance that contains the generated videos.
-
generateVideos
GenerateVideosOperation generateVideos(String model, String prompt, Image image, GenerateVideosConfig config)
Generates videos given a GenAI model, and an input (text, image).
This method is experimental, and kept for backward compatibility.
- Parameters:
model- the name of the GenAI model to use for generating videosprompt- the text prompt for generating the videos.image- the input image for generating the videos.config- a com.google.genai.types.GenerateVideosConfig instance that specifies the optional configurations- Returns:
a com.google.genai.types.GenerateVideosOperation instance that contains the generated videos.
-
embedContent
EmbedContentResponse embedContent(String model, String text, EmbedContentConfig config)
Embeds content given a GenAI model and a text string.
- Parameters:
model- the name of the GenAI model to use for embeddingtext- the text string to send to the embedding model- Returns:
a com.google.genai.types.EmbedContentResponse instance that contains the embedding.
-
embedContent
EmbedContentResponse embedContent(String model, Content content, EmbedContentConfig config)
Embeds content given a GenAI model and a content object.
- Parameters:
model- the name of the GenAI model to use for embeddingcontent- the com.google.genai.types.Content to send to the embedding model- Returns:
a com.google.genai.types.EmbedContentResponse instance that contains the embedding.
-
embedContent
EmbedContentResponse embedContent(String model, List<String> texts, EmbedContentConfig config)
Embeds content given a GenAI model and a list of text strings.
- Parameters:
model- the name of the GenAI model to use for embeddingtexts- the list of text strings to send to the embedding model- Returns:
a com.google.genai.types.EmbedContentResponse instance that contains the embedding.
-
list
Pager<Model> list(ListModelsConfig config)
Makes an API request to list the available models.
If `queryBase` is set to True in the ListModelsConfig or not set (default), the API will return all available base models. If set to False, it will return all tuned models.
- Parameters:
config- A ListModelsConfig for configuring the list request.- Returns:
A Pager object that contains the list of models. The pager is an iterable and automatically queries the next page once the current page is exhausted.
-
-
-
-