{"id":36,"library":"langsmith","title":"LangSmith","description":"Official Python SDK for LangSmith — LangChain's observability, tracing, and evaluation platform. Instruments LLM calls, chains, agents, and arbitrary functions with the @traceable decorator or wrap_openai(). Traces are sent asynchronously to LangSmith cloud (or self-hosted). Also provides dataset management and evaluation (evaluate()) APIs. Usable standalone without LangChain. Releases multiple times per week. SECURITY NOTE: CVE-2026-25528 — SSRF via baggage header injection, fixed in 0.6.3. Any version 0.4.10–0.6.2 is vulnerable.","status":"active","version":"0.7.7","language":"python","source_language":"en","source_url":"https://github.com/langchain-ai/langsmith-sdk","tags":["langsmith","tracing","observability","langchain","evaluation","llm-monitoring","traceable","evals"],"install":[{"cmd":"pip install langsmith","lang":"bash","label":"Core SDK"},{"cmd":"pip install 'langsmith[otel]'","lang":"bash","label":"With OpenTelemetry export support"},{"cmd":"pip install 'langsmith[pytest]'","lang":"bash","label":"With pytest integration for evals"}],"dependencies":[],"imports":[{"note":"Primary decorator for instrumenting any function. Works standalone — does not require LangChain.","symbol":"traceable","correct":"from langsmith import traceable"},{"note":"Wraps an OpenAI client to auto-trace all calls. Equivalent wrappers exist for Anthropic (wrap_anthropic).","symbol":"wrap_openai","correct":"from langsmith.wrappers import wrap_openai"},{"note":"Low-level client for dataset management, run querying, and evaluation APIs.","symbol":"Client","correct":"from langsmith import Client"}],"quickstart":{"code":"import os\nos.environ['LANGSMITH_TRACING'] = 'true'\nos.environ['LANGSMITH_API_KEY'] = 'ls_...'\nos.environ['LANGSMITH_PROJECT'] = 'my-project'\n\n# Option 1: Wrap OpenAI client (auto-traces all calls)\nimport openai\nfrom langsmith.wrappers import wrap_openai\n\nclient = wrap_openai(openai.OpenAI())\nresponse = client.chat.completions.create(\n    model='gpt-4o',\n    messages=[{'role': 'user', 'content': 'Hello!'}]\n)\n\n# Option 2: @traceable decorator for arbitrary functions\nfrom langsmith import traceable\n\n@traceable\ndef my_pipeline(query: str) -> str:\n    # any code here is traced as a span\n    response = client.chat.completions.create(\n        model='gpt-4o',\n        messages=[{'role': 'user', 'content': query}]\n    )\n    return response.choices[0].message.content\n\nresult = my_pipeline('What is 2+2?')\n\n# Option 3: LangChain auto-tracing (no decorator needed)\n# Just set env vars — all LangChain/LangGraph calls are traced automatically\nfrom langchain_openai import ChatOpenAI\nllm = ChatOpenAI(model='gpt-4o')\nllm.invoke('Hello!')  # automatically traced","lang":"python","description":"Env vars must be set BEFORE importing LangChain/LangSmith — they are read at import time. Setting them after import has no effect. LANGSMITH_TRACING must be the string 'true', not a boolean."},"warnings":[{"fix":"Upgrade immediately: pip install 'langsmith>=0.6.3'. Do not run affected versions in environments that process untrusted HTTP requests.","message":"CVE-2026-25528: SSRF via baggage header injection. The distributed tracing feature is vulnerable — attackers can inject arbitrary api_url values via the baggage HTTP header, causing the SDK to exfiltrate trace data to attacker-controlled endpoints. Affects versions 0.4.10–0.6.2.","severity":"breaking","affected_versions":">=0.4.10,<0.6.3"},{"fix":"Standardize on LANGSMITH_TRACING and LANGSMITH_API_KEY in all new code and CI configs. Remove LANGCHAIN_TRACING_V2 from environments.","message":"LANGCHAIN_TRACING_V2 and LANGCHAIN_API_KEY are the legacy env var names. Current docs use LANGSMITH_TRACING and LANGSMITH_API_KEY. Both still work, but mixing old and new names in the same environment causes confusing precedence issues.","severity":"breaking","affected_versions":"all"},{"fix":"Upgrade langchain to the latest version before upgrading langsmith. Or pin both: langchain==0.3.x requires langsmith<0.2.","message":"langsmith 0.5+ has a strict version conflict with older langchain versions. langchain 0.3.x requires langsmith<0.2.0. Installing langsmith>=0.5 in a langchain 0.3 environment causes a pip resolver conflict that breaks the entire environment.","severity":"breaking","affected_versions":"langsmith>=0.5 with langchain<0.4"},{"fix":"Set all LANGSMITH_* env vars at the very top of your entry point, before any LangChain/LangSmith imports. Use .env files loaded via python-dotenv before other imports.","message":"LANGSMITH_TRACING must be set BEFORE LangChain is imported. LangChain reads the env var at import time. Setting os.environ['LANGSMITH_TRACING'] = 'true' after 'from langchain...' has already run produces zero traces with no error.","severity":"gotcha","affected_versions":"all"},{"fix":"Always quote the value: LANGSMITH_TRACING='true' (shell) or LANGSMITH_TRACING: 'true' (YAML).","message":"LANGSMITH_TRACING='true' must be a string, not a boolean. In some YAML/env file parsers, setting LANGSMITH_TRACING: true (no quotes) passes the Python boolean True, which the SDK does not recognize. Traces silently drop.","severity":"gotcha","affected_versions":"all"},{"fix":"Call langsmith.utils.wait_for_all_tracers() at the end of short-lived scripts to ensure all traces are flushed before exit.","message":"Traces are sent asynchronously in a background thread. In short-lived scripts, the process may exit before all traces are flushed, resulting in missing or partial traces in the UI.","severity":"gotcha","affected_versions":"all"},{"fix":"Install the 'openai' package: `pip install openai`. Ensure all external dependencies required by your application are explicitly listed and installed.","message":"The script attempts to import the 'openai' package, but it is not installed in the environment. This error occurs when your application relies on 'openai' without explicitly including it in its dependencies.","severity":"breaking","affected_versions":"all"}],"env_vars":{"optional":[{"name":"LANGSMITH_PROJECT","note":"Project name to group traces. Defaults to 'default'."},{"name":"LANGSMITH_ENDPOINT","note":"Override for self-hosted deployments. Defaults to https://api.smith.langchain.com."},{"name":"LANGCHAIN_TRACING_V2","note":"Legacy alias for LANGSMITH_TRACING. Still works but deprecated. New docs use LANGSMITH_TRACING."},{"name":"LANGCHAIN_API_KEY","note":"Legacy alias for LANGSMITH_API_KEY. Still works but deprecated."}],"required":[{"name":"LANGSMITH_API_KEY","note":"API key from smith.langchain.com. Format: ls_..."},{"name":"LANGSMITH_TRACING","note":"Enables tracing. Must be the string 'true' (quoted). Without this, no traces are sent — silently.","value":"true"}]},"last_verified":"2026-05-12T05:18:37.051Z","next_check":"2026-05-28T00:00:00.000Z","problems":[{"fix":"Ensure the `LANGCHAIN_API_KEY` environment variable is correctly set with your valid LangSmith API key (it should start with `ls_`). Verify that `LANGCHAIN_PROJECT` matches an existing project name in your LangSmith dashboard and that `LANGCHAIN_TRACING_V2` is set to 'true'. Regenerate your API key on the LangSmith settings page if unsure.","cause":"This error typically occurs due to an incorrect LangSmith API key, using the wrong environment variable name (e.g., LANGSMITH_API_KEY instead of LANGCHAIN_API_KEY), an invalid project name in LANGCHAIN_PROJECT, or insufficient permissions for the API key.","error":"langsmith.utils.LangSmithAuthError: Authentication failed"},{"fix":"In Chrome, navigate to `https://smith.langchain.com`, click the lock icon in the address bar, find 'Local network access', and change its setting to 'Allow'. Reload the page. Alternatively, temporarily disable browser extensions (especially AI-related ones) or run `langgraph dev --tunnel` and use the provided tunnel URL in Studio's 'Connect to a local server' option.","cause":"This issue arises when the LangSmith Studio (an HTTPS site) cannot connect to a local development server (HTTP localhost), primarily due to Chrome versions 142+ enforcing Private Network Access (PNA) specifications or interfering browser extensions.","error":"TypeError: Failed to fetch (LangSmith Studio / langgraph dev connection issue)"},{"fix":"Set the environment variable `LANGCHAIN_TRACING_V2=true` (or `LANGSMITH_TRACING=true`). Double-check `LANGCHAIN_API_KEY` and `LANGCHAIN_ENDPOINT` for correctness. For short scripts or applications that exit quickly, explicitly call `langsmith.flush_traces()` or `langchain.callbacks.tracers.wait_for_all_tracers()` at the end of your script to ensure traces are sent.","cause":"Traces might not appear if the tracing environment variables (`LANGCHAIN_TRACING_V2` or `LANGSMITH_TRACING`) are not set to 'true', if the LangSmith API key or endpoint is incorrect, or if the Python process exits before asynchronous traces can be flushed and sent to LangSmith.","error":"No traces appearing in LangSmith UI when using @traceable decorator"},{"fix":"Install the `langsmith` package using `pip install -U langsmith`. If in a virtual environment, ensure it's activated. For deployment, explicitly list `langsmith` in your `requirements.txt` or `pyproject.toml` and verify that your deployment pipeline successfully installs all dependencies.","cause":"This indicates that the `langsmith` package, or a specific submodule it depends on, is not installed in the currently active Python environment, or it's not correctly bundled/installed in deployment environments like Docker containers or cloud platforms.","error":"ModuleNotFoundError: No module named 'langsmith'"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"otel","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.49,"mem_mb":28,"disk_size":"63.4M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pytest","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.32,"mem_mb":20,"disk_size":"73.6M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.32,"mem_mb":20,"disk_size":"55.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"otel","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.08,"mem_mb":28,"disk_size":"71M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pytest","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.95,"mem_mb":20,"disk_size":"82M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.94,"mem_mb":20,"disk_size":"63M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"otel","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.96,"mem_mb":30,"disk_size":"68.3M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pytest","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.74,"mem_mb":22.5,"disk_size":"79.7M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.74,"mem_mb":22.5,"disk_size":"59.2M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"otel","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.64,"mem_mb":30,"disk_size":"76M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pytest","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.44,"mem_mb":22.5,"disk_size":"88M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.44,"mem_mb":22.5,"disk_size":"67M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"otel","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.89,"mem_mb":30,"disk_size":"59.5M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pytest","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.67,"mem_mb":21.7,"disk_size":"70.6M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.66,"mem_mb":21.6,"disk_size":"50.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"otel","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.81,"mem_mb":30,"disk_size":"68M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pytest","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.7,"mem_mb":21.7,"disk_size":"79M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.69,"mem_mb":21.6,"disk_size":"58M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"otel","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.81,"mem_mb":30.5,"disk_size":"59.1M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pytest","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.61,"mem_mb":22.6,"disk_size":"70.4M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.6,"mem_mb":22.6,"disk_size":"50.2M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"otel","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.8,"mem_mb":30.5,"disk_size":"67M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pytest","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.58,"mem_mb":22.6,"disk_size":"79M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.63,"mem_mb":22.6,"disk_size":"58M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"otel","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.21,"mem_mb":25.6,"disk_size":"60.0M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pytest","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.05,"mem_mb":18.2,"disk_size":"72.1M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.04,"mem_mb":18.3,"disk_size":"51.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"otel","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.07,"mem_mb":25.6,"disk_size":"68M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pytest","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.91,"mem_mb":18.2,"disk_size":"81M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.95,"mem_mb":18.3,"disk_size":"60M"}]},"quickstart_checks":{"last_tested":"2026-05-12","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}