Deep dives · 2026-11-30 · Intermediate · By bombong
A map of LLM frameworks: choosing layer by layer, from serving engines to agent SDKs
SGLang/vLLM and LangChain/LangGraph are not competitors. They are tools that solve different problems at different layers, and they are often used together in one system. This article divides the field into four layers (serving engines, app and orchestration, agent SDKs, and observability and evaluation) and sets out what to choose and when.
Contents
- Why it gets confusing: names from different layers
- Inference and serving engine layer: running models on GPUs
- App and orchestration layer: combining components and designing flows
- Agent SDK layer: execution frameworks from model companies
- The observability and evaluation layer, and the protocols connecting the layers
- How to choose by situation
- Common mistakes and checklist
- Further reading
- 'SGLang vs LangChain' compares tools from different layers. A serving engine loads the model and exposes an API, and orchestration tools and agent SDKs call that API.
- vLLM, SGLang and TensorRT-LLM are competitors in the same layer. The choice is between generality and ease of use on one side and peak performance tuned to specific hardware on the other, and performance has to be measured directly on your own traffic.
- LangGraph mainly handles flows with state, loops and human approval; LlamaIndex handles document indexing and RAG; and DSPy turns prompts into programs and optimizes them.
- Agent SDKs from model companies are tailored to their own models and tools, but they are converging on attaching external tools through common protocols such as MCP.
- For a small feature, or when abstraction makes debugging hard, it is better to call the API directly without a framework. Model companies' documentation also spells out such cases.
Why it gets confusing: names from different layers
When you look into LLM frameworks, you often see comparison posts such as 'SGLang vs LangChain' or 'vLLM vs LlamaIndex'. But the two sides in each pair do different jobs. SGLang and vLLM are **inference and serving engines** that load model weights onto GPUs and process requests quickly. LangChain and LlamaIndex are **app and orchestration** tools that call an already-running model and combine tools, retrieval and multiple steps. Because they sit at different layers, picking one does not mean giving up the other; in fact, they are often used together in one system.
The interface connecting the two layers is usually an OpenAI-compatible API. The official vLLM documentation source states that it supports an OpenAI-compatible API server along with the Anthropic Messages API and gRPC, and the official SGLang documentation source likewise says it is compatible with Hugging Face and the OpenAI API. From the other side, the LLM integration list in the LlamaIndex documentation source includes vLLM, NVIDIA TensorRT-LLM and Ollama, and the Google ADK documentation source also lists Ollama, vLLM and LiteLLM as models agents can use. The engine loads the model and exposes an API, and the orchestration tool or agent SDK calls that API.
This article stacks the layers from bottom to top: model weights → inference and serving engine → (OpenAI-compatible API) → app and orchestration → agent SDK, with observability and evaluation tools watching over all the upper layers. The principles of PagedAttention and the KV cache are covered in depth in this site's 'LLM serving and PagedAttention' and 'LLM infrastructure basics', and the execution framework that wraps agents is covered in the 'Agent harness' article. This article focuses on what problem each layer solves and what to choose when.
Inference and serving engine layer: running models on GPUs
This layer solves the problem of handling more requests, faster, on the same GPUs. Start with the common techniques. **Continuous batching** slots new requests into free positions as soon as other requests finish, so the GPU does not sit idle. The **KV cache** is memory that stores intermediate attention values computed earlier. **Prefix caching** is a technique that reuses the KV cache for the leading part shared by many requests, such as a system prompt or conversation history. According to Baseten's book on inference engineering source, vLLM, SGLang and TensorRT-LLM all support continuous batching, quantization, speculative decoding, prefix caching and parallelism out of the box. So feature lists alone do not reveal much difference.
**vLLM** emphasizes generality. Its official documentation source says it manages KV memory efficiently with PagedAttention and supports continuous batching, chunked prefill (processing long inputs in small pieces) and prefix caching. It states that it supports more than 200 model architectures from Hugging Face and runs on NVIDIA and AMD GPUs and x86/ARM CPUs, plus Google TPU, Intel Gaudi, Apple Silicon and others via plugins. It also supports structured output generation using xgrammar or guidance. **SGLang**'s official documentation source explains that it aims for low latency and high throughput through RadixAttention, prefix caching and multi-GPU parallelism. RadixAttention manages the leading parts shared by multiple requests in a tree structure to reuse the KV cache, which gives a large advantage for agent-style traffic that repeats the same system prompt. The Baseten book source describes SGLang as a fast backend runtime combined with a flexible **frontend language**. As a result, SGLang is a pure engine but also has a bit of an orchestration character for writing program flows.
**TensorRT-LLM** is NVIDIA's open-source engine. The Baseten book source summarizes it as the best-performing of the three engines but the hardest to learn, and it runs only on NVIDIA hardware. As the reason, it cites access to kernels written by NVIDIA engineers (some of them closed-source). The same book puts forward the principle that 'the more constraints you impose, the better the performance'. vLLM, which supports a wide range of models and hardware, is easy to use but may fall short of peak performance, while TensorRT-LLM, tuned to a narrow target, is the opposite. The same book recommends vLLM 'when you want to quickly run almost any open model', SGLang 'when you need good default throughput on large MoE models such as DeepSeek and Kimi', and TensorRT-LLM 'when you want peak performance on Hopper-or-later GPUs and can accept extra engineering'.
For **local LLMs** run casually on a laptop or Mac, llama.cpp and Ollama come up often. The sources for this article do not include official documentation for either tool, so they are not covered in detail. However, since LlamaIndex source and ADK source list Ollama as a connection target, it is clear that experimenting locally and then moving to a serving engine is a common path. Figures claiming one engine is several times faster than another easily flip depending on version and load conditions. Measuring TTFT (time to first token) and throughput (tokens per second) directly, with your actual prompt length distribution and number of concurrent users, is the only reliable basis.
Character of the three serving engines
| Peak performance | Ease of use | Model support breadth | Hardware breadth | |
|---|---|---|---|---|
| vLLM | △ | ✓ | ✓ | ✓ |
| SGLang | △ | ✓ | ✓ | △ |
| TensorRT-LLM | ✓ | ✕ | △ | ✕ |
App and orchestration layer: combining components and designing flows
Few services end with a single call to a model API. You need to find and attach documents, call tools, and look at the results to decide the next step. The tools in this layer differ in character depending on which part of that process they handle.
**LangChain** started as components that connect models, tools and retrieval. The page introducing **LangGraph** source, from the same company, describes LangGraph as 'an agent runtime and low-level orchestration framework'. It states that single, multi-agent and hierarchical agent flows can be designed in one framework, that it supports human-in-the-loop (steps where a person checks and approves partway through), memory that stores conversation history, and token-level streaming, and that it is open source under the MIT license. It also emphasizes that you can choose between high-level abstraction and fine-grained control as needed. For workflows that carry state and loop back several times, or that must wait for human approval and then resume, a graph-based tool like this is a good fit. The latest structure and versions of LangChain itself change often, so it is safest to check the official documentation directly.
**LlamaIndex** focuses on documents. The table of contents of its official documentation source centers on a RAG pipeline built around Loading, Indexing, Querying and Storing. It offers integrations with many vector DBs and embedding models, rerankers and structured data extraction, and it also has agent, workflow, MCP, observability and evaluation features. If the core job is splitting internal documents into small pieces (chunking), indexing them and searching them, it is a good starting point.
**DSPy** takes a different angle. The slogan on its official site source is 'Program, don't prompt'. Instead of polishing prompt text by hand, you declare the input and output format as a Signature and change how it runs with Modules such as Predict, ChainOfThought and ReAct. Give it example data and a scoring function, and an Optimizer tunes the prompt automatically. It suits tasks where an evaluation metric can be defined, such as classification, extraction or moving to a smaller model, and its advantages shrink for tasks where metrics are hard to build.
Agent SDK layer: execution frameworks from model companies
An agent SDK is an execution framework that runs 'the loop in which the model plans its own steps and calls tools' for you. It overlaps a lot with the orchestration layer, but differs in that many are released by model companies and tailored to their own models and tools.
The **OpenAI Agents SDK** documentation source presents it as 'a lightweight package with very few abstractions'. Its three basic primitives are Agents (LLMs equipped with instructions and tools), Handoffs/agents as tools (passing work to other agents), and Guardrails (input/output validation). On top of these come session memory, human-in-the-loop, built-in tracing, tool calls to MCP servers, and Sandbox agents that run in an isolated workspace. It states that it uses the Responses API by default for OpenAI models but can also connect to other companies' models. The **Claude Agent SDK** documentation source describes it as a library that makes the tools, agent loop and context management that power Claude Code programmable in Python and TypeScript. It provides built-in tools, hooks, subagents, MCP, permission management, sessions and skills.
The **Google ADK** documentation source introduces it as an open-source agent framework supporting Python, TypeScript, Go, Java and Kotlin. It states that Gemini works out of the box, that other models, including local models, can be attached through adapters, and that ADK 2.0 added graph workflows. It also supports MCP tools and A2A, a protocol between agents. The **Microsoft Agent Framework** documentation source treats agents, workflows, agent harnesses, middleware, human-in-the-loop, checkpointing and resumption, and orchestration as its main concepts, and provides Python and C# examples. It also has separate migration guides from AutoGen and Semantic Kernel.
The four SDKs share fairly similar vocabulary: tools, passing work along (handoffs/subagents), validation (guardrails/permissions), session memory and human approval. The difference lies in which company's models and cloud the defaults are tuned for. Meanwhile, the OpenAI source, Anthropic source and Google source SDKs and LlamaIndex source can all attach external tools via MCP, and DSPy source also advertises MCP compatibility. Because tool connections are converging on a common protocol, tools built as MCP servers can be reused unchanged even if you switch SDKs. This reduces the burden of choosing an SDK.
The observability and evaluation layer, and the protocols connecting the layers
Once an agent receives a request, it goes back and forth between model calls and tool calls many times. Looking only at the final answer, you cannot tell at which step it went wrong or where tokens and time are leaking. That is why **tracing**, which records the input, output and duration of each call in a tree structure, and **evaluation** (Evals), which compares before and after a change using a fixed evaluation set, are needed as a separate layer. Together these are called LLM observability.
This capability is offered in several places. The LangGraph page source introduces LangSmith as 'an integrated observability and evaluation platform' for debugging agent decisions and evaluating changes. The OpenAI Agents SDK source has built-in tracing, ADK source documents observability and evaluation along with integration with Google Cloud's Cloud Trace, and LlamaIndex source documents tracing, debugging and evaluation modules. Tracing bundled with a framework is easy to start with but works well only inside that framework. Organizations that mix several frameworks are better off keeping a separate tool that is not tied to any one framework.
It also helps to keep in mind the protocols that connect the layers. At the bottom, the OpenAI-compatible API connects engines and apps sourcesource, and at the top, MCP connects agents and tools sourcesourcesource. Between agents, protocols such as A2A have started to be used source. The closer these interfaces are to standards, the less you need to change other layers when you swap a tool in one layer.
How to choose by situation
First decide 'which layer the problem you are trying to solve sits in'. The table below shows the layer to look at first and candidate tools for common situations. The candidates are examples chosen from within the scope of this article, not a ranked recommendation.
| Situation | Layer to look at first | Candidates |
|---|---|---|
| Serving open models on your own GPUs | Serving engine | vLLM, SGLang, TensorRT-LLM |
| Agent backend with heavy structured output | Serving engine + orchestration | vLLM/SGLang + LangGraph/DSPy |
| Local experiments | Serving engine (local) | Ollama family, engines supporting CPU/Mac |
| RAG over internal documents | Orchestration | LlamaIndex |
| Workflows with long-lived state | Orchestration | LangGraph, ADK/Microsoft workflows |
| Agents on one company's models | Agent SDK | That company's SDK |
When choosing an engine, decide separately for each deployment, as the Baseten book source advises. Consider whether the model is supported from day one, what the hardware is, and whether you have capacity for extra engineering, then measure performance on your own traffic. In the upper layers, the biggest fork is whether the flow is linear (retrieval → answer) or has loops, branches and approvals.
There are clearly **cases where calling the API directly without a framework is better**. The OpenAI Agents SDK documentation source advises using the Responses API directly when you want to control the loop, tool execution and state management yourself, or when the workflow is short and mostly returns model responses. It adds that you may mix the two within one application. The Anthropic documentation source also explains the distinction that with the Client SDK you write the tool loop yourself. The ADK documentation source cites 'complex multi-step processes' as the case for needing an agent framework. In short, for one-off features such as summarization or classification, or when an abstraction layer has made it hard to see what actually went into the model, direct calls are better.
Common mistakes and checklist
First, **comparing things from different layers side by side.** The question 'Should I use SGLang or LangChain?' usually needs to be split into two questions: 'Which engine should I use, and what should I use on top of it to build the flow?' Second, **stacking abstractions layer upon layer.** If you put an orchestration tool on top of an agent SDK and then add another wrapper, it becomes hard to find which layer an error came from. If you cannot see at a glance the prompt that actually went into the model, it is time to remove layers.
Third, **underestimating how fast versions change.** In the vLLM documentation source, the default view is the developer preview, so you have to select the stable documentation separately. TensorRT-LLM 0.x and 1.x differ in their basic structure (1.x is a standalone PyTorch-based package released in summer 2025). The Baseten book source urges readers to check which version they are using. Blog example code commonly stops working within a few months. Sources also disagree with each other. The comparison table in the Baseten book source lists SGLang's hardware as NVIDIA and AMD, but the official SGLang documentation source states that it also supports Intel Xeon, Google TPU, Ascend NPU and others. For fast-changing facts such as hardware support, check the date on the official documentation before deciding.
Fourth, **taking benchmark figures at face value.** Performance rankings between engines vary with model, batch size, input length and version. Use published figures only to narrow down candidates, and base the final decision on results measured on your own traffic. It is worth going through the checklist below once before adoption.
Pre-adoption checklist
Layering
- Are the things being compared on the same layer?
- Do the engine and app connect through an OpenAI-compatible API?
- Are tools attached via MCP so they can be reused if you switch SDKs?
Debugging
- Can you see the prompt that actually went into the model?
- Could you remove one layer of abstraction?
- Is the feature small enough that calling the API directly would suffice?
Versions & performance
- Do the example code and installed version match?
- Are you reading the stable-release docs?
- Have you measured TTFT and throughput with your own traffic?
Further reading
For the engine layer, start with the inference engine chapter in Baseten's book source. It sums up the character of the three engines and "when to use which" on a single page. Then follow the feature list and design documents in the vLLM docs source and the quick start in the SGLang docs source to actually stand up a model server. That gives you hands-on experience of how an OpenAI-compatible API connects the layers. For how PagedAttention and the KV cache work, this site's article "LLM Serving and PagedAttention" goes into more detail.
Read the upper layers according to the problem you want to solve. If document search is central, read the introduction to RAG pipelines in the LlamaIndex docs source. For flows with state and human approval, read the LangGraph page source. If you want to optimize prompts against a metric, read the Signature and Optimizer examples on the DSPy site source.
For agent SDKs, we recommend reading OpenAI's "Agents SDK or Responses API: which to use" source side by side with the tool comparison table in Anthropic's docs source. This gives you a sense of when to use a framework and when to leave it out. Comparing the tables of contents of the ADK source and Microsoft Agent Framework source docs also shows which concepts the industry covers in common (workflows, checkpoints, human-in-the-loop, MCP).
Related terms
Inference engine PagedAttention Continuous batching KV cache Structured output MCP LLM observability Harness
References
Further reading (official docs and engineering posts)
- Welcome to SGLang - SGLang Documentation (docs.sglang.ai)
- vLLM (docs.vllm.ai)
- LangGraph: Agent Orchestration Framework for Reliable AI Agents (langchain.com)
- LlamaIndex Framework, by the makers of LlamaParse | Developer Documentation (docs.llamaindex.ai)
- DSPy: Program, don't prompt, your LLMs (dspy.ai)
- OpenAI Agents SDK (openai.github.io)
- Agent SDK overview - Claude Code Docs (docs.claude.com)
- Agent Development Kit (ADK) - Agent Development Kit (ADK) (google.github.io)
- Agent Framework documentation | Microsoft Learn (learn.microsoft.com)
- Inference Engines | Inference Engineering (baseten.co)
Written by AI from the listed references and reviewed. Please check the original sources for details.