LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coretracersbaseBaseTraceron_chat_model_start
    Method●Since v0.1

    on_chat_model_start

    Copy
    on_chat_model_start(
      self,
      serialized: dict[str, Any],
      messages: list[list
    View source on GitHub
    [
    BaseMessage
    ]
    ]
    ,
    *
    ,
    run_id
    :
    UUID
    ,
    tags
    :
    list
    [
    str
    ]
    |
    None
    =
    None
    ,
    parent_run_id
    :
    UUID
    |
    None
    =
    None
    ,
    metadata
    :
    dict
    [
    str
    ,
    Any
    ]
    |
    None
    =
    None
    ,
    name
    :
    str
    |
    None
    =
    None
    ,
    **
    kwargs
    :
    Any
    =
    {
    }
    )
    ->
    Run

    Parameters

    NameTypeDescription
    serialized*dict[str, Any]

    The serialized model.

    messages*list[list[BaseMessage]]

    The messages to start the chat with.

    run_id*UUID
    tagslist[str] | None
    Default:None
    parent_run_idUUID | None
    Default:None
    metadatadict[str, Any] | None
    Default:None
    namestr | None
    Default:None
    **kwargsAny
    Default:{}

    Start a trace for a chat model run.

    Note:

    Naming can be confusing here: there is on_chat_model_start, but no corresponding on_chat_model_end callback. Chat model completion is routed through on_llm_end / _on_llm_end, which are shared with text LLM runs.

    The run ID.

    The tags for the run.

    The parent run ID.

    The metadata for the run.

    The name of the run.

    Additional arguments.