import requests
url = "https://api.keywordsai.co/api/traces/ingest/"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
logs = [
{
"id": "log_id_123",
"log_type": "chat",
"trace_unique_id": "trace_abc123",
"span_unique_id": "span_xyz789",
"span_name": "llm_call",
"span_workflow_name": "customer_support",
"input": '[{"role":"user","content":"Hello"}]',
"output": '{"role":"assistant","content":"Hi! How can I help?"}',
"model": "gpt-4o-mini",
"usage": {
"prompt_tokens": 10,
"completion_tokens": 8,
"total_tokens": 18
},
"timestamp": "2024-01-15T10:30:00Z",
"start_time": "2024-01-15T10:29:50Z",
"latency": 1.2
}
]
response = requests.post(url, headers=headers, json=logs)
print(response.json())