curl to send trace data from any system that can make HTTP requests.
Prerequisites:
- Ensure you have
curlinstalled on your system.
LANGWATCH_API_KEY environment variable in your environment:
- Prepare your JSON data. Make sure it’s properly formatted as expected by LangWatch.
- Use the curl command to send your trace data. Here is a basic template:
@- tells curl to read the JSON data from the standard input, which we provide via the EOF-delimited here-document.
All timestamps are unix epoch milliseconds. The optional first_token_at records when the first streamed token reached the user and powers the Time to First Token (TTFT) metric, see Tracking Time to First Token. Token counts and cost are derived from metrics and the model pricing registry, see Tracking LLM Costs and Tokens.
For the type reference of how a span should look like, check out our types definitions.
It’s optional but highly recommended to pass the user_id on the metadata if you want to use user-specific analytics and the thread_id to group related traces together. Read more about those and other concepts.
- Execute the
curlcommand. If successful, LangWatch will process your trace data.
curl command to handle these cases.
The same request from Python
Check it worked
A successful request returns a2xx status. Then open your project in LangWatch: the trace trace-123 appears in the traces list within a few seconds, with one LLM span holding the input and output you sent. Use a new trace_id for each trace you send.
If the request is refused or no trace appears, check that LANGWATCH_API_KEY holds a valid project API key.