Skip to main content
Learn how to trace your LLM applications using the LangSmith API directly. It is highly recommended to use our Python or TypeScript SDKs to send traces to LangSmith. We have designed these SDKs with optimizations like batching and backgrounding to ensure that your application’s performance is not impacted by sending traces to LangSmith. However, if you are unable to use our SDKs, you can use the LangSmith REST API to send traces. Performance may be impacted if you send traces synchronously in your application. This guide will show you how to trace a request using the LangSmith REST API. Please view our API documentation for a full list of endpoints and request/response schemas.

Basic tracing

The simplest way to log runs is via the POST and PATCH /runs endpoint. These routes expect minimal contextual information about the tree structure to
When using the LangSmith REST API, you will need to provide your API key in the request headers as "x-api-key".If your API key is linked to multiple workspaces, you will need to specify the workspace being used in the header with "x-tenant-id".In the simple example, you do not need to set the dotted_order opr trace_id fields in the request body. These fields will be automatically generated by the system. Though this is simpler, it is slower and has a lower rate limit in LangSmith.
The following example shows how you might leverage our API directly in Python. The same principles apply to other languages.
See the doc on the Run (span) data format for more information.

Batch Ingestion

For faster ingestion of runs and higher rate limits, you can use the POST /runs/multipart link endpoint. Below is an example. It requires orjson (for fast json ) and requests_toolbelt to run

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.