Open-Source Wikis

/

LangChain

/

Primitives

langchain-ai/langchain

Primitives

The cross-cutting abstractions that every other package builds on. They all live in libs/core/langchain_core/.

Primitive Purpose Page
Runnables / LCEL Universal invoke/batch/stream protocol; the | operator runnables
Messages and content blocks Conversation turn types and the typed-content taxonomy messages
Language models BaseChatModel, BaseLLM, BaseChatModelV1 language-models
Tools BaseTool, StructuredTool, the @tool decorator tools
Prompts PromptTemplate, ChatPromptTemplate, few-shot variants prompts
Output parsers Turn model output into typed values output-parsers
Callbacks and tracers The observability backbone callbacks-and-tracers

These are the symbols that show up in almost every example, every integration, and every downstream package. Understanding them is the prerequisite for reading the rest of the codebase.

Why "primitives"?

Each item on this page is something users build with, but never look inside. A Runnable is composable; you don't need to know how RunnableSequence.invoke walks its inner steps to use prompt | model | parser. A BaseChatModel is a contract; you don't need to know how ChatOpenAI translates content blocks to use it via init_chat_model.

The pages in this section explain the contracts — what each primitive guarantees, what implementations exist, and how downstream code consumes them.

Layering

graph TD
    Runnable["Runnable / LCEL"]
    Msg[Messages + Content Blocks]
    LM[Language Models]
    Tool[Tools]
    Prompt[Prompts]
    Out[Output Parsers]
    CB[Callbacks / Tracers]
    Doc[Documents / VectorStores]

    Prompt --> Runnable
    LM --> Runnable
    Tool --> Runnable
    Out --> Runnable
    Doc --> Runnable
    LM --> Msg
    Tool --> Msg
    Runnable --> CB
    LM --> CB
    Tool --> CB

Runnable sits at the bottom — almost everything else inherits from it. Messages flow through Language models and Tools. Callbacks observe everything.

Where to go next

  • The overview/architecture page shows how these primitives compose into agents and chains.
  • The packages/core page lists every module in libs/core/langchain_core/.
  • The features section covers the higher-level patterns built on top: agents, middleware, structured output.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Primitives – LangChain wiki | Factory