launchthat
LibreChat vs. Rolling Your Own AI Layer: When Each Makes Sense
Platforms like LibreChat give you a production-ready chat UI, multi-model routing, and built-in Langfuse integration. Custom agent frameworks give you reactive UI, transactional tool execution, and full rendering control. Here is how I decide between them across four different products.
I run AI features across four products. A portfolio chatbot that answers questions about my work. A multi-tenant support component embedded in Portal and TraderLaunchpad. A strategy builder where an AI agent manipulates trading charts, rules, and risk parameters. And an accessibility scanner where AI findings need to be evaluated against deterministic ground truth.
Each of these has a different relationship with its AI layer. Some would benefit from a platform like LibreChat. Others would lose critical functionality if I moved off a custom implementation. The decision framework is not about which approach is better — it is about which constraints dominate.
The two approaches
Platform approach (LibreChat and similar): Deploy an open-source chat platform as a standalone service. It provides a polished chat UI, multi-model routing, conversation management, agent personas, artifacts for generative UI, and native Langfuse integration for LLM observability. Your application embeds it via iframe or calls its API. The AI layer is a separate service with its own database, its own auth, and its own lifecycle.
Custom agent framework (Convex Agent, Vercel AI SDK, etc.): Build the AI layer directly into your application's data model and rendering pipeline. Threads, messages, and tool results live in the same database as your business data. The chat UI is your React code. Tool calls are mutations that write to the same tables your application reads. Streaming, subscriptions, and auth are inherited from the host framework.
Neither approach is universally better. The right choice depends on four factors: how tightly the AI needs to integrate with your UI, how many domains the AI spans, how large the team is, and how much observability infrastructure you want to manage.
Where I use each approach — and why
Portfolio AI chatbot: narrow scope, single tenant
The portfolio site has a chat bubble in the corner. It answers questions about my projects, skills, and blog posts using RAG over the portfolio content. One model. One persona. No tool calling. No multi-user threads.
This is the simplest possible AI integration. The chat bubble uses the Convex agent component because the rest of the portfolio already runs on Convex, so the marginal cost of adding a chat thread was near zero. But this is also the use case where LibreChat would have been equally fine — maybe better. I would have gotten a polished chat UI for free instead of building one. The RAG pipeline could feed into a LibreChat agent's system prompt. There is no deep UI integration that requires custom rendering.
Verdict: Either approach works. The deciding factor was that Convex was already the backend, not any architectural requirement.
Portal and TraderLaunchpad support: RAG-heavy, minimal tool calling
Both Portal and TraderLaunchpad embed a shared support component. It is a customer-facing AI assistant that answers questions using RAG over product documentation, help articles, and tenant-specific context. The interaction pattern is straightforward: the user asks a question, the AI retrieves relevant context, and generates a grounded response.
There is minimal tool calling. The support agent does not write data, does not modify UI state, and does not need transactional guarantees. It reads from the knowledge base and responds.
This could run on LibreChat without losing meaningful functionality. The RAG context would feed into an agent's system prompt or a retrieval plugin. The conversation UI would be LibreChat's — which is more polished than what I built. Multi-model routing would let me A/B test different models per tenant without code changes. And Langfuse integration would be automatic instead of manual instrumentation.
The reason I have not migrated is pragmatic, not architectural. The support component already exists, it shares the Convex agent infrastructure with the rest of the platform, and the switching cost outweighs the benefit for a component that works fine as-is.
Verdict: LibreChat would work well here. The AI layer is read-only, the UI integration is a contained panel, and the native Langfuse integration would reduce instrumentation work.
TraderLaunchpad strategy builder: deep UI integration, transactional tools
The strategy builder is where the custom approach becomes non-negotiable.
The AI agent has nine tools that directly modify trading strategy state: updating risk limits, adding and removing rules, managing trading sessions, creating strategy versions, and fetching market news for context. When the agent calls addStrategyRule, it executes a Convex mutation that writes the rule to the strategy document. The strategy panel — a React component subscribed to that document via useQuery — updates instantly. The user sees the new rule appear in their rule list at the same moment the AI confirms it in the chat.
This is not a chat interface with a side panel. It is a collaborative editing environment where the AI is one of the collaborators. The agent's tool calls modify the same reactive data model that powers the charts, the rule editor, the session timeline, and the risk dashboard. Changes propagate to every connected client through Convex subscriptions.
LibreChat could handle the conversation part. Its Artifacts feature can even render React components inline. But the strategy panel is not a generated artifact — it is a persistent, subscription-bound UI component with bidirectional interaction. The user edits a rule in the panel, and the change is visible to the agent in its next turn. The agent adds a trend line, and the chart renders it before the response finishes streaming. This tight loop between tool execution and reactive UI requires the AI layer to live inside the same data model as the application.
With LibreChat, every tool call would need to cross an HTTP boundary, authenticate separately, and lose the transactional context that lets the agent check user credits, validate strategy constraints, and write the result in one atomic operation.
Verdict: Custom agent framework. The AI layer is deeply coupled to the product's data model and rendering pipeline. The cost of the HTTP boundary and auth bridging would be significant, and the reactive UI integration would degrade.
The decision framework
After building AI into four different products, the pattern is clear. The choice comes down to three questions.
Does the AI write data that other UI components react to?
If yes, custom. If the agent's tool calls modify state that other parts of your application need to reflect in real time — strategy panels, dashboards, collaborative editors — you need the AI layer inside your reactive data model. An HTTP boundary between the chat service and your database adds latency, loses transactional guarantees, and creates sync complexity.
If no, either works. If the AI is read-only (RAG, Q&A, content generation) or its outputs are self-contained (artifacts, reports, summaries), a platform like LibreChat gives you more for less effort.
How many domains does the AI span?
A few focused products (under five): Roll your own. Each product has its own agent configuration, tools, and context. The per-product customization is manageable, and the tight integration with each product's data model pays off. This is where I am today — four products, each with distinct AI requirements, sharing a Convex agent component that each app wires differently.
A large organization with many teams and domains: Use LibreChat. When you have 10, 20, 50 teams that each need AI features — sales, support, engineering, legal, HR — the centralized platform approach wins. Each team gets their own agent persona with their own system prompt and data scope, managed through LibreChat's configuration rather than custom code. The alternative is each team building and maintaining their own agent infrastructure, which fragments expertise and multiplies maintenance.
LibreChat's architecture maps well to this: one deployment, many agents, each scoped to a domain. A sales agent queries the CRM. A support agent reads the knowledge base. A data analyst agent writes SQL. The agents share infrastructure but operate independently. An organization-wide Langfuse instance tracks quality, cost, and usage across all of them.
How much observability infrastructure do you want to manage?
LibreChat gives you Langfuse integration for free. Set a few environment variables, and every agent interaction is automatically traced — prompt versions, token usage, cost per session, evaluation scores. For a large organization running dozens of agents, this is significant. Manual instrumentation across that many surfaces is expensive to build and maintain.
Custom frameworks require manual instrumentation. Every streamText call, every tool execution, every model switch needs explicit Langfuse SDK calls. For a focused product with a handful of AI surfaces, this is manageable — maybe 200 lines of instrumentation code. For 50 agents across 10 teams, it becomes a full-time job.
The eval story scales the same way. A focused product might track five to ten quality metrics — precision per WCAG criterion, response relevance, hallucination rate. You can wire this up manually with Langfuse's scoring API. A large organization might need those same metrics for every team's agents, plus cross-team comparisons, cost allocation by department, and organization-wide quality dashboards. LibreChat's centralized telemetry feeds directly into Langfuse at that scale without each team building their own pipeline.
The hybrid path
These are not mutually exclusive. The realistic architecture for a growing organization looks like:
Start custom for your core product. The features that differentiate your product — the strategy builder, the accessibility scanner, the domain-specific tools — benefit from deep integration. Build these with a custom agent framework where the AI layer is part of the application.
Add LibreChat for the long tail. When internal teams start asking for AI features — "can we get a chatbot that answers questions about our docs?" or "can the sales team get an AI that queries our pipeline data?" — stand up a LibreChat instance. These use cases are read-heavy, RAG-driven, and do not need deep UI integration. LibreChat handles them with configuration instead of code.
Unify observability in Langfuse. Whether the AI call originates from your custom agent or from LibreChat, the traces end up in the same place. Custom agents instrument with the Langfuse SDK. LibreChat instruments automatically. One dashboard shows quality, cost, and usage across everything.
What I would do differently
If I were starting today with the knowledge I have now, I would make one change: I would start the portfolio chatbot and the support component on LibreChat instead of the custom Convex agent. Not because the custom approach is wrong — it works fine — but because the engineering effort did not buy me anything those products need. The portfolio chat does not need reactive subscriptions. The support component does not need transactional tool execution. Both would benefit from LibreChat's polished UI and free Langfuse integration.
The strategy builder and the accessibility scanner would stay custom. Their AI layers are too tightly coupled to their respective data models to live behind an HTTP boundary. The tools write data. The UI reacts to it. The agent needs auth context and transactional guarantees. These are the products where owning the AI layer is a competitive advantage, not just an engineering preference.
The lesson is the same one that applies to build-vs-buy decisions everywhere: use a platform for the commodity parts, build custom for the differentiating parts. The skill is knowing which is which before you start building.
Want to see how this was built?
See how AI is used across the platformWant to see how this was built?
Browse all posts