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

    Chat LangChain

    What can I help with?

    Enter to sendยทShift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coreloadserializableSerializable
    Classโ—Since v1.8

    Serializable

    Copy
    Serializable(
        self,
        args: Any = (),
        kwargs: Any = {},
    )

    Bases

    BaseModelABC

    Constructors

    Attributes

    Methods

    View source on GitHub
    constructor
    __init__
    NameType
    argsAny
    kwargsAny
    attribute
    lc_secrets: dict[str, str]

    A map of constructor argument names to secret ids.

    For example, {"openai_api_key": "OPENAI_API_KEY"}

    attribute
    lc_attributes: dict[str, Any]

    List of attribute names that should be included in the serialized kwargs.

    These attributes must be accepted by the constructor.

    Default is an empty dictionary.

    attribute
    model_config
    method
    is_lc_serializable

    Is this class serializable?

    By design, even if a class inherits from Serializable, it is not serializable by default. This is to prevent accidental serialization of objects that should not be serialized.

    method
    get_lc_namespace

    Get the namespace of the LangChain object.

    The default implementation splits cls.__module__ on '.', e.g. langchain_openai.chat_models becomes ["langchain_openai", "chat_models"]. This value is used by lc_id to build the serialization identifier.

    New partner packages should not override this method. The default behavior is correct for any class whose module path already reflects its package name. Some older packages (e.g. langchain-openai, langchain-anthropic) override it to return a legacy-style namespace like ["langchain", "chat_models", "openai"], matching the module paths that existed before those integrations were split out of the main langchain package. Those overrides are kept for backwards-compatible deserialization; new packages should not copy them.

    Deserialization mapping is handled separately by SERIALIZABLE_MAPPING in langchain_core.load.mapping.

    method
    lc_id

    Return a unique identifier for this class for serialization purposes.

    The unique identifier is a list of strings that describes the path to the object.

    For example, for the class langchain.llms.openai.OpenAI, the id is ["langchain", "llms", "openai", "OpenAI"].

    method
    to_json

    Serialize the object to JSON.

    method
    to_json_not_implemented

    Serialize a "not implemented" object.

    Serializable base class.

    This class is used to serialize objects to JSON.

    It relies on the following methods and properties:

    • is_lc_serializable: Is this class serializable?

      By design, even if a class inherits from Serializable, it is not serializable by default. This is to prevent accidental serialization of objects that should not be serialized.

    • get_lc_namespace: Get the namespace of the LangChain object.

      During deserialization, this namespace is used to identify the correct class to instantiate.

      Please see the Reviver class in langchain_core.load.load for more details.

      During deserialization an additional mapping is handle classes that have moved or been renamed across package versions.

    • lc_secrets: A map of constructor argument names to secret ids.

    • lc_attributes: List of additional attribute names that should be included as part of the serialized representation.