Runnables and LCEL
A Runnable is a unit of work with standard methods such as invoke, batch, and stream. LangChain Expression Language (LCEL) composes Runnables with |.
Tiny example
Section titled “Tiny example”from langchain_core.output_parsers import StrOutputParserfrom langchain_core.prompts import ChatPromptTemplate
prompt = ChatPromptTemplate.from_template("Summarize ticket: {ticket}")chain = prompt | model | StrOutputParser()
summary = chain.invoke({"ticket": "Checkout returns HTTP 503."})The output of each step becomes the input of the next. A dictionary inside a sequence creates parallel branches; a RunnableSequence runs steps in order.
Failure note
Section titled “Failure note”Composition can hide a wide retry boundary. If prompt | model | send_email is retried as one unit, the email step may run twice. Apply timeout, retry, and tracing configuration to the smallest risky component.