LangSmith gives you end-to-end visibility into your LLM application by capturing traces; a complete record of every step that ran during a request, from the inputs passed in to the final output returned. In this quickstart, you will add tracing to an AI assistant and view the results in LangSmith.Documentation Index
Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-change-1779831223-d853e2d.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before you begin, make sure you have:- A LangSmith account: Sign up or log in at smith.langchain.com.
- A LangSmith API key: Follow the Create an API key guide.
- An OpenAI API key: Generate this from the OpenAI dashboard.
1. Set up your environment
-
Create a project directory, install the dependencies, and configure the required environment variables:
-
Export your environment variables in your shell:
To send traces to a specific project, use the
LANGSMITH_PROJECTenvironment variable. If this is not set, LangSmith will create a default tracing project automatically on trace ingestion.If you are using Anthropic, use the Anthropic wrapper. If you are using Google Gemini, use the Gemini wrapper. For other providers, use theIf your account is in a region other than US (the default), also setLANGSMITH_ENDPOINTto the API URL for your region. Without this, your API key won’t be recognized and requests will fail to authenticate.
For example, EU accounts:Region GCP US GCP EU GCP APAC AWS US export LANGSMITH_ENDPOINT="https://eu.api.smith.langchain.com".@traceabledecorator to trace calls manually.
2. Build the app
The following app uses two LangSmith tools to add tracing:- OpenAI wrapper: wraps the OpenAI client so every LLM call is automatically logged as a nested span.
- Traceable wrapper: wraps a function so its inputs, outputs, and any nested spans appear as a single trace in LangSmith. Use
@traceablein Python,traceablein TypeScript and Kotlin, andTracing.traceFunctionin Java.
assistant function calls a tool (get_context) to retrieve relevant context, then passes that context to the model. Using the traceable wrapper on both functions captures the full pipeline in one trace, with the tool call and LLM call as nested spans.
Create a file called app.py, index.ts, App.java, or App.kt with the following code:
3. Run the app
4. View your trace
In the LangSmith UI, go to Tracing and select your default project. Click theassistant row to open the trace. The Messages tab shows the conversation as it was sent to the model. Select the Details tab to see the full run tree, including the assistant function with the get_context tool call and the OpenAI call nested inside it.

assistant function’s inputs and outputs. The nested get_context span records the tool call, and the ChatOpenAI span records the exact prompt sent to the model and the response returned.
Next steps
- Tracing integrations: LangChain, LangGraph, Anthropic, and other providers.
- Trace an LLM application: a full lifecycle tutorial, from prototyping through production.
- Filter traces: search and navigate large tracing projects.
- Log to a specific project: send traces to a named project instead of default.
After logging traces, use Polly to analyze them and get AI-powered insights into your application’s performance.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.


