LANGSMITH_TRACING
environment variable. Note that this does not affect the RunTree
objects or API users, as these are meant to be low-level and not affected by the tracing toggle.@traceable
/ traceable
@traceable
decorator in Python and traceable
function in TypeScript.
LANGSMITH_TRACING
environment variable must be set to 'true'
in order for traces to be logged to LangSmith, even when using @traceable
or traceable
. This allows you to toggle tracing on and off without changing your code.Additionally, you will need to set the LANGSMITH_API_KEY
environment variable to your API key (see Setup for more information).By default, the traces will be logged to a project named default
. To log traces to a different project, see this section.@traceable
decorator is a simple way to log traces from the LangSmith Python SDK. Simply decorate any function with @traceable
.trace
context manager (Python only)trace
context manager to log traces to LangSmith. This is useful in situations where:
traceable
decorator and wrap_openai
wrapper, so you can use them together in the same application.
wrap_openai
/wrapOpenAI
methods in Python/TypeScript allow you to wrap your OpenAI client in order to automatically log traces — no decorator or function wrapping required! Using the wrapper ensures that messages, including tool calls and multimodal content blocks will be rendered nicely in LangSmith. Also note that the wrapper works seamlessly with the @traceable
decorator or traceable
function and you can use both in the same application.
LANGSMITH_TRACING
environment variable must be set to 'true'
in order for traces to be logged to LangSmith, even when using wrap_openai
or wrapOpenAI
. This allows you to toggle tracing on and off without changing your code.Additionally, you will need to set the LANGSMITH_API_KEY
environment variable to your API key (see Setup for more information).By default, the traces will be logged to a project named default
. To log traces to a different project, see this section.wrap_anthropic
methods in Python allows you to wrap your Anthropic client in order to automatically log traces — no decorator or function wrapping required! Using the wrapper ensures that messages, including tool calls and multimodal content blocks will be rendered nicely in LangSmith. The wrapper works seamlessly with the @traceable
decorator or traceable
function and you can use both in the same application.
LANGSMITH_TRACING
environment variable must be set to 'true'
in order for traces to be logged to LangSmith, even when using wrap_anthropic
. This allows you to toggle tracing on and off without changing your code.Additionally, you will need to set the LANGSMITH_API_KEY
environment variable to your API key (see Setup for more information).By default, the traces will be logged to a project named default
. To log traces to a different project, see this section.RunTree
APIRunTree
API. This API allows you more control over your tracing - you can manually create runs and children runs to assemble your trace. You still need to set your LANGSMITH_API_KEY
, but LANGSMITH_TRACING
is not necessary for this method.
This method is not recommended, as it’s easier to make mistakes in propagating trace context.
flush
method before exit: