Chat Completions
curl --request POST \
--url https://api.tracelm.ai/v1/chat/completionsimport requests
url = "https://api.tracelm.ai/v1/chat/completions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.tracelm.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tracelm.ai/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tracelm.ai/v1/chat/completions"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tracelm.ai/v1/chat/completions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tracelm.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyAPI Reference
Chat Completions
OpenAI-compatible chat completions with TraceLM tracing and reliability context
POST
/
v1
/
chat
/
completions
Chat Completions
curl --request POST \
--url https://api.tracelm.ai/v1/chat/completionsimport requests
url = "https://api.tracelm.ai/v1/chat/completions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.tracelm.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tracelm.ai/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tracelm.ai/v1/chat/completions"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tracelm.ai/v1/chat/completions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tracelm.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyOpenAI-compatible endpoint with tracing and reliability metadata capture.
Required Headers
X-API-Key: lt_...Authorization: Bearer <provider_key>Content-Type: application/json
Optional Headers
X-Provider: openai | anthropic | googleX-Task-ID,X-Task-Name,X-Conversation-ID,X-User-ID
Request Body
Pass standard OpenAI Chat Completions payload fields (model, messages, tools, temperature, max_tokens, stream, etc.).
Example
curl -X POST "https://api.tracelm.ai/v1/chat/completions" \
-H "X-API-Key: $TRACELM_API_KEY" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "X-Provider: openai" \
-H "X-Task-ID: 550e8400-e29b-41d4-a716-446655440000" \
-H "X-Conversation-ID: 660e8400-e29b-41d4-a716-446655440000" \
-H "X-User-ID: user_123" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role":"user","content":"Find me flights to NYC"}],
"tools": []
}'
Response
Returns OpenAI-compatible response shape. Trace and task-level metrics are available through/api/v1/tasks/* and /api/v1/conversations/*.
