Metadata-Version: 2.5
Name: skimp
Version: 0.1.0
Summary: Local, privacy-first CLI profiler for OpenTelemetry and MLflow AI agent traces.
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: agents,cost,llm,mlflow,observability,opentelemetry,tokens
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.11
Requires-Dist: pydantic>=2.6.0
Requires-Dist: rich>=13.7.0
Requires-Dist: typer>=0.12.0
Description-Content-Type: text/markdown

# skimp

**Skimp on tokens, not on quality.**

`skimp` is a local, privacy-first Python CLI that profiles OpenTelemetry (`gen_ai.*`) and MLflow AI agent traces to diagnose **structural token waste** and project monthly dollar burn.

Unlike passive observability dashboards that only show *what* you spent, `skimp` is prescriptive: it flags *why* tokens are being wasted and estimates how much money you can save.

---

## Why `skimp`?

- **100% Privacy-First by Default**: All core detectors run strictly on **span metadata** (token counts, model names, durations, span hierarchy, status codes). Prompt/message payloads (`gen_ai.input.messages`, `gen_ai.output.messages`, `mlflow.spanInputs`, etc.) are stripped at ingest by default.
- **Multi-Dialect Telemetry**: Parses standard OTLP JSON (`resourceSpans`), OTLP NDJSON, `opentelemetry-sdk` flat exports, OpenLLMetry/OpenInference, and MLflow trace JSON exports.
- **4 Prescriptive Waste Detectors**:
  1. **Context Snowballing** — Flags multi-turn `chat` sequences with runaway/quadratic `input_tokens` growth.
  2. **Retry & Tool Thrashing** — Flags repeated `execute_tool` loops and repeated failed (`ERROR`) spans, attributing nested LLM retry costs.
  3. **Model Overkill** — Flags short, low-output-token spans (routing, classification, extraction) running on expensive frontier models.
  4. **Broken Prompt Caching** — Flags repeated large-input spans with zero cached tokens on cache-capable models.
- **Configurable for All Models (Current & Future)**: Override built-in rates or define any future/custom model ID in `skimp.toml`, `[tool.skimp]` in `pyproject.toml`, or `~/.config/skimp/config.toml`.

---

## Installation

Requires Python 3.11+.

```bash
# With uv (recommended)
uv tool install skimp

# Or with pip
pip install skimp
```

For local development:

```bash
git clone https://github.com/rajsinghparihar/skimp.git
cd skimp
uv sync
```

---

## Quickstart

Generate a realistic, noisy sample OTel trace with baked-in structural waste patterns:

```bash
uv run skimp generate-sample --out sample_trace.json
```

Analyze the trace, project monthly spend at 1,000 runs/day, and export a self-contained HTML audit report:

```bash
uv run skimp analyze sample_trace.json --daily-runs 1000 --html report.html
```

---

## Custom Model Pricing (`skimp.toml`)

`skimp` ships with reference per-1M token pricing for OpenAI, Anthropic, Google Gemini, and common open models, and automatically strips provider prefixes (`openai/`, `anthropic/`, `bedrock/`, `models/`) and dated snapshot suffixes (`gpt-4o-2024-11-20`).

To configure custom or future models, add a `skimp.toml` file (or `[tool.skimp]` in `pyproject.toml`):

```toml
daily_runs = 2500

[models."claude-opus-5-preview"]
input_per_1m = 12.00
output_per_1m = 60.00
cached_input_per_1m = 1.20
tier = "frontier"
provider = "anthropic"

[models."my-finetuned-router"]
input_per_1m = 0.15
output_per_1m = 0.45
tier = "mini"
```

Pass an explicit config file at runtime with `--config path/to/skimp.toml`.

---

## Development

```bash
uv run pytest -v
uv run ruff check .
uv build
```

## License

Apache-2.0 — see [LICENSE](LICENSE).
