> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-devupd-1765394015-eccef47.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Trace Claude Code

[Claude Code](https://code.claude.com/docs/en/overview) is one of the most impressive and useful AI coding tools to date. Claude code emits events 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.

## Quick Start

You can integrate LangSmith tracing with Claude Code by setting the following environment variables in the environment in which you run Claude Code.

```bash theme={null}
# Enables Claude Code to emit OTEL events
export CLAUDE_CODE_ENABLE_TELEMETRY=1

# Sets the output format to use Open Telemetry Protocol
export OTEL_LOGS_EXPORTER=otlp

# LangSmith ingests JSON format events
export OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/json

# Claude Code Logs are translated to Spans by LangSmith
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://api.smith.langchain.com/otel/v1/claude_code

# Pass your API key and desired tracing project through headers
export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=<api-key>,Langsmith-Project=<project-name>"

# Set this to true in order to log the input user prompts
export OTEL_LOG_USER_PROMPTS=1

# Once these are set, start Claude Code, and events will be traced to LangSmith
claude
```

<Note>
  Claude Code emits [open telemetry standard events](https://code.claude.com/docs/en/monitoring-usage#events) for monitoring usage, but this does not include the actual prompts and messages that go to the LLM.
</Note>

<Note>
  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`
</Note>

<img src="https://mintcdn.com/langchain-5e9cc07a-preview-devupd-1765394015-eccef47/pC7uS4KE47pwF6As/langsmith/images/claude-code-trace.png?fit=max&auto=format&n=pC7uS4KE47pwF6As&q=85&s=615433fa2c63668d9f3fcedb2f11b0ab" alt="Claude Code Trace" width="3406" height="1972" data-path="langsmith/images/claude-code-trace.png" />

***

<Callout icon="pen-to-square" iconType="regular">
  [Edit the source of this page on GitHub.](https://github.com/langchain-ai/docs/edit/main/src/langsmith/trace-claude-code.mdx)
</Callout>

<Tip icon="terminal" iconType="regular">
  [Connect these docs programmatically](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
</Tip>
