Pick the right way to trace a non-LangChain Python app into LangSmith
Use the @traceable decorator (and wrap_openai for OpenAI calls) from the langsmith SDK. The env var alone only triggers LangChain auto-instrumentation.
Picture a hotel that gives out room-service trays only when staff stamp them with the hotel's logo. If you cook a meal in your own kitchen and want it to count as a hotel meal, you walk over and ask the staff to stamp it for you. The decorator is the stamp. It tells LangSmith 'this function is part of my hotel order'. Just being a guest at the hotel is not enough; without the stamp the meal is invisible to the hotel's records. The LANGCHAIN_TRACING_V2 environment variable is the front-desk policy that says hotel-prepared meals get stamped automatically. It does nothing for the meals you cooked yourself.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
LangSmith's marketing puts LangChain front and center, so it is easy to assume the two are inseparable. They are not. LangSmith works with any Python code (and with TypeScript, and with anything that can speak HTTP). The path you take depends on what is in your call stack and how much vendor coupling you want.
This question covers the most common confusion: a team adopts LangSmith for tracing, sets the env var they saw in the docs, runs their non-LangChain code, and sees nothing in the dashboard. The fix is one decorator and one wrapper, plus understanding why the env var did not help.
The langsmith SDK is standalone
The langsmith Python package is a standalone library that depends only on standard Python tooling. It does NOT depend on LangChain. Installing it (pip install langsmith) gives you the full client surface: the Client class for direct API access, the @traceable decorator, the wrap_openai helper, the feedback API, and the dataset and evaluation utilities.
This is the same pattern Anthropic and OpenAI use for their own SDKs: a thin client library that any application can import without bringing in a framework. The historical confusion comes from LangSmith being conceived alongside LangChain and the docs leading with LangChain examples. The library itself is broader.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- FastAPI services without LangChain commonly use @traceable on the request handler and wrap_openai on the shared OpenAI client.
- LlamaIndex apps wired to LangSmith use the langsmith SDK directly, not the LangChain bridge.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhat features does the langsmith SDK expose that the OTLP endpoint does not?
Cover feedback API, dataset linking, prompt-versioning context, and structured input/output rendering.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Setting LANGCHAIN_TRACING_V2 and expecting non-LangChain OpenAI calls to show up. The env var only activates LangChain's built-in callbacks.
60 second bullets to scan on the way to the call.
Name the decorator that marks a Python function as a LangSmith span
Explain what wrap_openai adds beyond a generic @traceable
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.