Class Chats

java.lang.Object
com.google.genai.Chats

public class Chats extends Object
A class for creating chat sessions.
  • Method Details

    • create

      public Chat create(String model, GenerateContentConfig config, List<Content> history)
      Creates a new chat session that starts with the given history.

      The history is sent to the model with every message, as if the turns in it had already taken place in this session. Every turn must have the role user or model. A model turn with invalid content is not sent, and neither is the user turn before it.

      Parameters:
      model - The model to use for the chat session.
      config - The configuration for the chat session, or null.
      history - The turns to start the session with.
      Returns:
      The chat session.
      Throws:
      IllegalArgumentException - if a turn has no role, or a role other than user or model.
    • create

      public Chat create(String model, GenerateContentConfig config)
      Creates a new chat session.
      Parameters:
      model - The model to use for the chat session.
      config - The configuration for the chat session.
      Returns:
      The chat session.
    • create

      public Chat create(String model)
      Creates a new chat session.
      Parameters:
      model - The model to use for the chat session.
      Returns:
      The chat session.