Skip to content

[Feature]: Feature Request: Add Complete Request/Response JSON Logging Similar to LiteLLM #452

@magicbrighter

Description

@magicbrighter

Prerequisites

  • I have searched existing issues and discussions to avoid duplicates

Problem to solve

Feature Request: Add Complete Request/Response JSON Logging Similar to LiteLLM

Description

I would like to request a feature to add comprehensive request and response logging similar to what LiteLLM provides. This would greatly improve debugging capabilities and transparency when working with the API.

Current Behavior

Currently, the logs provide basic information but lack detailed request/response data, making it difficult to:

  • Debug API calls effectively
  • Monitor request/response patterns
  • Troubleshoot integration issues
  • Audit API usage

Requested Feature

Add optional verbose logging that includes:

  • Complete request JSON (headers, body, parameters)
  • Full response JSON (status, headers, body)
  • Request/response timestamps
  • Request ID correlation
  • Token usage metrics

Expected Implementation

Similar to LiteLLM's logging format:

{
  "timestamp": "2025-01-10T10:25:47Z",
  "request_id": "req_123456",
  "request": {
    "method": "POST",
    "url": "/v1/chat/completions",
    "headers": {...},
    "body": {...}
  },
  "response": {
    "status": 200,
    "headers": {...},
    "body": {...},
    "latency_ms": 150
  },
  "usage": {
    "prompt_tokens": 100,
    "completion_tokens": 50,
    "total_tokens": 150
  }
}

Configuration Suggestions

  • Environment variable: ENABLE_VERBOSE_LOGGING=true
  • Config parameter: verbose_logging: true
  • Log level: --log-level debug-verbose
  • Optional log file output: --log-file api_calls.jsonl

Use Cases

  • Development: Debug request/response issues
  • Monitoring: Track API performance and usage
  • Compliance: Audit logging for enterprise requirements
  • Integration: Easier troubleshooting with external systems

Benefits

  • Improved developer experience
  • Better debugging capabilities
  • Enhanced observability
  • Compliance with enterprise logging requirements

Would be happy to contribute to this feature if guidance is provided on the preferred implementation approach.

Proposed solution

Image

Alternatives considered

No response

Area(s)

Transports (HTTP)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions