Class AsyncModels
-
- All Implemented Interfaces:
public final class AsyncModelsAsync module of Models
-
-
Constructor Summary
Constructors Constructor Description AsyncModels(ApiClient apiClient)
-
Method Summary
Modifier and Type Method Description CompletableFuture<RecontextImageResponse>recontextImage(String model, RecontextImageSource source, RecontextImageConfig config)Asynchronously recontextualizes an image. CompletableFuture<SegmentImageResponse>segmentImage(String model, SegmentImageSource source, SegmentImageConfig config)Asynchronously segments an image, creating a mask of a specified area. CompletableFuture<Model>get(String model, GetModelConfig config)Asynchronously fetches information about a model by name. CompletableFuture<Model>update(String model, UpdateModelConfig config)Asynchronously updates a tuned model by its name. CompletableFuture<DeleteModelResponse>delete(String model, DeleteModelConfig config)Asynchronously fetches information about a model by name. CompletableFuture<CountTokensResponse>countTokens(String model, List<Content> contents, CountTokensConfig config)Asynchronously counts tokens given a GenAI model and a list of content. CompletableFuture<ComputeTokensResponse>computeTokens(String model, List<Content> contents, ComputeTokensConfig config)Asynchronously computes tokens given a GenAI model and a list of content. CompletableFuture<CountTokensResponse>countTokens(String model, String text, CountTokensConfig config)Asynchronously counts tokens given a GenAI model and a text string. CompletableFuture<ComputeTokensResponse>computeTokens(String model, String text, ComputeTokensConfig config)Asynchronously computes tokens given a GenAI model and a text string. CompletableFuture<GenerateContentResponse>generateContent(String model, List<Content> contents, GenerateContentConfig config)Asynchronously generates content given a GenAI model and a list of content. CompletableFuture<GenerateContentResponse>generateContent(String model, Content content, GenerateContentConfig config)Asynchronously generates content given a GenAI model and a content object. CompletableFuture<GenerateContentResponse>generateContent(String model, String text, GenerateContentConfig config)Asynchronously generates content given a GenAI model and a text string. CompletableFuture<ResponseStream<GenerateContentResponse>>generateContentStream(String model, List<Content> contents, GenerateContentConfig config)Asynchronously generates content with streaming support given a GenAI model and a list of content. CompletableFuture<ResponseStream<GenerateContentResponse>>generateContentStream(String model, Content content, GenerateContentConfig config)Asynchronously generates content with streaming support given a GenAI model and a content object. CompletableFuture<ResponseStream<GenerateContentResponse>>generateContentStream(String model, String text, GenerateContentConfig config)Asynchronously generates content with streaming support given a GenAI model and a text string. CompletableFuture<GenerateImagesResponse>generateImages(String model, String prompt, GenerateImagesConfig config)Asynchronously generates images given a GenAI model and a prompt. CompletableFuture<EditImageResponse>editImage(String model, String prompt, List<ReferenceImage> referenceImages, EditImageConfig config)Asynchronously edits an image given a GenAI model, a prompt, and a list of reference images. CompletableFuture<UpscaleImageResponse>upscaleImage(String model, Image image, String upscaleFactor, UpscaleImageConfig config)Asynchronously upscales an image given a GenAI model and an image and an upscale factor. CompletableFuture<GenerateVideosOperation>generateVideos(String model, GenerateVideosSource source, GenerateVideosConfig config)Asynchronously generates videos given a GenAI model, and a GenerateVideosSource source. CompletableFuture<GenerateVideosOperation>generateVideos(String model, String prompt, Image image, Video video, GenerateVideosConfig config)Asynchronously generates videos given a GenAI model, and an input (text, image, or video). CompletableFuture<GenerateVideosOperation>generateVideos(String model, String prompt, Image image, GenerateVideosConfig config)Asynchronously generates videos given a GenAI model, and an input (text, image). CompletableFuture<EmbedContentResponse>embedContent(String model, String text, EmbedContentConfig config)Asynchronously embeds content given a GenAI model and a text string. CompletableFuture<EmbedContentResponse>embedContent(String model, List<String> texts, EmbedContentConfig config)Asynchronously embeds content given a GenAI model and a list of text strings. CompletableFuture<EmbedContentResponse>embedContent(String model, Content content, EmbedContentConfig config)Asynchronously embeds content given a GenAI model and a content object. CompletableFuture<AsyncPager<Model>>list(ListModelsConfig config)Asynchronously makes an API request to list the available models. -
-
Constructor Detail
-
AsyncModels
AsyncModels(ApiClient apiClient)
-
-
Method Detail
-
recontextImage
CompletableFuture<RecontextImageResponse> recontextImage(String model, RecontextImageSource source, RecontextImageConfig config)
Asynchronously 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
CompletableFuture<SegmentImageResponse> segmentImage(String model, SegmentImageSource source, SegmentImageConfig config)
Asynchronously 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
CompletableFuture<Model> get(String model, GetModelConfig config)
Asynchronously fetches information about a model by name.
-
update
CompletableFuture<Model> update(String model, UpdateModelConfig config)
Asynchronously 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
CompletableFuture<DeleteModelResponse> delete(String model, DeleteModelConfig config)
Asynchronously fetches information about a model by name.
-
countTokens
CompletableFuture<CountTokensResponse> countTokens(String model, List<Content> contents, CountTokensConfig config)
Asynchronously 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
CompletableFuture<ComputeTokensResponse> computeTokens(String model, List<Content> contents, ComputeTokensConfig config)
Asynchronously 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.
-
countTokens
CompletableFuture<CountTokensResponse> countTokens(String model, String text, CountTokensConfig config)
Asynchronously 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
CompletableFuture<ComputeTokensResponse> computeTokens(String model, String text, ComputeTokensConfig config)
Asynchronously 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 count 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
CompletableFuture<GenerateContentResponse> generateContent(String model, List<Content> contents, GenerateContentConfig config)
Asynchronously 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
CompletableFuture<GenerateContentResponse> generateContent(String model, Content content, GenerateContentConfig config)
Asynchronously 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
CompletableFuture<GenerateContentResponse> generateContent(String model, String text, GenerateContentConfig config)
Asynchronously 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
CompletableFuture<ResponseStream<GenerateContentResponse>> generateContentStream(String model, List<Content> contents, GenerateContentConfig config)
Asynchronously 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
CompletableFuture<ResponseStream<GenerateContentResponse>> generateContentStream(String model, Content content, GenerateContentConfig config)
Asynchronously 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
CompletableFuture<ResponseStream<GenerateContentResponse>> generateContentStream(String model, String text, GenerateContentConfig config)
Asynchronously 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
-
generateImages
CompletableFuture<GenerateImagesResponse> generateImages(String model, String prompt, GenerateImagesConfig config)
Asynchronously 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
CompletableFuture<EditImageResponse> editImage(String model, String prompt, List<ReferenceImage> referenceImages, EditImageConfig config)
Asynchronously 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
CompletableFuture<UpscaleImageResponse> upscaleImage(String model, Image image, String upscaleFactor, UpscaleImageConfig config)
Asynchronously 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
CompletableFuture<GenerateVideosOperation> generateVideos(String model, GenerateVideosSource source, GenerateVideosConfig config)
Asynchronously 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
CompletableFuture<GenerateVideosOperation> generateVideos(String model, String prompt, Image image, Video video, GenerateVideosConfig config)
Asynchronously 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
CompletableFuture<GenerateVideosOperation> generateVideos(String model, String prompt, Image image, GenerateVideosConfig config)
Asynchronously 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
CompletableFuture<EmbedContentResponse> embedContent(String model, String text, EmbedContentConfig config)
Asynchronously 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
CompletableFuture<EmbedContentResponse> embedContent(String model, List<String> texts, EmbedContentConfig config)
Asynchronously 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.
-
embedContent
CompletableFuture<EmbedContentResponse> embedContent(String model, Content content, EmbedContentConfig config)
Asynchronously embeds content given a GenAI model and a content object.
- Parameters:
model- the name of the GenAI model to use for embeddingcontent- a com.google.genai.types.Content to send to the embedding model- Returns:
a com.google.genai.types.EmbedContentResponse instance that contains the embedding.
-
list
CompletableFuture<AsyncPager<Model>> list(ListModelsConfig config)
Asynchronously makes an API request to list the available models.
- Parameters:
config- A ListModelsConfig for configuring the list request.- Returns:
A CompletableFuture that resolves to a AsyncPager. The AsyncPager has a `forEach` method that can be used to asynchronously process items in the page and automatically query the next page once the current page is exhausted.
-
-
-
-