ChatModel represents a language model that is capable of chat.
Examples::
chat_model = ChatModel.from_pretrained("chat-bison@001")
chat = chat_model.start_chat(
context="My name is Ned. You are my personal assistant. My favorite movies are Lord of the Rings and Hobbit.",
examples=[
InputOutputTextPair(
input_text="Who do you work for?",
output_text="I work for Ned.",
),
InputOutputTextPair(
input_text="What do I like?",
output_text="Ned likes watching movies.",
),
],
temperature=0.3,
)
chat.send_message("Do you know any cool events this weekend?")
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[],null,["# Package language_models (1.95.1)\n\nVersion latestkeyboard_arrow_down\n\n- [1.95.1 (latest)](/python/docs/reference/vertexai/latest/vertexai.language_models)\n- [1.94.0](/python/docs/reference/vertexai/1.94.0/vertexai.language_models)\n- [1.93.1](/python/docs/reference/vertexai/1.93.1/vertexai.language_models)\n- [1.92.0](/python/docs/reference/vertexai/1.92.0/vertexai.language_models)\n- [1.91.0](/python/docs/reference/vertexai/1.91.0/vertexai.language_models)\n- [1.90.0](/python/docs/reference/vertexai/1.90.0/vertexai.language_models)\n- [1.89.0](/python/docs/reference/vertexai/1.89.0/vertexai.language_models)\n- [1.88.0](/python/docs/reference/vertexai/1.88.0/vertexai.language_models)\n- [1.87.0](/python/docs/reference/vertexai/1.87.0/vertexai.language_models)\n- [1.86.0](/python/docs/reference/vertexai/1.86.0/vertexai.language_models)\n- [1.85.0](/python/docs/reference/vertexai/1.85.0/vertexai.language_models)\n- [1.84.0](/python/docs/reference/vertexai/1.84.0/vertexai.language_models)\n- [1.83.0](/python/docs/reference/vertexai/1.83.0/vertexai.language_models)\n- [1.82.0](/python/docs/reference/vertexai/1.82.0/vertexai.language_models)\n- [1.81.0](/python/docs/reference/vertexai/1.81.0/vertexai.language_models)\n- [1.80.0](/python/docs/reference/vertexai/1.80.0/vertexai.language_models)\n- [1.79.0](/python/docs/reference/vertexai/1.79.0/vertexai.language_models)\n- [1.78.0](/python/docs/reference/vertexai/1.78.0/vertexai.language_models)\n- [1.77.0](/python/docs/reference/vertexai/1.77.0/vertexai.language_models)\n- [1.76.0](/python/docs/reference/vertexai/1.76.0/vertexai.language_models)\n- [1.75.0](/python/docs/reference/vertexai/1.75.0/vertexai.language_models)\n- [1.74.0](/python/docs/reference/vertexai/1.74.0/vertexai.language_models)\n- [1.73.0](/python/docs/reference/vertexai/1.73.0/vertexai.language_models)\n- [1.72.0](/python/docs/reference/vertexai/1.72.0/vertexai.language_models)\n- [1.71.1](/python/docs/reference/vertexai/1.71.1/vertexai.language_models)\n- [1.70.0](/python/docs/reference/vertexai/1.70.0/vertexai.language_models)\n- [1.69.0](/python/docs/reference/vertexai/1.69.0/vertexai.language_models)\n- [1.68.0](/python/docs/reference/vertexai/1.68.0/vertexai.language_models)\n- [1.67.1](/python/docs/reference/vertexai/1.67.1/vertexai.language_models)\n- [1.66.0](/python/docs/reference/vertexai/1.66.0/vertexai.language_models)\n- [1.65.0](/python/docs/reference/vertexai/1.65.0/vertexai.language_models)\n- [1.63.0](/python/docs/reference/vertexai/1.63.0/vertexai.language_models)\n- [1.62.0](/python/docs/reference/vertexai/1.62.0/vertexai.language_models)\n- [1.60.0](/python/docs/reference/vertexai/1.60.0/vertexai.language_models)\n- [1.59.0](/python/docs/reference/vertexai/1.59.0/vertexai.language_models) \nAPI documentation for `language_models` package. \n\nClasses\n-------\n\n### [ChatMessage](/python/docs/reference/vertexai/latest/vertexai.language_models.ChatMessage)\n\nA chat message.\n\n### [ChatModel](/python/docs/reference/vertexai/latest/vertexai.language_models.ChatModel)\n\nChatModel represents a language model that is capable of chat.\n\nExamples:: \n\n chat_model = ChatModel.from_pretrained(\"chat-bison@001\")\n\n chat = chat_model.start_chat(\n context=\"My name is Ned. You are my personal assistant. My favorite movies are Lord of the Rings and Hobbit.\",\n examples=[\n InputOutputTextPair(\n input_text=\"Who do you work for?\",\n output_text=\"I work for Ned.\",\n ),\n InputOutputTextPair(\n input_text=\"What do I like?\",\n output_text=\"Ned likes watching movies.\",\n ),\n ],\n temperature=0.3,\n )\n\n chat.send_message(\"Do you know any cool events this weekend?\")\n\n### [ChatSession](/python/docs/reference/vertexai/latest/vertexai.language_models.ChatSession)\n\nChatSession represents a chat session with a language model.\n\nWithin a chat session, the model keeps context and remembers the previous conversation.\n\n### [CodeChatModel](/python/docs/reference/vertexai/latest/vertexai.language_models.CodeChatModel)\n\nCodeChatModel represents a model that is capable of completing code.\n\n.. rubric:: Examples\n\ncode_chat_model = CodeChatModel.from_pretrained(\"codechat-bison@001\")\n\ncode_chat = code_chat_model.start_chat(\ncontext=\"I'm writing a large-scale enterprise application.\",\nmax_output_tokens=128,\ntemperature=0.2,\n)\n\ncode_chat.send_message(\"Please help write a function to calculate the min of two numbers\")\n\n### [CodeChatSession](/python/docs/reference/vertexai/latest/vertexai.language_models.CodeChatSession)\n\nCodeChatSession represents a chat session with code chat language model.\n\nWithin a code chat session, the model keeps context and remembers the previous converstion.\n\n### [CodeGenerationModel](/python/docs/reference/vertexai/latest/vertexai.language_models.CodeGenerationModel)\n\nCreates a LanguageModel.\n\nThis constructor should not be called directly.\nUse `LanguageModel.from_pretrained(model_name=...)` instead.\n\n### [GroundingSource](/python/docs/reference/vertexai/latest/vertexai.language_models.GroundingSource)\n\nAPI documentation for `GroundingSource` class.\n\n### [InputOutputTextPair](/python/docs/reference/vertexai/latest/vertexai.language_models.InputOutputTextPair)\n\nInputOutputTextPair represents a pair of input and output texts.\n\n### [TextEmbedding](/python/docs/reference/vertexai/latest/vertexai.language_models.TextEmbedding)\n\nText embedding vector and statistics.\n\n### [TextEmbeddingInput](/python/docs/reference/vertexai/latest/vertexai.language_models.TextEmbeddingInput)\n\nStructural text embedding input.\n\n### [TextEmbeddingModel](/python/docs/reference/vertexai/latest/vertexai.language_models.TextEmbeddingModel)\n\nCreates a LanguageModel.\n\nThis constructor should not be called directly.\nUse `LanguageModel.from_pretrained(model_name=...)` instead.\n\n### [TextGenerationModel](/python/docs/reference/vertexai/latest/vertexai.language_models.TextGenerationModel)\n\nCreates a LanguageModel.\n\nThis constructor should not be called directly.\nUse `LanguageModel.from_pretrained(model_name=...)` instead.\n\n### [TextGenerationResponse](/python/docs/reference/vertexai/latest/vertexai.language_models.TextGenerationResponse)\n\nTextGenerationResponse represents a response of a language model.\n.. attribute:: text\n\nThe generated text\n\n:type: str\n\nModules\n-------\n\n### [_language_models](/python/docs/reference/vertexai/latest/vertexai.language_models._language_models)\n\nClasses for working with language models."]]