luxvigil 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. luxvigil-0.1.0/.github/workflows/release.yml +46 -0
  2. luxvigil-0.1.0/.github/workflows/tests.yml +26 -0
  3. luxvigil-0.1.0/.gitignore +17 -0
  4. luxvigil-0.1.0/CHANGELOG.md +29 -0
  5. luxvigil-0.1.0/LICENSE +177 -0
  6. luxvigil-0.1.0/PKG-INFO +241 -0
  7. luxvigil-0.1.0/README.md +215 -0
  8. luxvigil-0.1.0/SECURITY.md +30 -0
  9. luxvigil-0.1.0/benchmarks/README.md +223 -0
  10. luxvigil-0.1.0/benchmarks/fraud_ecommerce.py +167 -0
  11. luxvigil-0.1.0/benchmarks/wildchat.py +196 -0
  12. luxvigil-0.1.0/pyproject.toml +44 -0
  13. luxvigil-0.1.0/scripts/bench.py +45 -0
  14. luxvigil-0.1.0/scripts/update_disposable.py +39 -0
  15. luxvigil-0.1.0/src/luxvigil/__init__.py +3 -0
  16. luxvigil-0.1.0/src/luxvigil/checks/__init__.py +12 -0
  17. luxvigil-0.1.0/src/luxvigil/checks/aliases.py +67 -0
  18. luxvigil-0.1.0/src/luxvigil/checks/emails.py +93 -0
  19. luxvigil-0.1.0/src/luxvigil/checks/farms.py +150 -0
  20. luxvigil-0.1.0/src/luxvigil/checks/groups.py +45 -0
  21. luxvigil-0.1.0/src/luxvigil/checks/keys.py +118 -0
  22. luxvigil-0.1.0/src/luxvigil/checks/prompts.py +119 -0
  23. luxvigil-0.1.0/src/luxvigil/checks/spikes.py +105 -0
  24. luxvigil-0.1.0/src/luxvigil/cli.py +158 -0
  25. luxvigil-0.1.0/src/luxvigil/config.py +131 -0
  26. luxvigil-0.1.0/src/luxvigil/data/__init__.py +1 -0
  27. luxvigil-0.1.0/src/luxvigil/data/disposable_domains.txt +10086 -0
  28. luxvigil-0.1.0/src/luxvigil/export.py +155 -0
  29. luxvigil-0.1.0/src/luxvigil/generate.py +133 -0
  30. luxvigil-0.1.0/src/luxvigil/report.py +297 -0
  31. luxvigil-0.1.0/src/luxvigil/schema.py +272 -0
  32. luxvigil-0.1.0/tests/test_aliases.py +69 -0
  33. luxvigil-0.1.0/tests/test_cli.py +37 -0
  34. luxvigil-0.1.0/tests/test_cli_args.py +32 -0
  35. luxvigil-0.1.0/tests/test_columns.py +105 -0
  36. luxvigil-0.1.0/tests/test_config.py +129 -0
  37. luxvigil-0.1.0/tests/test_emails.py +54 -0
  38. luxvigil-0.1.0/tests/test_export.py +59 -0
  39. luxvigil-0.1.0/tests/test_farms.py +93 -0
  40. luxvigil-0.1.0/tests/test_generate.py +39 -0
  41. luxvigil-0.1.0/tests/test_groups.py +18 -0
  42. luxvigil-0.1.0/tests/test_keys.py +79 -0
  43. luxvigil-0.1.0/tests/test_optional_columns.py +66 -0
  44. luxvigil-0.1.0/tests/test_prompts.py +122 -0
  45. luxvigil-0.1.0/tests/test_render.py +65 -0
  46. luxvigil-0.1.0/tests/test_report.py +116 -0
  47. luxvigil-0.1.0/tests/test_spikes.py +71 -0
  48. luxvigil-0.1.0/tests/test_validation.py +143 -0
@@ -0,0 +1,46 @@
1
+ name: release
2
+
3
+ # Publishes luxvigil to PyPI when you publish a release on GitHub.
4
+ # No tokens or passwords anywhere: PyPI trusts this exact workflow
5
+ # ("trusted publishing"), which is set up once on pypi.org.
6
+
7
+ on:
8
+ release:
9
+ types: [published]
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.13"
21
+ # the release tag (v0.1.0) has to match the version in the code,
22
+ # otherwise we'd publish something different from what the release says
23
+ - name: check the tag matches the version
24
+ run: |
25
+ version=$(python -c "import re; print(re.search(r'__version__ = \"(.+)\"', open('src/luxvigil/__init__.py').read())[1])")
26
+ echo "code says $version, tag says $GITHUB_REF_NAME"
27
+ test "v$version" = "$GITHUB_REF_NAME"
28
+ - run: pip install build
29
+ - run: python -m build
30
+ - uses: actions/upload-artifact@v4
31
+ with:
32
+ name: dist
33
+ path: dist/
34
+
35
+ publish:
36
+ needs: build
37
+ runs-on: ubuntu-latest
38
+ environment: pypi
39
+ permissions:
40
+ id-token: write # this is what lets PyPI check it's really this workflow
41
+ steps:
42
+ - uses: actions/download-artifact@v4
43
+ with:
44
+ name: dist
45
+ path: dist/
46
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,26 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ python: ["3.11", "3.12", "3.13", "3.14", "3.15"]
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python }}
23
+ - run: pip install -e ".[dev]"
24
+ - run: pytest -q
25
+ # make sure the scan command actually runs end to end, not just the tests
26
+ - run: luxvigil demo
@@ -0,0 +1,17 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ venv/
5
+ dist/
6
+ build/
7
+ *.egg-info/
8
+ .pytest_cache/
9
+
10
+ # never commit real logs
11
+ *.log
12
+ /data/
13
+ examples/*.csv
14
+ !examples/sample*.csv
15
+
16
+ # benchmark datasets, download them yourself (see benchmarks/README)
17
+ benchmarks/data/
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ First release.
6
+
7
+ Checks:
8
+
9
+ - **account farms**: accounts linked by a shared device, or by a shared network when they also have another red flag
10
+ - **disposable emails**: a bundled list of ~10k throwaway domains, works offline
11
+ - **shared or leaked keys**: one key used from many countries in a short window
12
+ - **copy-paste bots**: accounts sending the same prompts over and over. Phrases everyone types ("more", "continue") are left out, see benchmarks/
13
+ - **Gmail aliases**: several accounts on the same Gmail inbox
14
+ - **spend spikes**: an account suddenly spending 10x its usual, grouped per account
15
+
16
+ Report:
17
+
18
+ - two totals kept apart: likely abuse and worth a look, every request counted once
19
+ - `--json` with stable ids, evidence, an innocent explanation and a next step for every finding
20
+ - says which checks it had to skip and why when your logs don't have the data for them
21
+
22
+ Reading your logs:
23
+
24
+ - only time, account and tokens are required, everything else is optional
25
+ - column aliases and `--map` for logs that name things differently, cost from tokens with `--price-in`/`--price-out`
26
+ - Excel exports (BOM, `;` separators), bad rows stop the scan or get skipped with `--skip-bad-rows`
27
+ - `luxvigil.toml` for trusted networks and devices and ignored accounts
28
+
29
+ Tested on real data: Amazon's fraud ecommerce benchmark and ~5M real messages from WildChat, see benchmarks/.
luxvigil-0.1.0/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,241 @@
1
+ Metadata-Version: 2.5
2
+ Name: luxvigil
3
+ Version: 0.1.0
4
+ Summary: Abuse forensics for AI APIs: find account farms, leaked keys and bots hiding in your request logs.
5
+ Project-URL: Homepage, https://github.com/polfananas/luxvigil
6
+ Project-URL: Issues, https://github.com/polfananas/luxvigil/issues
7
+ Project-URL: Changelog, https://github.com/polfananas/luxvigil/blob/main/CHANGELOG.md
8
+ Project-URL: Benchmarks, https://github.com/polfananas/luxvigil/tree/main/benchmarks
9
+ Author: polfananas
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: abuse,api,forensics,fraud,free tier,llm,security
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Information Technology
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Topic :: Security
21
+ Classifier: Topic :: System :: Logging
22
+ Requires-Python: >=3.11
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest; extra == 'dev'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # luxvigil 🕯️
28
+
29
+ [![tests](https://github.com/polfananas/luxvigil/actions/workflows/tests.yml/badge.svg)](https://github.com/polfananas/luxvigil/actions/workflows/tests.yml)
30
+
31
+ **Abuse forensics for AI APIs.** Your free tier is part of your attack surface.
32
+
33
+ > *Nihil occultum quod non manifestetur.* Nothing stays hidden forever (Luke 8:17).
34
+
35
+ luxvigil reads the request logs of your AI API (or any app that gives away tokens or credits) and shows you the abuse hiding in them: account farms, throwaway emails, shared or leaked keys, bots sending the same prompts over and over… and roughly how much it cost you.
36
+
37
+ > ⚠️ Early days. All the checks and the terminal report work. I'm building it in the open step by step, so star or watch if you want to follow along.
38
+
39
+ ## Try it
40
+
41
+ ```
42
+ pipx run luxvigil demo # no install: makes fake logs with abuse in them and scans them
43
+ pip install luxvigil # then: luxvigil scan your-logs.csv
44
+ ```
45
+
46
+ Python 3.11+, no dependencies, nothing leaves your machine.
47
+
48
+ ## Why
49
+
50
+ If you run an AI product with a free tier, you're probably feeding someone who signed up 300 times with fake emails. Each account looks normal on its own, so per-user rate limits don't catch it. All you see is the inference bill going up and conversion going down.
51
+
52
+ And it's not just a billing problem. Free credits and leaked keys are how a lot of people get anonymous, untraceable access to LLMs: to resell it, to run spam or scam campaigns, or to hammer models with jailbreak attempts without risking their own account. On the attacker side, "free inference" is a resource like any other, and your free tier is part of the attack surface.
53
+
54
+ luxvigil looks **across** accounts to find the patterns that only show up when you put them side by side.
55
+
56
+ ## What it does
57
+
58
+ You give it a CSV export of your request logs, it gives you a report. Want to see it before digging out your logs? `luxvigil demo` makes a month of fake logs with two farms, a leaked key and a spend spike planted in them, and scans them:
59
+
60
+ ```
61
+ $ luxvigil demo
62
+
63
+ 🕯️ luxvigil · 2026-10-01 to 2026-10-30
64
+
65
+ 11,405 requests · 285 accounts · $324.60 spent
66
+ 💰 ~$195.25 is likely abuse (60% of your spend), 86 accounts
67
+ 🔎 ~$22.76 more is worth a look, 1 account (signals that can have an innocent explanation)
68
+
69
+ 🚨 2 account farms, 85 accounts
70
+ - 60 accounts on 3 shared devices + 1 shared network (185.220.101.0/24, with throwaway emails or template prompts) · 3,368 requests · ~$144.89
71
+ - 25 accounts on 1 shared device · 968 requests · ~$32.39
72
+ 📧 60 of 285 accounts (21%) use throwaway emails: mailinator.com (16), sharklasers.com (12), 10minutemail.com (12)
73
+ 3,368 requests · ~$144.89
74
+ 🔑 1 key probably shared or leaked
75
+ - key key_eb500b7a7780b4c2: 13 countries in a single day, 401 IPs, home is GB · 400 requests from abroad · ~$17.97
76
+ 🤖 1 copy-paste bot, 60 accounts
77
+ - 60 accounts sending the same 5 prompts over and over (3,368 times) · 3,368 requests · ~$144.89
78
+ ✅ no shared Gmail inboxes
79
+ 💸 2 spend spikes (could be a launch or a batch job, check first)
80
+ - acc_0100 went from ~$0.02/day to $7.99/day (368x) on 2026-10-28 to 2026-10-30 · 302 requests · ~$22.76 extra
81
+ - acc_0007 went from ~$0.02/day to $6.26/day (266x) on 2026-10-23 to 2026-10-25 · 402 requests · ~$17.93 extra
82
+
83
+ The same account can show up in more than one check. The totals at the top count it once.
84
+ ```
85
+
86
+ The checks:
87
+
88
+ - **Account farms**: lots of accounts on the same device, or on the same network when they also use throwaway emails or template prompts (a shared network alone proves nothing: think mobile carriers and universities)
89
+ - **Disposable emails**: signups from mailinator & friends
90
+ - **Shared / leaked keys**: one key used from many countries in a short window (often a sign it's been stolen and resold)
91
+ - **Copy-paste bots**: different accounts sending the same prompts or templates
92
+ - **Gmail aliases**: three or more accounts on the same Gmail inbox (`you+1@gmail.com`, `y.o.u@gmail.com`…), the classic way to get lots of free trials with one inbox
93
+ - **Spend spikes**: a user suddenly burning 10x their usual
94
+
95
+ Every flag tells you *why* it fired. No black box.
96
+
97
+ The report keeps two totals apart. **Likely abuse** is what comes from strong signals: farms, copy-paste bots, shared Gmail inboxes and keys used from all over the world. **Worth a look** is for weak signals that often have an innocent explanation, like a throwaway email on its own (someone testing) or a spend spike (a launch, a batch job). An account that trips both just counts as likely abuse, and nothing is counted twice.
98
+
99
+ ## What it won't do
100
+
101
+ - It doesn't block anything. It only looks at what already happened.
102
+ - It doesn't run in real time or sit in your request path.
103
+ - It never sends your logs anywhere. Everything runs on your machine, which matters since prompt logs are usually some of the most sensitive data you have.
104
+
105
+ ## Log format
106
+
107
+ One row per API request, as a CSV. Only when, who and how many tokens are a
108
+ must, everything else is optional. Give it what you have: if a column is
109
+ missing, the checks that need it are skipped and the report says so
110
+ (`⏭️ disposable emails: skipped, no emails in the logs`) instead of telling you
111
+ everything's fine.
112
+
113
+ | column | what it is | needed for |
114
+ |---|---|---|
115
+ | `timestamp` | when it happened, ISO 8601 (`2026-10-01T14:03:22Z`) or a unix timestamp | **required** |
116
+ | `account_id` | your id for the account | **required** |
117
+ | `input_tokens` / `output_tokens` | tokens in and out | **required** |
118
+ | `cost_usd` | what the request cost you (or pass prices, see below) | spend, spikes |
119
+ | `email` | email the account signed up with | throwaway emails, Gmail aliases |
120
+ | `api_key_id` | id or hash of the key used, **never the key itself** | shared / leaked keys |
121
+ | `ip` / `country` | client IP and its 2-letter country | farms (IP), shared keys (country) |
122
+ | `device_id` | device / browser fingerprint | farms |
123
+ | `prompt_hash` | hash of the prompt, so repeated prompts show up without storing them | copy-paste bots |
124
+ | `prompt_chars` | length of the prompt in characters | lets the bot check ignore "more", "continue"... |
125
+
126
+ ### Your columns are called something else?
127
+
128
+ luxvigil already understands the usual suspects (`user_id`, `user_email`, `created_at`, `prompt_tokens`, `completion_tokens`, `client_ip`…) and tells you when it uses one. For anything else, point it at your column with `--map`:
129
+
130
+ ```
131
+ $ luxvigil scan logs.csv --map account_id=customer --map email=signup_email
132
+ ```
133
+
134
+ No cost column? Give it your prices per 1M tokens and it works it out:
135
+
136
+ ```
137
+ $ luxvigil scan logs.csv --price-in 3 --price-out 15
138
+ ```
139
+
140
+ It will never pick up a column called `api_key`, since in some exports that's the raw key. Hash it first and map the hash with `--map api_key_id=...`.
141
+
142
+ ### JSON
143
+
144
+ Want to feed it into something else? `--json` prints the same report as data. Every finding has a stable id (same logs, same ids), how strong it is, the evidence behind it, what could explain it innocently and what to check next:
145
+
146
+ ```json
147
+ {
148
+ "id": "shared_key-c09f5a151c",
149
+ "check": "shared_key",
150
+ "severity": "likely",
151
+ "summary": "key key_eb500b7a7780b4c2: 13 countries in a single day, 401 IPs, home is GB",
152
+ "accounts": ["acc_0007"],
153
+ "requests": 400,
154
+ "cost_usd": 17.9693,
155
+ "evidence": {"key": "key_eb500b7a7780b4c2", "home_country": "GB", "peak_countries_in_a_day": 13, "...": "..."},
156
+ "innocent_explanation": "a customer running the same key from servers in several regions",
157
+ "next_step": "ask the key owner if they use it from these countries, if not rotate it"
158
+ }
159
+ ```
160
+
161
+ No raw emails or prompts end up in it, only the ids and hashes already in your logs.
162
+
163
+ ### Bad rows
164
+
165
+ luxvigil stops at the first row it can't trust (a cost of `nan` or `-5`, negative tokens, an empty account id…) and tells you which line, rather than quietly getting the totals wrong. If your export has a few broken rows and you just want the rest, add `--skip-bad-rows` and it'll tell you how many it skipped. It also warns you about duplicated rows and rows without a valid IP.
166
+
167
+ ### Telling it what's normal for you
168
+
169
+ Your office, your VPN or a big customer behind one network will look like a farm, since lots of accounts share an IP range. Drop a `luxvigil.toml` next to your logs (or pass `--config`):
170
+
171
+ ```toml
172
+ [trusted]
173
+ networks = ["203.0.113.0/24"] # office, VPN exit, a customer's office...
174
+ devices = ["kiosk-01"]
175
+
176
+ [ignore]
177
+ accounts = ["qa_*"]
178
+ emails = ["*@yourcompany.com"]
179
+ keys = ["key_ci_*"]
180
+ ```
181
+
182
+ Trusted networks and devices are still checked, they just never link accounts into a farm. Ignored accounts are skipped completely, but still count towards your total spend.
183
+
184
+ No logs handy? `luxvigil demo` scans fake ones for you, or make your own to play with:
185
+
186
+ ```
187
+ $ luxvigil generate --out sample-logs.csv
188
+ ```
189
+
190
+ ## How fast is it?
191
+
192
+ On fake logs, on a small 2-core cloud box with Python 3.13 (`python scripts/bench.py 10000 100000 1000000`):
193
+
194
+ | requests | time | peak memory |
195
+ |---:|---:|---:|
196
+ | 10k | 0.1s | ~30 MB |
197
+ | 100k | 1.2s | ~90 MB |
198
+ | 1M | 18s | ~740 MB |
199
+
200
+ About half of that is just reading the CSV. Everything is loaded into memory, so tens of millions of rows will need a big machine or splitting the file by month. Run the script on your own machine to get your numbers.
201
+
202
+ ## Does it work on real fraud?
203
+
204
+ There's no public dataset of AI API abuse with labels, so we tested the farm check on the closest thing: Amazon's "Fraud ecommerce" benchmark (~150k signups with a fraud label). The fraud there comes in a burst of farms in one month, and luxvigil catches it: **9 out of 10 accounts it flags are real fraud**, with no ML and no tuning. On Amazon's own test set, which has hardly any farms, it flags almost nothing and its device signal scores about the same as their best model.
205
+
206
+ Only the farm check is tested there, and it's e-commerce, not AI API logs. Full numbers, caveats and how to run it in [benchmarks/](https://github.com/polfananas/luxvigil/tree/main/benchmarks).
207
+
208
+ We also ran it on [WildChat](https://huggingface.co/datasets/allenai/WildChat-1M), ~2M real messages to a free GPT chatbot (27s to scan). It found people using the free chat as an API (a print-on-demand shop, agent loops, data generation scripts), and it showed the copy-paste bot check over-flags follow-ups like "more" or "continue" in chat logs. With the optional `prompt_chars` column that mostly goes away (34% of the spend flagged went down to 5% on WildChat-1M), checked on 3.4M newer chats we never tuned on. Details in [benchmarks/](https://github.com/polfananas/luxvigil/tree/main/benchmarks).
209
+
210
+ ## Status
211
+
212
+ - [x] Name & scope
213
+ - [x] Log format + fake log generator (for demos and tests)
214
+ - [x] Account farms
215
+ - [x] Disposable emails
216
+ - [x] Shared / leaked keys
217
+ - [x] Copy-paste bots
218
+ - [x] Gmail aliases
219
+ - [x] Spend spikes
220
+ - [x] Terminal report (with a total that counts each account once)
221
+ - [x] JSON output
222
+ - [x] Farm check tested on real labeled fraud
223
+ - [ ] HTML report (v0.2)
224
+ - [ ] Read LiteLLM / Helicone / gateway exports directly (v0.3)
225
+
226
+ ## Why "luxvigil"?
227
+
228
+ *Lux* = light, *vigil* = keeping watch through the night. It keeps an eye on what happened while you weren't looking.
229
+
230
+ ## License
231
+
232
+ [Apache-2.0](https://github.com/polfananas/luxvigil/blob/main/LICENSE). Use it, change it, ship it, just keep the notice.
233
+
234
+ The list of throwaway email domains bundled with luxvigil comes from
235
+ [disposable-email-domains](https://github.com/disposable-email-domains/disposable-email-domains),
236
+ which is public domain (CC0).
237
+
238
+ ---
239
+
240
+ Built by [@polfananas](https://github.com/polfananas)
241
+