Trace - Cost and Performance
Tracing and Performance Monitoring with Infron AI
Last updated
Tracing and Performance Monitoring with Infron AI
Last updated
import requests
import json
import uuid
# Auto-generate tracing identifiers
trace_id = str(uuid.uuid4())
span_id = str(uuid.uuid4())[:8]
parent_id = "root"
trace_tags = "model=claude-3-5-sonnet@20240620,env=prod,region=us-east-1"
response = requests.post(
url="https://llm.onerouter.pro/v1/chat/completions",
headers={
"Authorization": "Bearer <API_KEY>",
"Content-Type": "application/json",
# Pass tracing headers
"trace-id": trace_id,
"span-id": span_id,
"parent-id": parent_id,
"x-trace-tags": trace_tags
},
data=json.dumps({
"model": "claude-3-5-sonnet@20240620",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
})
)
print(response.json()["choices"][0]["message"]["content"])