POST /api/logs/insert
Include your API key in the request header:
x-api-key: your-api-key-here
Field | Type | Required | Description |
---|---|---|---|
model | string | Yes | Model identifier (e.g., 'gpt-4o', 'whisper-1') |
duration | number | No | Processing time in seconds |
initiator | string | No | Who triggered the request (e.g., 'user:123') |
description | string | No | Summary of the log entry |
request_data | object | No | Original request payload |
response_data | object | No | Response payload |
metadata | object | No | Additional metadata |
cost | number | No | Cost in dollars |
media | object | No | Media attachments |
const response = await fetch('/api/logs/insert', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'your-api-key-here'
},
body: JSON.stringify({
model: 'gpt-4o',
duration: 2.3,
initiator: 'user:12345',
description: 'Chat completion request',
request_data: {
messages: [{ role: 'user', content: 'Hello' }],
temperature: 0.7
},
response_data: {
choices: [{ message: { role: 'assistant', content: 'Hi there!' } }],
usage: { total_tokens: 25 }
},
metadata: {
client_version: '1.0.0',
environment: 'production',
user_agent: 'Mozilla/5.0',
session_id: 'sess_123abc'
},
cost: 0.001
})
});
const result = await response.json();
console.log('Log ID:', result.id);
Note: Currently only images are supported. Additional media types will be added in future updates.
data
field can contain either:{ ...,
"media": {
"request": [
{
"type": "image",
"title": "Input image 1",
"data": "base64-encoded-image-data"
},
{
"type": "image",
"title": "Input image 2",
"data": "https://example.com/image.jpg"
},
{
"type": "image",
"title": "Reference image",
"data": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
}
],
"response": [
{
"type": "image",
"title": "Generated variation 1",
"data": "https://api.example.com/images/generated-1.png"
},
{
"type": "image",
"title": "Generated variation 2",
"data": "base64-encoded-image-data"
}
]
}
}
POST /api/logs/update
Update an existing log entry. This endpoint accepts the same fields as the insert endpoint, plus an ID to identify the log entry to update.
{
"id": "log_entry_id",
"update_data": {
// Same fields as insert endpoint
"model": "gpt-4o",
"duration": 2.3,
"initiator": "user:12345",
"description": "Updated description",
// ... other fields
}
}
Note: All fields in the update_data object are optional. Only provide the fields you want to update.
Access the dashboard to view and analyze your logged data.