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 agent.
In an agent-based workspace, create an agent once before sending traces. Use agent addressing to select its identifier and environment. If an integration requires
project_name, use the selected environment’s tracer_session_name as a compatibility value.The
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).If your LangSmith API key is linked to multiple workspaces, set the LANGSMITH_WORKSPACE_ID environment variable to specify which workspace to use.Set LANGSMITH_AGENT_ID and LANGSMITH_AGENT_ENVIRONMENT to the registered agent and environment. See Configure tracing for the agent.Connect these docs to your agent of choice via MCP for real-time answers.

