Skip to main content

Observability

The AI Gateway provides complete visibility into every AI request made from your applications or development tools. Know exactly what data is being sent, track usage patterns, and identify issues before they become problems.

The Problem

When using AI providers directly, you have limited visibility:
  • What code is being sent? You don’t know exactly what context is included
  • Are secrets exposed? API keys and passwords might be in the request
  • How much are you spending? Token usage is hard to track across tools
  • What’s failing? Errors are logged on the provider’s side, not yours

Complete Request Logging

Every request through the AI Gateway is logged with full details:
Request detail view

What’s Logged

FieldDescription
TimestampWhen the request was made
Request BodyFull content sent to the AI provider
Response BodyComplete response received
ModelWhich AI model was used
TokensInput, output, and total token counts
LatencyResponse time in milliseconds
User IDWhich user made the request (if provided)
Session IDSession tracking for conversation grouping
StatusSuccess, error, or blocked

Viewing Logs

Access logs in your dashboard:
  1. Navigate to AI Gateway > Logs
  2. Use filters to narrow down:
    • Date range
    • Model
    • User ID
    • Status (success/error/blocked)
    • Contains text
Log filtering options

See Your Entire Codebase

When using AI coding assistants, the gateway shows you exactly what’s being sent:
Code context visibility

What Gets Sent to AI

AI assistants typically send:
  • The file you’re editing
  • Surrounding context from nearby files
  • Open tabs in your editor
  • Terminal output
  • Error messages
With the gateway, you can see all of this - no more guessing what context is included.

Identifying Sensitive Data

The gateway automatically detects potentially sensitive data:

Credentials

  • API keys (AWS, GitHub, etc.)
  • Database passwords
  • OAuth tokens
  • Private keys

Personal Data

  • Email addresses
  • Phone numbers
  • Social security numbers
  • Credit card numbers

Internal Data

  • Internal URLs
  • Private IP addresses
  • Server names
  • Database connection strings

Business Data

  • Customer data
  • Financial figures
  • Proprietary algorithms
  • Trade secrets

Download and Analyze

Export Options

Export your data for analysis:
  • JSON - Full structured data for programmatic analysis
  • CSV - Spreadsheet-compatible for reporting
  • Filtered exports - Only export what you need
# Example: Export last 7 days
curl -X GET "https://api.leanmcp.com/gateway/logs?days=7" \
  -H "Authorization: Bearer your-api-key" \
  -o logs.json

What You Can Discover

Search logs for patterns like API keys, passwords, or personal data to find and remediate exposure.
Understand which features generate the most AI requests and optimize accordingly.
Identify which requests use the most tokens and find opportunities to reduce costs.
Find common failure modes and fix issues before users report them.

Real-Time Monitoring

Live Log Stream

Watch requests in real-time:
Live log stream
  • Instant visibility - see requests as they happen
  • Error highlighting - failed requests are immediately visible
  • Sensitive data alerts - get notified when sensitive patterns are detected

Metrics Dashboard

Metrics dashboard
Track key metrics:
  • Requests per minute/hour/day
  • Token usage over time
  • Error rate trends
  • Latency percentiles
  • Cost accumulation

Alerts and Notifications

Set up alerts for important events:

Available Alert Types

AlertTrigger
Sensitive Data DetectedWhen credentials or PII are found in requests
High Error RateWhen error rate exceeds threshold
Usage SpikeWhen request volume suddenly increases
Budget WarningWhen approaching spending limits
Unusual PatternWhen usage deviates from normal

Configuration

// Set up alerts via API
await leanmcp.gateway.createAlert({
  type: 'sensitive_data_detected',
  channels: ['email', 'slack'],
  config: {
    patterns: ['api_key', 'password', 'secret'],
    severity: 'high',
  }
});

Integration with Your Tools

Windsurf / Cursor Usage

See exactly what your coding assistant sends:
  1. Configure your IDE to use the gateway
  2. Code normally
  3. Check dashboard to see what context was included
Review your logs after coding sessions to understand what data your AI assistant accessed.

Application Requests

For your own applications, add context headers:
const response = await client.chat.completions.create({
  model: 'gpt-5.2',
  messages: messages,
}, {
  headers: {
    'X-Request-Source': 'mobile-app',
    'X-Feature': 'chat-completion',
    'X-User-ID': userId,
  }
});
These headers are logged, making it easy to filter and analyze requests.

Data Retention

PlanRetention
Free7 days
Pro30 days
Enterprise90 days (customizable)
Export data regularly if you need longer retention. All exports are available for download within the retention period.

Next Steps