Class Models

java.lang.Object
com.google.genai.Models

public final class Models extends Object
  • Constructor Details

    • Models

      public Models(com.google.genai.ApiClient apiClient)
  • Method Details

    • generateImages

      public GenerateImagesResponse generateImages(String model, String prompt, GenerateImagesConfig config) throws IOException, org.apache.http.HttpException
      Throws:
      IOException
      org.apache.http.HttpException
    • generateContent

      public GenerateContentResponse generateContent(String model, List<Content> contents, GenerateContentConfig config) throws IOException, org.apache.http.HttpException
      Generates content given a GenAI model and a content object.
      Parameters:
      model - the name of the GenAI model to use for generation
      contents - a List<Content> to send to the generative model
      config - a GenerateContentConfig instance that specifies the optional configurations
      Returns:
      a GenerateContentResponse instance that contains response contents and other metadata
      Throws:
      IOException - if an I/O error occurs while making the API call
      org.apache.http.HttpException - if an HTTP error occurs while making the API call
    • generateContent

      public GenerateContentResponse generateContent(String model, Content content, GenerateContentConfig config) throws IOException, org.apache.http.HttpException
      Generates content given a GenAI model and a content object.
      Parameters:
      model - the name of the GenAI model to use for generation
      content - a Content to send to the generative model
      config - a GenerateContentConfig instance that specifies the optional configurations
      Returns:
      a GenerateContentResponse instance that contains response contents and other metadata
      Throws:
      IOException - if an I/O error occurs while making the API call
      org.apache.http.HttpException - if an HTTP error occurs while making the API call
    • generateContent

      public GenerateContentResponse generateContent(String model, String text, GenerateContentConfig config) throws IOException, org.apache.http.HttpException
      Generates content given a GenAI model and a text string.
      Parameters:
      model - the name of the GenAI model to use for generation
      text - the text string to send to the generative model
      config - a GenerateContentConfig instance that specifies the optional configurations
      Returns:
      a GenerateContentResponse instance that contains response contents and other metadata
      Throws:
      IOException - if an I/O error occurs while making the API call
      org.apache.http.HttpException - if an HTTP error occurs while making the API call
    • generateContentStream

      public ResponseStream<GenerateContentResponse> generateContentStream(String model, List<Content> contents, GenerateContentConfig config) throws IOException, org.apache.http.HttpException
      Generates content with streaming support given a GenAI model and a content object.
      Parameters:
      model - the name of the GenAI model to use for generation
      contents - a List<Content> to send to the generative model
      config - a GenerateContentConfig instance that specifies the optional configurations
      Returns:
      a GenerateContentResponse instance that contains response contents and other metadata
      Throws:
      IOException - if an I/O error occurs while making the API call
      org.apache.http.HttpException - if an HTTP error occurs while making the API call
    • generateContentStream

      public ResponseStream<GenerateContentResponse> generateContentStream(String model, Content content, GenerateContentConfig config) throws IOException, org.apache.http.HttpException
      Generates content with streaming support given a GenAI model and a content object.
      Parameters:
      model - the name of the GenAI model to use for generation
      content - a Content to send to the generative model
      config - a GenerateContentConfig instance that specifies the optional configurations
      Returns:
      a GenerateContentResponse instance that contains response contents and other metadata
      Throws:
      IOException - if an I/O error occurs while making the API call
      org.apache.http.HttpException - if an HTTP error occurs while making the API call
    • generateContentStream

      public ResponseStream<GenerateContentResponse> generateContentStream(String model, String text, GenerateContentConfig config) throws IOException, org.apache.http.HttpException
      Generates content with streaming support given a GenAI model and a text string.
      Parameters:
      model - the name of the GenAI model to use for generation
      text - the text string to send to the generative model
      config - a GenerateContentConfig instance that specifies the optional configurations
      Returns:
      a GenerateContentResponse instance that contains response contents and other metadata
      Throws:
      IOException - if an I/O error occurs while making the API call
      org.apache.http.HttpException - if an HTTP error occurs while making the API call
    • upscaleImage

      public UpscaleImageResponse upscaleImage(String model, Image image, String upscaleFactor, UpscaleImageConfig config) throws IOException, org.apache.http.HttpException
      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 upscaling
      image - a Image to send to the generative model
      upscaleFactor - the factor to upscale the image
      config - a UpscaleImageConfig instance that specifies the optional configurations
      Returns:
      a UpscaleImageResponse instance that contains the upscaled image.
      Throws:
      IOException - if an I/O error occurs while making the API call
      org.apache.http.HttpException - if an HTTP error occurs while making the API call