# LangSmith tracing setup

## 1. Account and key

Sign up or log in at smith.langchain.com (free tier exists). Create an API key from the settings page.

## 2. Environment variables

Set these before the app process starts:

- LANGSMITH_TRACING=true (the master switch; the old LANGCHAIN_TRACING name is stale)
- LANGSMITH_API_KEY holding your LangSmith key
- LANGSMITH_PROJECT to name the project (defaults to `default`)
- LANGSMITH_ENDPOINT only for regional accounts, e.g. `https://eu.api.smith.langchain.com` for EU, with no trailing slash
- LANGSMITH_WORKSPACE_ID if your key is linked to multiple workspaces

## 3. Run

No code changes. Run your agent normally:

```python
from langchain.agents import create_agent

agent = create_agent(model="gpt-5.5", tools=[...])
agent.invoke({"messages": [{"role": "user", "content": "hello"}]})
```

## 4. Verify

Open the project in the LangSmith UI. One trace with the full step tree (model calls, tool calls, decisions) confirms the whole chain.

## Rules

- Set the variables in the process environment, not in a shell you hope launched the process. Notebooks, containers, and schedulers drop env vars silently.
- Regional account without LANGSMITH_ENDPOINT gives 401s: the key is not recognized on the wrong region's endpoint.
- The docs also recommend LangSmith Engine, which monitors traces and proposes fixes, once basic tracing works.