Overview
The Logs API allows you to create, retrieve, and list conversation logs. Logs capture the complete context of interactions including messages, model information, token usage, and metadata.Key Features
- Create logs for conversations and API requests
- Retrieve specific logs by ID
- List logs with filtering and pagination
- Track token usage and costs
- Store custom metadata for analysis
Quick Start
Available Methods
Synchronous Methods
Method | Description |
---|---|
create() | Create a new log entry |
list() | List logs with optional filtering |
get() | Retrieve a specific log by ID |
Asynchronous Methods
Method | Description |
---|---|
acreate() | Async version of create |
alist() | Async version of list |
aget() | Async version of get |
Update and delete operations are not supported for logs to maintain data integrity and audit trails.
Log Structure
A log entry contains the following key information:Common Use Cases
1. Logging Chat Conversations
2. Tracking API Usage
3. Performance Monitoring
Filtering and Search
When listing logs, you can apply various filters:Best Practices
1. Include Relevant Metadata
2. Log Errors and Edge Cases
3. Use Async for High Volume
Error Handling
Next Steps
- Learn how to create logs
- Explore listing and filtering logs
- Understand how to retrieve specific logs
- See complete examples for real-world usage