Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Excurs1ons/MonoRelay/llms.txt

Use this file to discover all available pages before exploring further.

Every request proxied through MonoRelay is written to a local SQLite database with full token counts, latency metrics, and optional request/response body previews. The logs API lets you page through recent requests, retrieve a specific log entry with its full body, stream new entries in real time via SSE, filter by provider or model, and clear the log store when needed.

Authentication

All log endpoints require a valid JWT token:
Authorization: Bearer <jwt>

Endpoints

GET /api/logs

Return a paginated list of recent log entries, newest first. Heavy fields (request_full, response_full) are stripped from the list view; fetch them individually via /api/logs/{id}. Query parameters:
ParameterTypeDefaultDescription
pageinteger1Page number (1-indexed)
page_sizeinteger20Items per page
limitinteger50Maximum total entries to load before pagination
curl "http://localhost:8787/api/logs?page=1&page_size=20" \
  -H "Authorization: Bearer <jwt>"
Response envelope:
{
  "success": true,
  "data": [ /* array of log records */ ],
  "metadata": {
    "page": 1,
    "page_size": 20,
    "total": 143,
    "timestamp": "2026-05-17T10:00:00"
  }
}

GET /api/logs/

Retrieve a single log entry by ID, including the full request and response bodies. Log IDs are integers. Pending (in-flight streaming) requests use negative temporary IDs until finalized.
curl http://localhost:8787/api/logs/42 \
  -H "Authorization: Bearer <jwt>"
Returns 404 if the ID is not found in the database or in the in-memory pending store.

GET /api/logs/stream

An SSE (Server-Sent Events) endpoint that pushes new and updated log entries in real time. The dashboard uses this to display live request activity without polling.
curl -N http://localhost:8787/api/logs/stream \
  -H "Authorization: Bearer <jwt>"
The stream emits two event types:
Event typeWhen emitted
log_newA new request starts (immediately, before completion)
log_updateA pending entry is updated (first token received, stream finalized)
A heartbeat comment (: heartbeat) is sent every 20 seconds to keep the connection alive through proxies. Example SSE output:
event: log_new
data: {"id": -1, "model": "claude-opus-4-5", "provider": "anthropic", "timestamp": 1747468800.0}

event: log_update
data: {"id": -1, "_real_id": 99, "status_code": 200, "latency_ms": 1342.5, "input_tokens": 84, "output_tokens": 210}

GET /api/logs/filtered

Return logs filtered by provider, model, status, or date range. Applies in-memory filtering after loading a larger window of recent entries. Query parameters:
ParameterTypeDescription
providerstringExact provider name match (e.g. anthropic)
modelstringCase-insensitive substring match on model name
statusstring"success" (status < 400) or "error" (status ≥ 400)
date_fromstringISO date string, e.g. 2026-05-01
date_tostringISO date string, e.g. 2026-05-17
limitintegerMax entries to scan (default 100)
pageintegerPage number
page_sizeintegerItems per page (default 20)
curl "http://localhost:8787/api/logs/filtered?provider=anthropic&status=error&date_from=2026-05-01" \
  -H "Authorization: Bearer <jwt>"

POST /api/logs/clear

Delete all log entries from the database and clear any in-memory pending entries.
curl -X POST http://localhost:8787/api/logs/clear \
  -H "Authorization: Bearer <jwt>"
{"success": true, "message": "请求日志已清空"}

Log record fields

Each log entry returned by the API contains these fields:
id
integer
Database row ID. Negative values indicate pending (in-flight) entries not yet written to disk.
timestamp
number
Unix timestamp (float) of when the request was received.
model
string
The resolved model name as used for the upstream request.
provider
string
The provider that handled the request.
key_label
string
Label of the API key used, as configured in providers.<name>.keys[].label.
status_code
integer
HTTP status code returned by the upstream provider (e.g. 200, 429, 500).
latency_ms
number
Total request latency in milliseconds from receipt to final byte.
first_token_ms
number
Time to first token in milliseconds. Populated for streaming requests.
input_tokens
integer
Number of prompt tokens consumed.
output_tokens
integer
Number of completion tokens generated.
estimated_cost
number
Estimated USD cost calculated from configured cost_per_m_input / cost_per_m_output rates.
cache_hit_tokens
integer
Tokens served from the upstream prompt cache (Anthropic cache read).
cache_miss_tokens
integer
Tokens written to the upstream prompt cache (Anthropic cache creation).
streaming
boolean
true if the request used streaming mode.
error_message
string
Error description if the request failed, otherwise null.
error_type
string
Error category string, e.g. "rate_limit_error", "proxy_error".
request_preview
string
Truncated preview of the request body (length controlled by logging.content_preview_length). Stripped from list endpoints; available in detail view.
response_preview
string
Truncated preview of the response content. Updated in real time for streaming requests.
request_full
string
Full JSON request body. Only included in single-entry detail responses (GET /api/logs/{id}).
response_full
string
Full JSON response body. Only included in single-entry detail responses.
client_ip
string
Originating client IP address, resolved from x-real-ip, x-forwarded-for, or the direct connection.
user_agent
string
The User-Agent header sent by the calling client.

Logging configuration reference

Logging is configured in config.yml under the logging key:
FieldTypeDefaultDescription
enabledbooleantrueEnable or disable request logging entirely
db_pathstring./data/requests.dbPath to the SQLite database file
max_age_daysinteger30Automatically delete log entries older than this many days
content_preview_lengthinteger200Maximum characters to store in request/response preview fields
Example:
logging:
  enabled: true
  db_path: ./data/requests.db
  max_age_days: 30
  content_preview_length: 200

Build docs developers (and LLMs) love