Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStatsPractice TestsCertifications

Categories

🎓 Certifications
🤖 Artificial Intelligence
☁️ Cloud and Infrastructure
💾 Data and Databases
💼 Professional Skills
🎯 Programming and Development
🔒 Security and Networking
📚 Specialized Topics
CheatGrid
HomeAboutTopicsPricingMy VaultStatsPractice TestsCertifications
LVLEVEL 0
0/5 XP
GitHub
© 2026 CheatGrid™. All rights reserved.
Privacy PolicyTerms of UseAboutContact

LangChain Cheat Sheet

LangChain Cheat Sheet

Back to Generative AI
Updated 2026-04-28
Next Topic: LangGraph Cheat Sheet

LangChain is a comprehensive framework for building applications powered by large language models (LLMs), transforming simple prompts into production-ready AI agents. With the v1.0 release in October 2025, it has been streamlined around three pillars: create_agent (the new standard agent builder), middleware (composable hooks for customization), and standard content blocks (provider-agnostic message content). LangChain abstracts the complexity of chaining LLM calls, managing memory, integrating tools, and orchestrating retrieval-augmented generation (RAG) pipelines, while LangGraph (stateful graph workflows) and LangSmith (observability) complete the ecosystem. A critical mental model: every component implements the Runnable interface (invoke, stream, batch), and legacy functionality now lives in the separate langchain-classic package.

What This Cheat Sheet Covers

This topic spans 22 focused tables and 169 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Core ComponentsTable 2: LCEL (LangChain Expression Language)Table 3: Memory TypesTable 4: Agent TypesTable 5: Agent Middleware (v1.0)Table 6: Tools and Tool CallingTable 7: Retrieval (RAG Components)Table 8: Advanced RAG PatternsTable 9: Chains (Composing Operations)Table 10: LangGraph (Stateful Workflows)Table 11: Callbacks and ObservabilityTable 12: Streaming and AsyncTable 13: Error Handling and RetriesTable 14: CachingTable 15: Prompt EngineeringTable 16: Document TransformersTable 17: IntegrationsTable 18: Structured OutputTable 19: Advanced Agent PatternsTable 20: Testing and EvaluationTable 21: Production Best PracticesTable 22: Debugging and Troubleshooting

Table 1: Core Components

These are the building blocks you assemble into any LangChain app — chat models, prompts, output parsers, embeddings, vector stores, and the loaders and splitters that prep your data. The unifying idea is that nearly every one of them implements the same Runnable interface, so once you know how one works, you know how to invoke, stream, and batch them all.

ComponentExampleDescription
Chat Models
ChatOpenAI(model="gpt-4o")
ChatAnthropic(model="claude-3-5-sonnet")
• Unified wrappers for conversational LLMs from OpenAI, Anthropic, Google, and more
• returns structured AIMessage objects with metadata
init_chat_model
from langchain.chat_models import init_chat_model
llm = init_chat_model("openai:gpt-4o")
llm = init_chat_model("anthropic:claude-3-5-sonnet")
• Unified model initialization via provider:model string — no provider-specific import needed
• supports fully configurable runtime model selection via config["configurable"]
• recommended v1.0 pattern for provider-agnostic code
Embeddings
OpenAIEmbeddings()
HuggingFaceEmbeddings()
• Convert text to vectors for semantic search
• used with vector stores; supports batch processing for efficiency
Prompts
PromptTemplate(template="Answer: {question}")
ChatPromptTemplate.from_messages([...])
• Templating system for dynamic prompt construction
• supports f-string syntax, Jinja2, and chat message formatting
Output Parsers
JsonOutputParser()
PydanticOutputParser(pydantic_object=MyModel)
• Extract structured data from LLM text responses
• handles JSON, Pydantic models, lists, and custom formats with validation
Runnable Interface
chain.invoke(input)
chain.stream(input)
chain.batch([inputs])
• Unified execution protocol for all LangChain components
• enables invoke (single), stream (tokens), batch (multiple), and async variants

More in Generative AI

  • Knowledge Distillation Cheat Sheet
  • LangGraph Cheat Sheet
  • Advanced RAG Patterns and Optimization Cheat Sheet
  • ColBERT and Late Interaction Retrieval Cheat Sheet
  • LlamaIndex Cheat Sheet
  • pgvector for Postgres Vector Search Cheat Sheet
View all 95 topics in Generative AI