S9.9

    LangChain vs Building Direct: Which Approach to Use?

    ·
    LangChain vs Building Direct: Which Approach to Use?

    The short answer

    LangChain is a framework that wraps LLM APIs and adds tools for chaining, memory, and agents. Building direct means calling the API yourself with no framework. For simple apps, build direct. For complex multi-step pipelines or if you're prototyping fast with unfamiliar patterns, LangChain can save time. But it has real costs.

    TL;DR

    • →LangChain adds abstractions over LLM APIs. It helps with complex chains but adds overhead.
    • →For simple apps with one or two LLM calls, building direct is faster and easier to debug.
    • →LangChain's strength is chaining multiple steps, tools, and memory together quickly.
    • →LangChain upgrades have broken production apps repeatedly. Direct builds are more stable.
    • →Most experienced builders start direct and add frameworks when they feel the pain of not having them.

    LangChain vs direct: what are you actually choosing between?

    LangChain is a framework that wraps LLM APIs and adds tools for chaining, memory, and agents. Building direct means calling the API yourself with no framework. For simple apps, build direct. For complex multi-step pipelines or if you're prototyping fast with unfamiliar patterns, LangChain can save time. But it has real costs.

    Here's the thing: the LangChain debate has become tribal. Some developers swear by it. Others say it's complexity for no gain. The truth depends on what you're building.

    Direct API builds: what they look like

    Direct means using the official SDK and writing your own logic.

    import anthropic
     
    client = anthropic.Anthropic()
     
    def summarise_document(text: str) -> str:
        response = client.messages.create(
            model="claude-3-5-sonnet-20241022",
            max_tokens=500,
            system="Summarise the following document in 3 bullet points.",
            messages=[{"role": "user", "content": text}]
        )
        return response.content[0].text

    Clean. Easy to read. Easy to debug. When something breaks, you know exactly where.

    LangChain builds: what they look like

    from langchain_anthropic import ChatAnthropic
    from langchain_core.prompts import ChatPromptTemplate
     
    llm = ChatAnthropic(model="claude-3-5-sonnet-20241022")
    prompt = ChatPromptTemplate.from_messages([
        ("system", "Summarise the following document in 3 bullet points."),
        ("user", "{document}")
    ])
    chain = prompt | llm
    result = chain.invoke({"document": text})

    Slightly more setup. The value shows when you chain multiple steps, add retrieval, or connect tools.

    Side-by-side comparison

    FactorLangChainDirect API
    Setup speedFast (abstractions built in)Slightly slower
    DebuggingHard (many abstraction layers)Easy (your code, your errors)
    StabilityFramework updates can break appsStable (SDK changes are rare)
    PerformanceOverhead from abstractionMinimal overhead
    FlexibilityCan be limiting for custom logicFull control
    Community resourcesLarge, many tutorialsGrowing, mostly official docs
    Best forComplex chains, rapid prototypingProduction apps, simple tasks

    When LangChain makes sense

    Use LangChain when you're:

    • Building complex chains with multiple steps, conditional logic, and tool integrations.
    • Prototyping quickly and want pre-built patterns for RAG, agents, and memory.
    • Your team is familiar with it and productivity is higher with the abstraction.
    • Building something where the patterns LangChain provides match your use case closely.

    When to build direct

    Build direct when you're:

    • Making one or two LLM calls with simple input-output logic.
    • Building a production app that needs to be stable over time.
    • Debugging is a priority (it always is).
    • Your use case doesn't map cleanly to LangChain's patterns and you're fighting the framework.
    • You want full control over cost, latency, and error handling.

    One problem though: many developers choose LangChain because they saw a tutorial, not because they needed what it provides. If you're not sure you need a framework, you probably don't yet.

    The experience curve

    Most experienced AI developers follow the same path. Start with direct API calls. Understand what the raw API does. Feel the pain of writing the same patterns repeatedly. Then selectively add tooling where it helps.

    If you start with LangChain before understanding direct calls, debugging becomes very hard. You won't know if an issue is in your code, the framework, or the model.

    For a broader look at agent frameworks beyond LangChain, see AI agent frameworks compared. If you're building multi-agent systems specifically, read how to build multi-agent systems.

    Devwiz builds AI apps both ways. We'll tell you honestly which approach fits your project.


    Not sure which approach fits your build? Let's talk it through.

    Frequently Asked Questions

    Is LangChain still worth using in 2026?
    Yes, for certain use cases. LangChain Expression Language (LCEL) improved the framework a lot. It's still the fastest way to prototype complex chains. But for production apps, many teams find direct builds easier to maintain and debug.
    What are the alternatives to LangChain?
    LlamaIndex is popular for RAG-focused applications. LangGraph is better for multi-agent workflows. For Anthropic-specific builds, the MCP ecosystem and Claude's built-in tool use reduce the need for a framework. Or just build direct with the SDK.
    Does LangChain work with Claude?
    Yes. LangChain has a ChatAnthropic integration. You can use Claude models within LangChain chains and agents. The integration works well but you lose some Claude-specific features and you're adding a dependency layer.