LangChain’s mandatory custom chat-model surface is compact: the Python BaseChatModel reference marks only _generate and the _llm_type property as required. Streaming, native asynchronous generation, asynchronous streaming and identifying parameters are optional. For a fine-tuned or self-hosted model behind a custom API, you can therefore implement the minimum contract without building every execution mode immediately.
The minimum is not the full engineering decision. If the model will sit inside a long-lived LangChain agent, support model swaps, or use LangSmith’s documented evaluation and tracing paths, I would build it as a BaseChatModel component and add the optional members needed for parity. For an isolated API call that does not need those component paths, an ad hoc wrapper remains a reasonable candidate. The evidence supports access to documented integration conveniences; it does not establish that a component always requires less code.
Integration package or ad hoc wrapper?
LangChain’s integration guide defines LangChain components as subclasses of base classes in langchain-core, naming chat models, tools and retrievers as examples. It describes chat models as BaseChatModel subclasses that implement methods for generating chat completions, handling message formatting and managing model parameters.
The guide’s documented distribution route is an integration package: an installable package implementing one or more components that adhere to LangChain’s interface standards. That distinguishes two questions that are easy to conflate:
- Can the application call the model endpoint? An application-specific HTTP wrapper can address this.
- Does the model implement the interface expected of a LangChain component? The base-class contract addresses this.
This distinction does not mean wrappers are forbidden or that every model must be published as a separate package. It means the fetched documentation describes first-class component treatment in terms of interface adherence, not merely in terms of successfully returning text from an API.
What the contract actually requires
The langchain-core reference, accessed December 6, 2026, places BaseChatModel under BaseLanguageModel[AIMessage] and ABC. Its custom-implementation table supplies the practical checklist:
| Member | Status | Documented purpose |
|---|---|---|
_generate | Required | Generate a chat result from a prompt |
_llm_type property | Required | Uniquely identify the model type; used for logging |
_identifying_params property | Optional | Represent model parameterization for tracing purposes |
_stream | Optional | Implement streaming |
_agenerate | Optional | Implement a native asynchronous method |
_astream | Optional | Implement the asynchronous version of _stream |
A minimal implementation therefore has two required members, not six. That matters when pricing the work: it would be unsupported to claim a large mandatory syntactic gap between a minimal compliant subclass and a minimal ad hoc wrapper. The fetched sources do not measure the implementation effort of either route.
Optional does not mean irrelevant. It means the reference does not require the member for every custom implementation.
If callers need streamed output, _stream is the documented streaming member. If they need native asynchronous generation or asynchronous streaming, _agenerate and _astream are the relevant members. The reference does not establish a performance penalty for omitting them, so their absence should not be turned into an invented benchmark claim.
_identifying_params deserves separate attention during model swaps. Its documented role is to represent model parameterization for tracing. When two deployments differ in configuration, this is the contract member concerned with exposing that parameterization to the tracing path. It is not merely another name for _llm_type, which identifies the model type for logging.
Use the linked reference for the method signatures of the version being installed. The checklist establishes which members are required or optional in the reviewed documentation; it does not establish a version-support window or substitute for checking a version-specific signature.
What adherence buys
Two LangSmith documents supply the practical payoff, but they should be kept separate rather than compressed into an overly broad mechanism claim.
Direct evaluation for chat-model Runnables
The LangSmith evaluation guide states that LangChain Runnable objects, explicitly including chat models, retrievers and chains, can be passed directly into evaluate() and aevaluate().
For a custom chat model, this is the clearest documented benefit of becoming a chat-model Runnable: the evaluation guide names that kind of object as directly accepted, without requiring an additional target wrapper. It does not report evaluation quality, compare models, or promise that results will remain equivalent after a model swap. Those are separate questions.
Tracing LangChain code without extra logging code
The LangSmith tracing guide makes the following vendor-documented claim:
No extra code is needed to log a trace to LangSmith. Just run your LangChain code as you normally would.
The JavaScript and TypeScript passage needs its qualification preserved. Starting with langchain@0.2.x, the guide says LangChain objects are traced automatically when used inside @traceable functions. Those objects inherit the traceable function’s client, tags, metadata and tracing destination. The broad “no extra code” statement should therefore not be generalized into an unconditional promise across languages, versions and calling patterns.
Where the mechanism claim becomes inference: The evaluation guide names chat models among the Runnables accepted directly by
evaluate()andaevaluate(). The tracing guide separately documents tracing for LangChain code. Inferring that a custom model built to the component contract joins these paths is reasonable, but the sources do not state a universal rule that Runnable status itself causes both tracing and evaluation behavior. This synthesis is not a hands-on verification.
LangSmith’s positioning also limits how the benefit should be interpreted. The LangChain documentation home describes LangSmith as a framework-agnostic platform for testing, deploying, monitoring and improving agents. Direct Runnable evaluation and no-extra-code LangChain tracing therefore should not be read as proof that other kinds of code cannot use LangSmith. The narrower finding is that these particular conveniences are explicitly documented for the component paths described above.
Why the contract affects model-swap economics
LangChain’s project README describes a standard interface for models, embeddings, vector stores and other components. It presents model interoperability as the ability to swap models while an engineering team experiments with choices for an application. That is the vendor’s architectural framing, not an independent measurement of migration savings.
Consider a bounded hypothetical: an application currently invokes a hosted chat model through LangChain, and the team wants to replace it with a self-hosted model behind its own API. If the replacement is implemented through the same chat-model contract, the agent’s calling convention can remain oriented toward the shared abstraction. The team also has a documented route for passing chat-model Runnables directly to LangSmith evaluation and for tracing LangChain code.
That is the economic argument for the contract. The work is concentrated in making the new model satisfy the component interface, rather than introducing a new calling convention at each agent call site. Evaluation and observability have documented component paths that can remain part of the setup.
The argument has limits:
- It does not establish that prompts, outputs, latency or model behavior remain stable across providers.
- It does not quantify engineering time saved during a swap.
- It does not specify what an ad hoc wrapper would need to recreate equivalent evaluation and tracing behavior.
- It does not prove that a wrapper cannot be engineered to preserve a stable application interface.
Consequently, “build the component” should not be inflated into “every wrapper must rebuild the entire agent, tracing system and evaluation suite.” Nothing in the fetched material supports that claim. The decision is whether the documented component paths are valuable enough to justify implementing and maintaining the interface.
The model contract is not the whole agent
A custom-model project may also introduce tools or middleware. Those have separate contracts in the integration guide.
The guide says a BaseTool subclass has three properties and two methods that should be implemented. It describes middleware as subclasses of AgentMiddleware that customize agent behavior by hooking into model calls, tool calls and agent lifecycle events. These are adjacent extension surfaces, not extra required members of BaseChatModel.
That separation matters for estimation. Completing the two-member chat-model minimum does not document completion of a tool integration or middleware layer. If the project includes either, budget and verify it separately.
Which route fits your situation?
| Situation | Best-supported choice | Reason and limit |
|---|---|---|
| A reusable model inside a LangChain agent, with swaps or LangSmith evaluation planned | Implement a BaseChatModel component; package it when distributing an integration | This follows the documented interface route, and chat models are explicitly included in direct Runnable evaluation |
| Streaming, native async generation or async streaming is required | Implement the two required members plus the relevant optional members | The reference marks these capabilities optional, so the minimum checklist does not express the required application parity |
| One isolated custom API call, with no need for LangChain component hooks | An ad hoc wrapper remains a reasonable candidate | The evidence does not quantify a component payoff for this case or establish that the wrapper must recreate LangSmith facilities |
| A JavaScript or TypeScript implementation | Verify the current language-specific base-class contract before writing implementation steps | Contract parity is unresolved here, and automatic tracing inside @traceable functions is scoped to langchain@0.2.x and later in the cited passage |
The strongest limitation covers all of these rows: the findings come from vendor documentation, not from running a custom model through the contract, evaluation and tracing paths. The integration page also sits on a JavaScript contributing path while its text describes Python packages, so the fetched material does not settle Python versus JavaScript and TypeScript contract parity. Recheck the current reference for the language and version being deployed, then run a bounded acceptance check with the finished object: invoke it through the intended agent path, pass it to the intended evaluation path and confirm tracing under the actual configuration.
Pydantic AI remains an open question. None of the supplied evidence establishes its custom-model extension contract, so this article cannot support a claim that adding a model is easier, harder or cheaper there. For a LangChain-based agent that needs swaps and the documented LangSmith paths, the component contract is worth its cost. For a one-off call, the two-member minimum is not by itself a reason to reject a simpler wrapper.
Frequently Asked Questions
Can a custom chat model be passed directly to LangSmith evaluation?
The LangSmith evaluation guide states that LangChain Runnable objects, explicitly including chat models, retrievers and chains, can be passed directly into evaluate() and aevaluate().

Join the discussion
Share a useful perspective or ask a question about this article.