Claude Code is one of the most impressive and useful AI coding tools to date. Claude code emits for monitoring and observability. LangSmith can collect and display these events to give you a full detailed log on what Claude Code does under the hood.
You can integrate LangSmith tracing with Claude Code by setting the following environment variables in the environment in which you run Claude Code.
Copy
Ask AI
# Enables Claude Code to emit OTEL eventsexport CLAUDE_CODE_ENABLE_TELEMETRY=1# Sets the output format to use Open Telemetry Protocolexport OTEL_LOGS_EXPORTER=otlp# LangSmith ingests JSON format eventsexport OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/json# Claude Code Logs are translated to Spans by LangSmithexport OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://api.smith.langchain.com/otel/v1/claude_code# Pass your API key and desired tracing project through headersexport OTEL_EXPORTER_OTLP_HEADERS="x-api-key=<api-key>,Langsmith-Project=<project-name>"# Set this to true in order to log the input user promptsexport OTEL_LOG_USER_PROMPTS=1# Once these are set, start Claude Code, and events will be traced to LangSmithclaude
If you’re self-hosting LangSmith, replace the base endpoint with your LangSmith api endpoint and append /api/v1. For example: OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://ai-company.com/api/v1/otel/v1/claude_code