A pipeline connects operations so that the result of one stage can drive the next. In an AI web app, a user request may pass through input preparation, model selection, generation, output formatting, and delivery to the UI. Some workflows also collect feedback for a follow-up response. section 1.2.1 section 1.2.2
LangChain.js calls a reusable composition of operations a chain. Its runnables are units of work that accept input and produce output; they can be invoked, batched, or streamed. The LangChain Expression Language (LCEL) composes them into workflows that can themselves be used as runnables. section 6.1 section 6.1.1 section 6.5.1
Choose the composition to match the data flow:
- Use RunnableSequence or .pipe() when stages must run in order: each output becomes the next input. section 6.5.1
- Use RunnableParallel when several operations can process the same input concurrently and return named results. section 6.5.1
- Wrap a JavaScript function with RunnableLambda to add custom processing alongside prompts, models, retrievers, and output parsers. section 6.5.1 section 6.2.3
A small runnable chain
A JavaScript example uppercases input, counts its vowels, puts the count into a prompt, calls a model, and parses the answer as a string. The same ordered stages can be assembled with .pipe() or RunnableSequence.from([...]). It demonstrates why stage boundaries matter: the prompt needs the vowelCount produced earlier. section 6.1.1
Figure 6.1 A typical LangChain operation chain where it processes data sequentially through a toUpperCase function, then a VowelCount function, then via the LLM, and finally via the StringOutputParser to parse the output.
The diagram makes the handoff between successive functions, the model, and the output parser visible. section 6.1.1
For document retrieval, the pipeline has a preparation side and a query side. Ingest documents, generate embeddings, and store them in a vector store. At query time, a retriever finds relevant documents; a chain formats that context and the question for a prompt, calls the model, and parses its response. Match each stage’s output to the next stage’s expected arguments—a missing context value can break the chain. section 6.2 section 6.2.3
From uploaded document to summary
A summarization app moves an uploaded document through loading, extraction, chunking, and summarization. For a large document, a MapReduce workflow summarizes chunks independently, then combines their summaries into an overview. Next.js supplies the interface, LangChain.js handles the multistep backend workflow, and the Vercel AI SDK connects AI output to UI updates. section 7.1.1 section 7.1.2
A pipeline need not wait until every stage finishes before updating the screen. A LangChain chain can stream its output while a Vercel AI SDK UI stream displays the accumulating response. Keep API credentials in environment configuration when running provider-backed examples. section 6.1.2 section 6.1.1















































