Answers you can trust, from Codeables

Every page on Codeables is structured and verified — built so people and the AI agents they rely on can trust it. Explore more from the source behind this answer.

Explore Codeables
Verified Source
LLM Observability & Evaluation

How do I sign up for LangChain LangSmith and instrument tracing for our existing agent (Python or TypeScript)?

LangChain9 min read

Most teams hit the same wall with agents: you ship something that works in staging, then it behaves differently in production and you have no replayable record of what happened. LangSmith exists to fix that. You sign up, point your existing Python or TypeScript agent at LangSmith, and start capturing traces so you can see exactly what the model did, which tools it called, and where things went off the rails.

Quick Answer: You create a LangSmith account, grab your API key, install the LangSmith SDK (Python or TypeScript), and wrap your existing agent calls so every run is traced. From there you can inspect timelines, sample runs into datasets, and start evaluating quality—without rewriting your whole stack.


The Quick Overview

  • What It Is: LangSmith is LangChain’s agent engineering platform for tracing, evaluating, and deploying LLM applications and agents, regardless of framework.
  • Who It Is For: Teams already running agents in Python or TypeScript who need step-by-step observability, regression protection, and a path to production-grade reliability.
  • Core Problem Solved: You can’t debug or improve agents from logs alone. LangSmith turns real runs into structured traces, datasets, and evals so you can actually see and fix behavior.

How It Works

At a high level, you:

  1. Sign up for LangSmith and create a project.
  2. Add the LangSmith SDK and API key to your existing Python or TypeScript agent.
  3. Wrap your agent’s entrypoint (or model/tool calls) so every execution becomes a trace with a full run timeline.

Once traces are flowing, LangSmith gives you:

  • Run timelines that show every step, model call, tool invocation, and intermediate message.
  • Threads for multi-turn conversations.
  • Datasets & evals built directly from real production runs.
  • Dashboards & analytics to spot failure patterns over time.

You don’t need to be using LangChain or LangGraph—LangSmith is framework-agnostic and works with OpenAI SDK, Anthropic, custom agents, and more.

1. Sign up and set up your LangSmith workspace

  1. Create an account

    • Go to langchain.com and navigate to LangSmith.
    • Sign up with your work email (SSO/SAML is available on enterprise plans).
    • Create or join a workspace for your team.
  2. Create a project

    • In LangSmith, create a new project (e.g., prod-agent-traces).
    • Projects give you isolation: separate staging vs production, or different apps, with distinct dashboards and datasets.
  3. Generate an API key

    • Go to Settings → API Keys.
    • Create a new key (e.g., prod-agent), copy it, and store it in your secret manager / env vars.
    • LangSmith does not use your data to train models; traces stay within your account.

2. Instrument tracing for an existing Python agent

You don’t have to rewrite your agent. You just wrap the calls you care about.

  1. Install the SDK
pip install langsmith
  1. Set environment variables

In your deployment environment, set:

export LANGSMITH_API_KEY="your_api_key_here"
export LANGSMITH_ENDPOINT="https://api.smith.langchain.com"  # default; adjust for region/self-hosted
export LANGSMITH_PROJECT="prod-agent-traces"                  # your project name
export LANGSMITH_TRACING="true"                               # enable tracing
  1. Initialize a client (optional but useful)
from langsmith import Client

client = Client()
  1. Wrap your main agent call

If your agent entrypoint looks like:

def run_agent(user_input: str) -> str:
    # your existing logic
    ...
    return answer

You can instrument it using the tracing utilities:

from langsmith.run_helpers import traceable

@traceable(name="customer_support_agent")
def run_agent(user_input: str) -> str:
    # your existing logic
    ...
    return answer

Now, every call to run_agent(...) becomes a traceable run in LangSmith, with inputs/outputs logged.

  1. Instrument internal steps (optional, for deeper visibility)

For complex agents (tools, planners, retrievers), you can trace sub-steps:

from langsmith.run_helpers import traceable

@traceable(name="retrieve_documents")
def retrieve_docs(query: str):
    ...

@traceable(name="call_llm")
def call_llm(prompt: str):
    ...

These show up as nested runs in the timeline so you can see exactly which tool or model step failed.

  1. Verify traces in the UI
  • Trigger an agent run from your app.
  • Open LangSmith → your project → Runs.
  • You should see a new run with:
    • Input: user query / payload.
    • Output: final agent response.
    • Timeline: each traced function, model call, and tool invocation, in order.

From here, you can:

  • Click into a run to inspect the full trace.
  • Flag bad runs for later.
  • Add notes or metadata.

3. Instrument tracing for an existing TypeScript agent

The flow is the same: install the SDK, set env vars, and wrap your entrypoints.

  1. Install the SDK
npm install langsmith
# or
yarn add langsmith
# or
pnpm add langsmith
  1. Set environment variables
export LANGSMITH_API_KEY="your_api_key_here"
export LANGSMITH_ENDPOINT="https://api.smith.langchain.com"
export LANGSMITH_PROJECT="prod-agent-traces"
export LANGSMITH_TRACING="true"
  1. Initialize a client
import { Client } from "langsmith";

const client = new Client();
  1. Wrap your main handler / agent

If your agent looks like:

async function runAgent(userInput: string): Promise<string> {
  // your existing logic
  ...
  return answer;
}

Use the tracing helpers to instrument it:

import { traceable } from "langsmith/run_helpers";

const runAgent = traceable(
  async (userInput: string): Promise<string> => {
    // your existing logic
    ...
    return answer;
  },
  { name: "customer_support_agent" }
);

Every await runAgent(...) now shows up as a run in LangSmith with full inputs/outputs.

  1. Trace internal components

For tool calls or sub-agents:

import { traceable } from "langsmith/run_helpers";

const fetchDocs = traceable(
  async (query: string) => { ... },
  { name: "fetch_documents" }
);

const callLLM = traceable(
  async (prompt: string) => { ... },
  { name: "call_llm" }
);

These nested runs give you a structured timeline across your whole agent.

  1. Validate in LangSmith
  • Run your agent locally or in staging.
  • Confirm runs appear in your project.
  • Check that the correct metadata (user IDs, environment tags, etc.) is present; you can attach metadata to runs for better filtering.

Features & Benefits Breakdown

Core FeatureWhat It DoesPrimary Benefit
Trace-first observabilityCaptures every run, sub-run, tool call, and message in a structured timelineYou see exactly what happened, in what order, and why
Framework-agnostic instrumentationWorks with Python, TypeScript, OpenAI SDK, Anthropic, LangChain, LangGraph, or custom stacksYou keep your existing agent architecture and models
Datasets & evals from tracesTurns production traces into reusable datasets for offline/online evaluationYou can measure quality, catch regressions, and ship safely

Ideal Use Cases

  • Best for teams with an existing Python or TypeScript agent: Because you can instrument tracing with a few wrappers and environment variables—no redesign required.
  • Best for teams scaling to production traffic: Because LangSmith already handles millions of traces per day and lets you convert real runs into eval datasets before you roll out changes broadly.

Limitations & Considerations

  • You still need to choose what to trace: LangSmith gives you the primitives; you decide which entrypoints and internal steps to wrap. For complex agents, plan a minimal set of traceable functions to avoid noise.
  • Initial signal requires traffic: The most useful datasets and evals come from real runs. If you’re early, start tracing now so you have enough data to sample and label once usage ramps up.

Pricing & Plans

LangSmith is built for teams of any size, from individual builders to enterprises running billions of events per day.

Typical structure:

  • Usage-based tracing: Pay for what you use based on the number of traces and retention. Start free or on a low-commitment plan, then scale up as you send more production traffic.
  • Seat-based collaboration: Add teammates (engineers, PMs, subject matter experts) to review traces, label data, and configure evals.

Common plan fit:

  • Team / Plus-style plans: Best for product teams needing collaborative tracing, longer retention, and the ability to create datasets and run evals over real production traffic.
  • Enterprise plans: Best for large organizations needing SSO/SAML, SCIM, audit logs, RBAC/ABAC, US/EU data residency, hybrid or self-hosted deployment, and higher-volume trace ingestion.

For current pricing details and volume tiers, talk to sales or check the pricing page.


Frequently Asked Questions

Do I have to use LangChain or LangGraph to use LangSmith?

Short Answer: No, LangSmith is framework-agnostic.

Details: LangSmith works with any LLM framework, including OpenAI SDK, Anthropic, custom Python or TypeScript agents, LangChain, and LangGraph. You use the LangSmith SDKs (Python, TypeScript, Go, Java) or the API to send traces from whatever stack you run. If you are using LangChain or LangGraph, you can enable native tracing with a single environment variable; otherwise, you just wrap your existing functions and handlers.


Will enabling tracing change my agent’s behavior or slow it down significantly?

Short Answer: No, behavior doesn’t change; overhead is typically small.

Details: LangSmith instrumentation is side-band: it records inputs, outputs, and metadata but doesn’t alter your logic or model calls. In most setups, the added latency is modest compared to LLM calls themselves. For very high-QPS or latency-critical paths, you can:

  • Sample runs (trace only a subset).
  • Limit how deep you nest traceable functions.
  • Use different projects / environments for debug vs production traffic.

How do I start evaluating quality once tracing is enabled?

Short Answer: Turn traces into datasets, label a sample, and attach evaluators.

Details: After you have traces:

  1. In LangSmith, select runs from your project and add them to a dataset (e.g., “support-agent-production-sample”).
  2. Have subject matter experts label outputs in annotation queues (correctness, tone, policy compliance, etc.).
  3. Configure LLM-as-judge or rule-based evaluators; calibrate with human labels using Align Evals.
  4. When you change prompts, tools, or models, run offline evals against the dataset and compare results side-by-side before deploying.

Summary

Signing up for LangSmith and instrumenting your existing Python or TypeScript agent takes a few steps: create an account, grab an API key, install the SDK, and wrap your agent entrypoints with tracing helpers. From there, every run becomes a structured trace you can replay, sample into datasets, and evaluate—so you move from “we saw something weird in the logs” to “here is the exact tool call and prompt where this went wrong.”

Instead of guessing at agent behavior, you get a single, trace-first view across build, observe, evaluate, and deploy. That’s the foundation for agents that actually work in production, not just in the demo.


Next Step

Get Started

How do I sign up for LangChain LangSmith and instrument tracing for our existing agent (Python or TypeScript)? | LLM Observability & Evaluation | Codeables | Codeables