Back to blog
    AI Engineering

    Why We Switched from LangChain to Custom Pipelines

    Steinn Labs··7 min read

    Key Takeaways

    • LangChain excels at prototyping but its abstractions make production debugging difficult
    • Custom pipelines reduced our latency by 40% compared to LangChain equivalents
    • Direct API calls with a simple pipeline runner give full control over every step
    • LangChain still makes sense for rapid prototyping and evaluating multiple approaches

    The LangChain Starting Point

    LangChain is an incredible tool for prototyping AI applications. It lets you go from idea to working demo in hours. We used it extensively throughout 2024 for client prototypes and MVPs.

    But as those prototypes moved to production, we kept running into the same issues: opaque abstractions that made debugging difficult, version-breaking changes between releases, and performance overhead that added latency to every request.

    What Broke for Us

    Three specific pain points pushed us to build custom pipelines:

    1. Debugging black boxes: When a chain fails in LangChain, the error messages often point to internal abstractions rather than the actual problem. In production, a developer needs to trace exactly where a failure occurred
    2. Unnecessary abstractions: For a simple "embed, retrieve, generate" flow, LangChain adds multiple layers of wrapping that serve no purpose in production but add latency and complexity
    3. Vendor lock-in: Switching from one LLM provider to another required understanding LangChain's adapter pattern rather than just swapping API calls

    Our Custom Pipeline Approach

    We now build AI pipelines using a minimal abstraction pattern:

    • Direct API calls to model providers (OpenAI, Google, Anthropic)
    • A simple pipeline runner that handles retries, logging, and error handling
    • Type-safe interfaces between pipeline stages
    • Observability built in from the start using tools like Langfuse

    The result: 40% less latency, significantly easier debugging, and full control over every step of the pipeline.

    When LangChain Still Makes Sense

    We still recommend LangChain for rapid prototyping and for teams that need to evaluate multiple approaches quickly. The library's strength is exploration, not production.

    Frequently Asked Questions

    Why would you switch from LangChain to custom pipelines?

    Production demands like debugging transparency, performance optimization, and avoiding unnecessary abstraction layers push teams toward custom pipelines. LangChain adds latency and complexity that is unnecessary for well-defined production flows.

    Is LangChain good for production?

    LangChain is excellent for prototyping and exploring approaches, but its opaque abstractions, version-breaking changes, and performance overhead make it challenging for production use cases that require reliability and observability.

    What does a custom AI pipeline look like?

    A minimal custom pipeline uses direct API calls to model providers, a simple pipeline runner for retries and logging, type-safe interfaces between stages, and built-in observability with tools like Langfuse.

    langchain
    ai-pipelines
    production
    architecture
    developer-experience