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-coreutilspydanticmodel_validate
    Functionā—Since v1.4

    model_validate

    Copy
    model_validate(
        model: TypeBaseModel,
        obj: Any,
    ) -> PydanticBaseModel
    View source on GitHub

    Parameters

    NameTypeDescription
    model*TypeBaseModel

    The Pydantic model class to validate against.

    obj*Any

    The object to validate.

    Validate obj against a Pydantic model class of either major version.

    Dispatches to the correct method for Pydantic v1 (parse_obj) or v2 (model_validate), so callers holding a TypeBaseModel don't have to branch on the model's version themselves.