Insert Log Entry

POST
POST /api/logs/insert

Authentication

Include your API key in the request header:

HEADER
x-api-key: your-api-key-here

Request Fields

FieldTypeRequiredDescription
modelstringYesModel identifier (e.g., 'gpt-4o', 'whisper-1')
durationnumberNoProcessing time in seconds
initiatorstringNoWho triggered the request (e.g., 'user:123')
descriptionstringNoSummary of the log entry
request_dataobjectNoOriginal request payload
response_dataobjectNoResponse payload
metadataobjectNoAdditional metadata
costnumberNoCost in dollars
mediaobjectNoMedia attachments

Example Request

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);

Media Format

Note: Currently only images are supported. Additional media types will be added in future updates.

Example Media Structure

The data field can contain either:
  • Base64-encoded content (max 10MB)
  • A valid URL pointing to the media resource
{ ...,
  "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"
      }
    ]
  }
}

Update Log Entry

POST
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.

Request Format

{
  "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.

View Your Logs

Access the dashboard to view and analyze your logged data.

Open Dashboard