# langsmith

> Client library to connect to the LangSmith Observability and Evaluation Platform.

- **URL**: https://www.freshcrate.ai/projects/langsmith
- **Author**: pypi
- **Category**: Developer Tools
- **Latest version**: `v0.8.9` (2026-06-03)
- **License**: MIT
- **Source**: https://github.com/langchain-ai/langsmith-sdk
- **Homepage**: https://pypi.org/project/langsmith/
- **Language**: Python
- **GitHub**: 858 stars, 221 forks
- **Registry**: pypi (`langsmith`)
- **Tags**: `evaluation`, `langchain`, `langsmith`, `language`, `llm`, `nlp`, `platform`, `pypi`, `tracing`

## Description

# LangSmith Client SDK

[![Release Notes](https://img.shields.io/github/release/langchain-ai/langsmith-sdk?logo=python)](https://github.com/langchain-ai/langsmith-sdk/releases)
[![Python Downloads](https://img.shields.io/pypi/dm/langsmith)](https://pypi.org/project/langsmith/)

This package contains the Python client for interacting with the [LangSmith platform](https://smith.langchain.com/).

To install:

```bash
pip install -U langsmith
export LANGSMITH_TRACING=true
export LANGSMITH_API_KEY=ls_...
```

Then trace:

```python
import openai
from langsmith.wrappers import wrap_openai
from langsmith import traceable

# Auto-trace LLM calls in-context
client = wrap_openai(openai.Client())

@traceable # Auto-trace this function
def pipeline(user_input: str):
    result = client.chat.completions.create(
        messages=[{"role": "user", "content": user_input}],
        model="gpt-3.5-turbo"
    )
    return result.choices[0].message.content

pipeline("Hello, world!")
```

See the resulting nested trace [🌐 here](https://smith.langchain.com/public/b37ca9b1-60cd-4a2a-817e-3c4e4443fdc0/r).

LangSmith helps you and your team develop and evaluate language models and intelligent agents. It is compatible with any LLM application.

> **Cookbook:** For tutorials on how to get more value out of LangSmith, check out the [Langsmith Cookbook](https://github.com/langchain-ai/langsmith-cookbook/tree/main) repo.

A typical workflow looks like:

1. Set up an account with LangSmith.
2. Log traces while debugging and prototyping.
3. Run benchmark evaluations and continuously improve with the collected data.

We'll walk through these steps in more detail below.

## 1. Connect to LangSmith

Sign up for [LangSmith](https://smith.langchain.com/) using your GitHub, Discord accounts, or an email address and password. If you sign up with an email, make sure to verify your email address before logging in.

Then, create a unique API key on the [Settings Page](https://smith.langchain.com/settings), which is found in the menu at the top right corner of the page.

> [!NOTE]
> Save the API Key in a secure location. It will not be shown again.

## 2. Log Traces

You can log traces natively using the LangSmith SDK or within your LangChain application.

### Logging Traces with LangChain

LangSmith seamlessly integrates with the Python LangChain library to record traces from your LLM applications.

1. **Copy the environment variables from the Settings Page and add them to your application.**

Tracing can be activated by setting the following environment variables or by manually specifying the LangChainTracer.

```python
import os
os.environ["LANGSMITH_TRACING"] = "true"
os.environ["LANGSMITH_ENDPOINT"] = "https://api.smith.langchain.com"
# os.environ["LANGSMITH_ENDPOINT"] = "https://eu.api.smith.langchain.com" # If signed up in the EU region
os.environ["LANGSMITH_API_KEY"] = "<YOUR-LANGSMITH-API-KEY>"
# os.environ["LANGSMITH_PROJECT"] = "My Project Name" # Optional: "default" is used if not set
# os.environ["LANGSMITH_WORKSPACE_ID"] = "<YOUR-WORKSPACE-ID>" # Required for org-scoped API keys
```

> **Tip:** Projects are groups of traces. All runs are logged to a project. If not specified, the project is set to `default`.

2. **Run an Agent, Chain, or Language Model in LangChain**

If the environment variables are correctly set, your application will automatically connect to the LangSmith platform.

```python
from langchain_core.runnables import chain

@chain
def add_val(x: dict) -> dict:
    return {"val": x["val"] + 1}

add_val({"val": 1})
```

### Logging Traces Outside LangChain

You can still use the LangSmith development platform without depending on any
LangChain code.

1. **Copy the environment variables from the Settings Page and add them to your application.**

```python
import os
os.environ["LANGSMITH_ENDPOINT"] = "https://api.smith.langchain.com"
os.environ["LANGSMITH_API_KEY"] = "<YOUR-LANGSMITH-API-KEY>"
# os.environ["LANGSMITH_PROJECT"] = "My Project Name" # Optional: "default" is used if not set
```

2. **Log traces**

The easiest way to log traces using the SDK is via the `@traceable` decorator. Below is an example.

```python
from datetime import datetime
from typing import List, Optional, Tuple

import openai
from langsmith import traceable
from langsmith.wrappers import wrap_openai

client = wrap_openai(openai.Client())

@traceable
def argument_generator(query: str, additional_description: str = "") -> str:
    return client.chat.completions.create(
        [
            {"role": "system", "content": "You are a debater making an argument on a topic."
             f"{additional_description}"
             f" The current time is {datetime.now()}"},
            {"role": "user", "content": f"The discussion topic is {query}"}
        ]
    ).choices[0].message.content



@traceable
def argument_chain(query: str, additional_description: str = "") -> str:
    argument = argument_generator(query, additional_description)
    # ... Do othe

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `v0.8.9` | 2026-06-03 | High | ## What's Changed * feat(sandbox): add JS Dockerfile snapshots by @langchain-infra in https://github.com/langchain-ai/langsmith-sdk/pull/2951 * chore(deps-dev): bump the js-minor-and-patch group across 1 directory with 11 updates by @dependabot[bot] in https://github.com/langchain-ai/langsmith-sdk/pull/2931 * chore(deps): bump websockets from 15.0.1 to 16.0 in /python by @dependabot[bot] in https://github.com/langchain-ai/langsmith-sdk/pull/2811 * chore(deps): update myst-parser requirement from |
| `v0.8.6` | 2026-05-27 | High | ## What's Changed * chore(deps-dev): bump @google/genai from 1.50.1 to 2.0.1 in /js by @dependabot[bot] in https://github.com/langchain-ai/langsmith-sdk/pull/2875 * chore(deps): bump mako from 1.3.11 to 1.3.12 in /python by @dependabot[bot] in https://github.com/langchain-ai/langsmith-sdk/pull/2880 * chore(deps): bump authlib from 1.6.11 to 1.6.12 in /python by @dependabot[bot] in https://github.com/langchain-ai/langsmith-sdk/pull/2888 * chore(deps): bump hono from 4.12.15 to 4.12.18 in /js by @ |
| `v0.8.5` | 2026-05-15 | High | ## What's Changed * release(js): 0.7.0 by @ramon-langchain in https://github.com/langchain-ai/langsmith-sdk/pull/2890 * fix(js): add alias for `experimental/sandbox` to appease broad peer dep range within `deepagents` by @dqbd in https://github.com/langchain-ai/langsmith-sdk/pull/2893 * feat(js): allow disabling multipart streaming via env variable by @dqbd in https://github.com/langchain-ai/langsmith-sdk/pull/2900 * feat(python): add Client.close() to release session [closes LSDK-183] by @open- |
| `v0.8.4` | 2026-05-13 | High | ## What's Changed * release(js): 0.6.3 by @vishnu-ssuresh in https://github.com/langchain-ai/langsmith-sdk/pull/2864 * chore(deps): bump python-multipart from 0.0.26 to 0.0.27 in /python by @dependabot[bot] in https://github.com/langchain-ai/langsmith-sdk/pull/2859 * chore(deps-dev): bump @anthropic-ai/sdk from 0.91.1 to 0.92.0 in /js by @dependabot[bot] in https://github.com/langchain-ai/langsmith-sdk/pull/2858 * chore(deps): bump postcss from 8.5.8 to 8.5.14 in /js by @dependabot[bot] in https |
| `v0.8.3` | 2026-05-07 | High | ## What's Changed * fix(js): prevent sending [object Object] as span attribute when dealing with nested objects, send full langsmith.usage_metadata if present by @dqbd in https://github.com/langchain-ai/langsmith-sdk/pull/2845 * release(js): bump to 0.6.2 by @dqbd in https://github.com/langchain-ai/langsmith-sdk/pull/2856 * sdk(py): replace ttl_seconds with idle_ttl_seconds + delete_after_stop_seconds by @DanielKneipp in https://github.com/langchain-ai/langsmith-sdk/pull/2853 * sdk(js): replace |
| `v0.8.2` | 2026-05-06 | High | ## What's Changed * Bump JS SDK version to 0.6.1 by @langchain-infra in https://github.com/langchain-ai/langsmith-sdk/pull/2847 * fix: parse urllib3 version with packaging.Version by @justinwolfington in https://github.com/langchain-ai/langsmith-sdk/pull/2851 * Bump Python SDK version to 0.8.2 by @langchain-infra in https://github.com/langchain-ai/langsmith-sdk/pull/2855  ## New Contributors * @justinwolfington made their first contribution in https://github.com/langchain-ai/langsmith-sdk/pull/2 |
| `v0.8.0` | 2026-04-30 | High | ## What's Changed * feat(js,py): JS 0.6.0, Py 0.8.0 by @jacoblee93 in https://github.com/langchain-ai/langsmith-sdk/pull/2831 * release(js): 0.6.0 by @jacoblee93 in https://github.com/langchain-ai/langsmith-sdk/pull/2832 * release(py): 0.8.0 by @jacoblee93 in https://github.com/langchain-ai/langsmith-sdk/pull/2833   **Full Changelog**: https://github.com/langchain-ai/langsmith-sdk/compare/v0.7.38...v0.8.0 |
| `v0.7.38` | 2026-04-29 | High | ## What's Changed * feat(js): add tracing of opencode by @dqbd in https://github.com/langchain-ai/langsmith-sdk/pull/2776 * chore(js): Remove types/uuid by @jacoblee93 in https://github.com/langchain-ai/langsmith-sdk/pull/2814 * docs(sandbox): document default idle TTL of 10 minutes by @DanielKneipp in https://github.com/langchain-ai/langsmith-sdk/pull/2788 * ci(py): Bump pytest timeout to 2m by @jacoblee93 in https://github.com/langchain-ai/langsmith-sdk/pull/2815 * chore(deps-dev): bump the js |
| `v0.7.35` | 2026-04-24 | High | ## What's Changed * fix: patch 2 security alerts (high severity) by @jkennedyvz in https://github.com/langchain-ai/langsmith-sdk/pull/2756 * feat(python): add Hub agent/skill methods on Client and AsyncClient by @vishnu-ssuresh in https://github.com/langchain-ai/langsmith-sdk/pull/2746 * feat(js): add agent/skill hub methods on Client with unit tests by @vishnu-ssuresh in https://github.com/langchain-ai/langsmith-sdk/pull/2747 * fix(py): suppress Pydantic serialization warnings for ParsedBetaMes |
| `0.7.33` | 2026-04-21 | Low | Imported from PyPI (0.7.33) |

## Citation

- HTML: https://www.freshcrate.ai/projects/langsmith
- Markdown: https://www.freshcrate.ai/projects/langsmith.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/langsmith/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
