Comparison intermediate · 8 min read

LangChain vs Semantic Kernel: which LLM framework should you choose?

Quick pick

Use LangChain if you need the largest ecosystem of integrations (300+ tools) and most community patterns. Use Semantic Kernel if you prefer C#/.NET or want tighter OpenAI/Azure integration with a smaller learning curve.

VERDICT

LangChain dominates for Python production applications: it has 10x more integrations, stronger agent patterns, and a larger community sharing battle-tested examples. Semantic Kernel wins if you're in the .NET ecosystem or prioritize Microsoft/OpenAI integration. For pure Python LLM work, LangChain is the default choice.

Side-by-side comparison

FeatureLangChainSemantic KernelWinner
Primary Language Python (v0.2+) C# (v1.0+), Python experimental LangChain
Model Support 300+ integrations (OpenAI, Anthropic, Cohere, local) 200+ integrations, Microsoft-first LangChain
Agent Framework ReAct, tools, memory patterns mature Plugins + planner (newer, evolving) LangChain
RAG Maturity Production-ready (chains, retrievers, QA patterns) Growing, integrates Semantic Search LangChain
Community Size 50k+ GitHub stars, large Discord/Reddit presence 8k+ GitHub stars, smaller community LangChain
Learning Curve Steep (many abstractions), docs scattered Moderate (cleaner mental model) Semantic Kernel
Enterprise Support Community-driven, no official SLA Microsoft-backed, Azure integration Semantic Kernel
Installation Size ~200MB with common deps ~80MB base Semantic Kernel
TypeScript Support First-class (langchain.js) Partial (SDK exists, less mature) LangChain
Cost Control Built-in token counting, cost tracking chains Token tracking available Tie

Performance benchmarks

Integration count (Nov 2024)

LangChain 300+ (LangChain docs count)
Semantic Kernel 200+ (Semantic Kernel docs count)

LangChain integrates more third-party tools; Semantic Kernel focuses on Microsoft ecosystem depth

Time to build RAG pipeline (experienced dev)

LangChain ~2-3 hours (chains + retrievers well-documented)
Semantic Kernel ~3-4 hours (requires plugin architecture setup)

LangChain has more tutorials and Stack Overflow answers for RAG patterns

Bundle size (pip install)

LangChain ~200MB (with common deps like langchain_openai)
Semantic Kernel ~80MB (core SDK lighter)

Semantic Kernel ships smaller; LangChain trades size for built-in tool richness

Community Q&A response time (GitHub Issues)

LangChain ~6-24 hours for LangChain core team
Semantic Kernel ~12-48 hours for Microsoft team

LangChain's larger community also answers faster; Semantic Kernel has official SLA on enterprise

When to use each

LangChain
  • ✓ Building a production Python RAG system or multi-step agent: LangChain's chains and memory patterns are battle-tested by 50k+ developers
  • ✓ You need integrations to Pinecone, Weaviate, LlamaIndex, Hugging Face, or any non-Microsoft tool: LangChain's breadth is unmatched
  • ✓ Your team is Python-first and doesn't use .NET: LangChain is the de facto standard, meaning more code examples, Stack Overflow answers, and community tools
  • ✓ You want to experiment with cutting-edge patterns (multi-agent systems, function calling, memory types): LangChain's experimentation velocity is higher
  • ✓ Cost tracking and token counting across LLM calls is critical: LangChain has built-in callbacks for this
Semantic Kernel
  • ✓ Your team is C# or .NET-heavy: Semantic Kernel is the native choice with better language ergonomics
  • ✓ You're already in the Microsoft/Azure ecosystem (Azure OpenAI, Copilot plugins): Semantic Kernel has native bindings
  • ✓ You want a cleaner, smaller API surface: Semantic Kernel's plugin architecture is more opinionated than LangChain's loose chain composition
  • ✓ You need official enterprise support with SLA: Microsoft backs Semantic Kernel
  • ✓ Building lightweight agents with fewer dependencies: Semantic Kernel's core is ~80MB vs LangChain's 200MB+

Common misconceptions

LangChain

✗ LangChain is a single unified framework

✓ LangChain 0.2+ split into separate packages (langchain_openai, langchain_anthropic, etc.). You install only what you need, but this means more pip installs and version management

✗ LangChain RAG is production-ready out of the box

✓ LangChain chains work, but production RAG requires careful tuning of chunk size, embedding model, retriever strategy, and re-ranking. Many LangChain examples are educational prototypes, not production patterns

✗ LangChain agents are as reliable as hardcoded pipelines

✓ LangChain ReAct agents can hallucinate tool calls, get stuck in loops, or fail on edge cases. You need explicit error handling, max iteration caps, and input validation: the docs don't emphasize this heavily

Semantic Kernel

✗ Semantic Kernel is production-ready for Python

✓ The Python SDK is still experimental (0.x versions as of 2026). The stable, production-grade version is C#. If you choose SK for Python, you're inheriting API churn and fewer community examples

✗ Semantic Kernel's plugins are equivalent to LangChain's tools

✓ Plugins are functions + metadata, which is cleaner in theory but less flexible. LangChain tools are just Python callables with optional validation: easier to retrofit existing code

✗ Semantic Kernel makes you vendor-agnostic

✓ Semantic Kernel has tighter coupling to OpenAI/Azure models. While it supports other providers, the planner and many examples assume OpenAI-style function calling

Code examples

Task: Build a retrieval-augmented generation chain that takes a user question, retrieves relevant documents, and generates an answer using an LLM.

LangChain: basic RAG chain with retrieval
python
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
from langchain_chroma import Chroma
from langchain.chains import create_retrieval_chain
from langchain.chains.combine_documents import create_stuff_documents_chain
from langchain_core.prompts import ChatPromptTemplate
import os

# Initialize embeddings and vector store
embeddings = OpenAIEmbeddings(api_key=os.environ["OPENAI_API_KEY"])
vectorstore = Chroma(collection_name="docs", embedding_function=embeddings)

# Create retriever
retriever = vectorstore.as_retriever(search_kwargs={"k": 5})

# Create LLM and prompt
llm = ChatOpenAI(model="gpt-4o", api_key=os.environ["OPENAI_API_KEY"])
prompt = ChatPromptTemplate.from_template(
    "Answer this question using the provided context: {context}\n\nQuestion: {input}"
)

# Create RAG chain
docs_chain = create_stuff_documents_chain(llm, prompt)
rag_chain = create_retrieval_chain(retriever, docs_chain)  # LangChain's fluent chain composition

# Generate answer
result = rag_chain.invoke({"input": "How do I use LangChain for RAG?"})
print(result["answer"])

LangChain's create_retrieval_chain() handles the retriever→LLM pipeline in one call, with built-in document formatting. This pattern is reused across hundreds of tutorials.

Semantic Kernel: basic RAG with plugins
python
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
from semantic_kernel.connectors.ai.embeddings import OpenAITextEmbedding
from semantic_kernel.functions import kernel_function
import os

# Initialize kernel and service
kernel = Kernel()
kernel.add_service(
    OpenAIChatCompletion(
        model_id="gpt-4o",
        api_key=os.environ["OPENAI_API_KEY"]
    )
)

# Add embedding service (note: separate from chat service in SK)
embedding_service = OpenAITextEmbedding(
    api_key=os.environ["OPENAI_API_KEY"]
)

# Define retrieval plugin (manual: SK doesn't bundle vector stores like LangChain)
class RetrievalPlugin:
    @kernel_function(description="Retrieve documents from vector store")
    async def retrieve(self, query: str) -> str:
        # Your vector store call (Pinecone, etc.)
        return "retrieved context..."

kernel.add_plugin(RetrievalPlugin(), "retrieval")  # SK uses explicit plugin registration

# Create RAG prompt and invoke
prompt = """Answer this question using context: {{retrieval.retrieve(input)}}
Question: {{input}}"""
result = await kernel.invoke_prompt_function(prompt, input="How do I use Semantic Kernel for RAG?")
print(result.value)

Semantic Kernel requires explicit plugin registration and manual vector store integration. The 'await' syntax signals SK's async-first design, which differs from LangChain's sync-by-default chains.

Migration path

  1. Migrating from LangChain to Semantic Kernel (or vice versa) requires a full rewrite: they have fundamentally different APIs and mental models.
  2. If moving LangChain→SK: Replace langchain chains with kernel + plugins. Replace retrievers with manual plugin methods. Replace Chat OpenAI with OpenAIChatCompletion. Update prompts from {input} to {{input}} template syntax.
  3. If moving SK→LangChain: Use langchain_openai.ChatOpenAI instead of OpenAIChatCompletion. Replace plugins with tool decorators (@tool). Use create_retrieval_chain() instead of manual plugin composition.
  4. No direct import swap: the abstractions are too different. Plan 2-3 days for a non-trivial migration. For new projects, start with your ecosystem choice (Python→LangChain, .NET→Semantic Kernel) and commit.

RECOMMENDATION

Use LangChain for Python production systems: it has 3x more integrations, mature RAG patterns, and a larger community with more Stack Overflow solutions. Use Semantic Kernel if your team is C#/.NET or if you need Microsoft/Azure deep integration. Switching between them later is a full rewrite, so choose based on your primary language, not just framework features.
Verified 2026-04 · gpt-4o
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.