Logs
Ingest Logs from traces
POST
/
api
/
traces
/
ingest
/
[
{
"id": "log_id_123",
"log_type": "chat",
"trace_unique_id": "trace_abc123",
"span_unique_id": "span_xyz789",
"span_name": "llm_call",
"span_parent_id": null,
"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,
"status": "success"
}
]
[
{
"id": "workflow_log_456",
"log_type": "workflow",
"trace_unique_id": "trace_abc123",
"span_unique_id": "span_workflow_001",
"span_name": "customer_support_workflow",
"span_parent_id": null,
"span_workflow_name": "customer_support",
"input": "{\"customer_query\":\"Order status?\",\"customer_id\":\"cust_123\"}",
"output": "{\"status\":\"resolved\",\"result\":\"Order shipped\",\"steps\":5}",
"timestamp": "2024-01-15T10:30:00Z",
"start_time": "2024-01-15T10:29:50Z",
"latency": 3.5,
"status": "success"
}
]
[
{
"id": "task_log_789",
"log_type": "task",
"trace_unique_id": "trace_abc123",
"span_unique_id": "span_task_002",
"span_name": "fetch_order_details",
"span_parent_id": "span_workflow_001",
"span_workflow_name": "customer_support",
"input": "{\"order_id\":\"order_12345\"}",
"output": "{\"order_id\":\"order_12345\",\"status\":\"shipped\",\"tracking\":\"TRACK123\"}",
"timestamp": "2024-01-15T10:29:55Z",
"start_time": "2024-01-15T10:29:54Z",
"latency": 0.8,
"status": "success"
}
]
Ingest trace data as logs. This endpoint allows you to convert trace data into log format for storage and analysis using the universal input/output design.
Universal input/output support
This endpoint accepts logs with:input: Any JSON-serializable structure (string, object, array)output: Any JSON-serializable structure (string, object, array)log_type: Determines how input/output are interpreted ("chat","embedding","workflow","task", etc.)
log_type. See log types for complete specifications and the Create Log documentation for all field details.
Authentication
All endpoints require API key authentication:Authorization: Bearer YOUR_API_KEY
Request body
The request body should be an array of log objects. Each log object should contain trace and span information.[
{
"id": "log_id_123",
"log_type": "chat",
"trace_unique_id": "trace_abc123",
"span_unique_id": "span_xyz789",
"span_name": "llm_call",
"span_parent_id": null,
"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,
"status": "success"
}
]
[
{
"id": "workflow_log_456",
"log_type": "workflow",
"trace_unique_id": "trace_abc123",
"span_unique_id": "span_workflow_001",
"span_name": "customer_support_workflow",
"span_parent_id": null,
"span_workflow_name": "customer_support",
"input": "{\"customer_query\":\"Order status?\",\"customer_id\":\"cust_123\"}",
"output": "{\"status\":\"resolved\",\"result\":\"Order shipped\",\"steps\":5}",
"timestamp": "2024-01-15T10:30:00Z",
"start_time": "2024-01-15T10:29:50Z",
"latency": 3.5,
"status": "success"
}
]
[
{
"id": "task_log_789",
"log_type": "task",
"trace_unique_id": "trace_abc123",
"span_unique_id": "span_task_002",
"span_name": "fetch_order_details",
"span_parent_id": "span_workflow_001",
"span_workflow_name": "customer_support",
"input": "{\"order_id\":\"order_12345\"}",
"output": "{\"order_id\":\"order_12345\",\"status\":\"shipped\",\"tracking\":\"TRACK123\"}",
"timestamp": "2024-01-15T10:29:55Z",
"start_time": "2024-01-15T10:29:54Z",
"latency": 0.8,
"status": "success"
}
]
Examples
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())
import requests
url = "https://api.keywordsai.co/api/traces/ingest/"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
# Ingest a workflow with child tasks
logs = [
# Parent workflow
{
"id": "workflow_log_001",
"log_type": "workflow",
"trace_unique_id": "trace_abc123",
"span_unique_id": "span_workflow_001",
"span_name": "customer_support_workflow",
"span_parent_id": None,
"span_workflow_name": "customer_support",
"input": '{"customer_query":"Order status?","customer_id":"cust_123"}',
"output": '{"status":"resolved","result":"Order shipped","steps":5}',
"timestamp": "2024-01-15T10:30:00Z",
"start_time": "2024-01-15T10:29:50Z",
"latency": 3.5
},
# Child task
{
"id": "task_log_002",
"log_type": "task",
"trace_unique_id": "trace_abc123",
"span_unique_id": "span_task_002",
"span_name": "fetch_order_details",
"span_parent_id": "span_workflow_001",
"span_workflow_name": "customer_support",
"input": '{"order_id":"order_12345"}',
"output": '{"order_id":"order_12345","status":"shipped","tracking":"TRACK123"}',
"timestamp": "2024-01-15T10:29:55Z",
"start_time": "2024-01-15T10:29:54Z",
"latency": 0.8
}
]
response = requests.post(url, headers=headers, json=logs)
print(response.json())
curl -X POST "https://api.keywordsai.co/api/traces/ingest/" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '[{
"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
}]'
curl -X POST "https://api.keywordsai.co/api/traces/ingest/" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '[{
"id": "workflow_log_001",
"log_type": "workflow",
"trace_unique_id": "trace_abc123",
"span_unique_id": "span_workflow_001",
"span_name": "customer_support_workflow",
"span_workflow_name": "customer_support",
"input": "{\"customer_query\":\"Order status?\",\"customer_id\":\"cust_123\"}",
"output": "{\"status\":\"resolved\",\"result\":\"Order shipped\",\"steps\":5}",
"timestamp": "2024-01-15T10:30:00Z",
"start_time": "2024-01-15T10:29:50Z",
"latency": 3.5
}]'
Response
200 OK
{
"success": true,
"ingested_count": 1
}
Was this page helpful?
⌘I
[
{
"id": "log_id_123",
"log_type": "chat",
"trace_unique_id": "trace_abc123",
"span_unique_id": "span_xyz789",
"span_name": "llm_call",
"span_parent_id": null,
"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,
"status": "success"
}
]
[
{
"id": "workflow_log_456",
"log_type": "workflow",
"trace_unique_id": "trace_abc123",
"span_unique_id": "span_workflow_001",
"span_name": "customer_support_workflow",
"span_parent_id": null,
"span_workflow_name": "customer_support",
"input": "{\"customer_query\":\"Order status?\",\"customer_id\":\"cust_123\"}",
"output": "{\"status\":\"resolved\",\"result\":\"Order shipped\",\"steps\":5}",
"timestamp": "2024-01-15T10:30:00Z",
"start_time": "2024-01-15T10:29:50Z",
"latency": 3.5,
"status": "success"
}
]
[
{
"id": "task_log_789",
"log_type": "task",
"trace_unique_id": "trace_abc123",
"span_unique_id": "span_task_002",
"span_name": "fetch_order_details",
"span_parent_id": "span_workflow_001",
"span_workflow_name": "customer_support",
"input": "{\"order_id\":\"order_12345\"}",
"output": "{\"order_id\":\"order_12345\",\"status\":\"shipped\",\"tracking\":\"TRACK123\"}",
"timestamp": "2024-01-15T10:29:55Z",
"start_time": "2024-01-15T10:29:54Z",
"latency": 0.8,
"status": "success"
}
]