Skip to main content
The following environment variables allow you to configure tracing enabled, the API endpoint, the API key, and the tracing project:
  • LANGSMITH_TRACING
  • LANGSMITH_API_KEY
  • LANGSMITH_ENDPOINT
  • LANGSMITH_PROJECT
If you need to trace runs with a custom configuration, are working in an environment that doesn’t support typical environment variables (such as Cloudflare Workers), or prefer not to rely on environment variables, LangSmith allows you to configure tracing programmatically.
In version 0.1.95 of the Python SDK, with trace honors the LANGSMITH_TRACING environment variable. For details, refer to the release notes. To disable or enable tracing without setting environment variables, use the with tracing_context context manager, as shown in the following example.
  • Python: The recommended way to do this in Python is to use the tracing_context context manager. This works for both code annotated with traceable and code within the trace context manager.
  • TypeScript: You can pass in both the client and the tracingEnabled flag to the traceable decorator.
If you prefer a video tutorial, check out the Alternative Ways to Trace video from the Introduction to LangSmith Course. If you need to dynamically enable or disable tracing based on runtime conditions (such as client requirements, data sensitivity, or compliance policies), refer to Conditional tracing for examples.