LangChain: what it is, what it consists of and when you really need it

What LangChain is and which packages it consists of, which tasks it helps with and when the plain OpenAI SDK is enough. We compare code and spending.

5 min · · development · агенты

What LangChain is: an open-source Python library (there is a JavaScript version too) that provides a common set of building blocks for applications on large language models: a unified interface to models from different providers, tools, agents, and work with documents and search. The name often appears in tutorials, so newcomers decide they cannot do without it. That is not so. Next, in order: the parts of the ecosystem, what LangChain is for in practice and when the official SDK is simpler. The description follows the LangChain documentation (docs.langchain.com); the packages evolve quickly, so check details against it.

What LangChain is and what it consists of

By "LangChain" people usually mean several related products. According to the documentation they divide like this:

PartWhat it isWhen you need it
langchainThe main package: models, messages, tools, create_agent, middleware, structured outputFor agents and typical scenarios
Integration packages (langchain-openai, langchain-anthropic and others)Connection to specific model providersWhenever you call a model
langchain-coreBase abstractions: Document, vector stores, interfacesPulled in automatically
langchain-text-splittersSplitting texts into fragmentsFor RAG and summarization
LangGraphA low-level runtime and orchestration for graphs mixing deterministic and agentic stepsFor complex stateful flows
Deep AgentsA ready harness for long tasks: filesystem, subagents, context summarizationFor autonomous multi-step agents
LangSmithTracing, debugging and evaluationFor observability, optional

The main idea the documentation stresses: an agent is a model plus a harness. The model calls tools in a loop until the task is solved, and LangChain provides the prompt, tools and middleware around that loop. The library itself contains no model: you plug in any model that has an integration or an OpenAI-compatible address.

What LangChain is for: typical tasks

  • A unified interface to models. The same llm.invoke(...) code works with different providers, and the model changes in one line.
  • Agents with tools. create_agent takes care of the "model, function call, result, model again" loop.
  • A structured response. A Pydantic object instead of text: with_structured_output, or response_format on an agent.
  • RAG. Document loaders, splitters, vector stores and retrievers.
  • Reliability. Ready middleware for retries, call limits and history summarization.
  • Observability. Step tracing through LangSmith.

The same call: the OpenAI SDK versus LangChain

To see the difference, compare a minimal call. First the official SDK. For the OpenAI format the Zukko address ends with /v1:

bash
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.zukko.pro/v1",
    api_key=os.environ["ZUKKO_API_KEY"],
)

reply = client.chat.completions.create(
    model="gpt-6.1-sol",
    messages=[{"role": "user", "content": "Explain what a token is in two sentences."}],
)
print(reply.choices[0].message.content)

Now the same in LangChain:

bash
import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="gpt-6.1-sol",
    base_url="https://api.zukko.pro/v1",
    api_key=os.environ["ZUKKO_API_KEY"],
)

print(llm.invoke("Explain what a token is in two sentences.").content)

For a single call the two versions are equivalent: LangChain only adds a layer over the same request to /v1/chat/completions. The benefit appears when there are many linked calls. Here is an agent with a tool function:

bash
from langchain.agents import create_agent
from langchain.tools import tool


@tool
def convert_to_usd(rub: float, rate: float) -> float:
    """Convert rubles to dollars at the given rate (rubles per dollar)."""
    return round(rub / rate, 2)


agent = create_agent(
    model=llm,
    tools=[convert_to_usd],
    system_prompt="You are a calculation assistant. Do arithmetic through the tools.",
)

result = agent.invoke(
    {"messages": [{"role": "user", "content": "How many dollars is 15,000 rubles at a rate of 90?"}]}
)
print(result["messages"][-1].content)

To build such a loop on the plain SDK you have to parse tool_calls yourself, run the functions and append results to the history (this is covered in the article an AI agent in Python from scratch). It is not hard, but boilerplate grows.

When you need LangChain and when the SDK is enough

SituationWhat to pick
A single request, a chat with history, streamingThe OpenAI SDK or Anthropic SDK is enough
A script that calls a model in a couple of placesThe SDK, fewer dependencies
You need to switch model providers without rewriting codeLangChain, or the gateway itself with a common format
An agent with several tools and step limitsLangChain (create_agent)
An autonomous agent for long tasks with filesDeep Agents
RAG with loaders, splitters and storesLangChain or a specialized library
A complex graph with branching and saved stateLangGraph

The honest downsides of LangChain: more dependencies, more layers when debugging (an error can come from any of them), and quick API changes between versions. If your task fits into a few calls to a model, the extra layer does not pay off. For tasks around data indexing there are other libraries too, for example LlamaIndex. And if all you need is one address and format, the gateway itself helps: it accepts requests in the OpenAI and Anthropic formats for any catalog model.

Connecting Zukko to LangChain

The rule is simple: integrations based on the OpenAI format get a base_url with /v1, and the fetch_... key comes from the dashboard. You can put any catalog model into the model parameter; the current list comes from GET https://api.zukko.pro/v1/models. A detailed guide with environment variables: LangChain: how to set our base_url.

Does LangChain affect spending

LangChain itself adds no tokens: you pay for requests to the model. But typical scenarios have a hidden price. An agent calls the model several times and each time resends the accumulated history; history summarization makes separate calls; retries after errors are billed like normal requests. An example with a formula on gpt-6.1-sol (0.27 / 1.32 per 1M as of October 18, 2026); the token volumes are an assumption for illustration:

  • One call: 1,000 input and 300 output tokens: 1000 × 0.27 + 300 × 1.32 = 270 + 396 = 666 millionths of a dollar, that is $0.000666.
  • An agent with five calls: inputs 1,000, 1,300, 1,600, 1,900 and 2,200 (sum 8,000), 100 outputs each (sum 500): 8000 × 0.27 + 500 × 1.32 = 2160 + 660 = 2820, that is $0.00282.

For Claude in the OpenAI format the whole input is billed at the input price. A cache discount for Claude is possible only in the Anthropic format, while for GPT cache reads are visible in both. To keep an agent from going into the red, limit its steps and create a separate key with a daily limit: how to cap a key's spending.

FAQ

Is LangChain free?

The library is open source, but requests to models are paid. LangSmith and other services around it have their own terms, see the LangChain site. Model prices in Zukko are given per 1M tokens, the list is available via GET /v1/models.

Do I need LangChain to use Claude or GPT through the API?

No. The official SDK or a plain HTTP request is enough. LangChain is needed when you build an agent or RAG, or want a unified harness.

How does LangChain differ from LangGraph and Deep Agents?

LangGraph is a low-level runtime, LangChain gives an agent with a configurable harness, and Deep Agents is a ready out-of-the-box option for long tasks built on them.

Does LangChain work with non-OpenAI models?

Yes, through provider-specific integrations or through any OpenAI-compatible address with ChatOpenAI and base_url. Check support for the features you need (tools, structured output) on your chosen model with your own tasks.

Try both code versions above on one key: create it in the dashboard, and see client examples in the Python reference.

zukko

Pay 25×
less

for Claude Code & ChatGPT

One fetch_* key and base URL api.zukko.pro — for Cursor, Claude Code, Codex, and any SDK.

Get API keyDocumentation

api.zukko.pro · fetch_*

LangChain explained: what it is and when you need it · Zukko