Skip to main content

No project description provided

Project description

🧠 OpenRouter Observer

OpenRouter Observer is a CLI utility that monitors and analyzes LLM requests from structured logs — built for teams using OpenRouter and logging structured JSON per request.

It provides a streamlined way to:

  • 📄 Tail logs live
  • 📊 Aggregate stats (successes, failures, model breakdown)
  • 📤 Export parsed entries to JSONL
  • 🔍 Run dry-run parsing validations

📦 Installation

Requires Python 3.10+ and Poetry:

git clone https://github.com/rajesh1804/openrouter_observer.git
cd openrouter_observer
poetry install

⚙️ Configuration

Edit config/default.yaml to configure paths and behavior:

app:
  name: "OpenRouter Observer"
  mode: "dev"
  log_path: "logs/sample.log"
  export_path: "exports/observer_output.jsonl"
  poll_interval: 1.0

🚀 Usage

Run all CLI commands via:

poetry run python -m openrouter_observer.main [OPTIONS]

✅ Available Commands

Command Description
--hello Print a welcome message
--run Run the main observer (WIP)
--tail Tail the log file in real time
--report Ingest full log and print aggregated stats
--export Export valid log entries to JSONL
--head N Show the last N log entries
--dry-run Parse and count valid/invalid lines, without output

🔁 Log Format (Input)

The observer expects each log line to be a valid JSON object like:

{
  "model": "mistralai/mistral-7b-instruct",
  "prompt": "Write a story about...",
  "latency": 1.24,
  "status": "success"
}

📂 Project Structure

openrouter_observer/
├── config/             # YAML config files
├── exports/            # Exported JSONL logs
├── logs/               # Source log files
├── src/                # Main source code
├── tests/              # Pytest-based test suite

🧪 Example

poetry run python -m openrouter_observer.main --report

Outputs:

📊 Ingest Summary from sample.log
-------------------------------
🔢 Total Requests     : 42
✅ Successes          : 40
❌ Failures           : 2
🤖 Models Used        : 3
✍️ Longest Prompt     : 123 characters
→ Tell me a story about the ocean and...

📈 Model Breakdown:
- gpt-4: 20 reqs | ⏱️ Avg Latency: 2.34s
- mistral: 15 reqs | ⏱️ Avg Latency: 1.12s
...

🛠️ Limitations

  • Only works with structured JSON logs (one per line)
  • No real-time alerts or metrics yet
  • No web UI or dashboard (yet)

📌 Road to v0.1.x

The following are out of scope for v0.0.1 but coming soon:

  • Rich TUI mode
  • Filtering/sorting by model or latency
  • Exporting to CSV or SQLite
  • Alerts or anomaly detection
  • Plugins for non-OpenRouter logs

🏁 Version

This is v0.0.1. Ready for internal use and light testing.


📄 License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openrouter_observer-0.0.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openrouter_observer-0.0.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file openrouter_observer-0.0.1.tar.gz.

File metadata

  • Download URL: openrouter_observer-0.0.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.11 Windows/10

File hashes

Hashes for openrouter_observer-0.0.1.tar.gz
Algorithm Hash digest
SHA256 db0bf84168357a52b5098b3b21b36153f187d266e39fdd4faf7e0a8b602f3d50
MD5 54cad0162d329b05e73207d93e746a27
BLAKE2b-256 8fede29ac24ff3c83427bff9b078c16bc5e3503cba9d553ba8b33023dfff0e28

See more details on using hashes here.

File details

Details for the file openrouter_observer-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for openrouter_observer-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb81f4ada957d0df14b5b2393fb3f43f25f1dbcb8bb2cf87f00409dad46696da
MD5 f89d6dc67684a0fe2a35f8112727380c
BLAKE2b-256 1424428a9103624e1a78c516a57e8e7b7e29e51fbd4c778da8d4a2d9e3f87b1d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page