linklbee-scan 1.4.4__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.
- linklbee_scan-1.4.4/LICENSE +21 -0
- linklbee_scan-1.4.4/PKG-INFO +121 -0
- linklbee_scan-1.4.4/README.md +98 -0
- linklbee_scan-1.4.4/linklbee_scan.egg-info/PKG-INFO +121 -0
- linklbee_scan-1.4.4/linklbee_scan.egg-info/SOURCES.txt +9 -0
- linklbee_scan-1.4.4/linklbee_scan.egg-info/dependency_links.txt +1 -0
- linklbee_scan-1.4.4/linklbee_scan.egg-info/entry_points.txt +2 -0
- linklbee_scan-1.4.4/linklbee_scan.egg-info/top_level.txt +1 -0
- linklbee_scan-1.4.4/linklbee_scan.py +210527 -0
- linklbee_scan-1.4.4/pyproject.toml +39 -0
- linklbee_scan-1.4.4/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NOTEGG
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: linklbee-scan
|
|
3
|
+
Version: 1.4.4
|
|
4
|
+
Summary: Find where your LLM API bill leaks. One file, standard library only, zero network calls.
|
|
5
|
+
Author-email: "NOTEGG Corp." <bee@linklbee.com>
|
|
6
|
+
Maintainer-email: Chungnyung Kang <bee@linklbee.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://linklbee.com
|
|
9
|
+
Project-URL: Repository, https://github.com/linklbee/scan
|
|
10
|
+
Keywords: llm,openai,anthropic,cost-optimization,token,finops,prompt-caching,observability
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Classifier: Topic :: System :: Monitoring
|
|
17
|
+
Classifier: Environment :: Console
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
[한국어 → README.ko.md](https://github.com/linklbee/scan/blob/main/README.ko.md)
|
|
25
|
+
|
|
26
|
+
# Linklbee scanner
|
|
27
|
+
|
|
28
|
+
**Find where your LLM API bill leaks.** The scanner reads your LLM call log on your own machine and writes a one-page report of where token spend goes: prompts too short for the vendor's cache, the cache hit rate, prefixes repeated across calls, identical calls resent seconds apart, and failed or cut-off calls that were still billed. If your service writes new versions of the same documents, it also shows how much output could be saved by rewriting only the parts that changed.
|
|
29
|
+
|
|
30
|
+
If the log lacks a field an item needs, the report does not guess. It names the field that would show the item. Every number comes from the log you give it.
|
|
31
|
+
|
|
32
|
+
## Install and run
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
pip install linklbee-scan
|
|
36
|
+
linklbee-scan <log file or folder> --lang en --out report.html
|
|
37
|
+
linklbee-scan --demo --lang en # see a report on a [synthetic] example log first
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Python 3.9+, no dependencies. Reports are in Korean by default; `--lang en` gives English. Run it with no arguments and it looks in the current folder for something to read.
|
|
41
|
+
|
|
42
|
+
Without pip, the whole tool is one file: download `linklbee_scan.py` and run `python3 linklbee_scan.py` with the same arguments.
|
|
43
|
+
|
|
44
|
+
Not sure how your log will be read? `--peek` reads the first 200 records, prints which field comes from where, and writes nothing:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
linklbee-scan calls.jsonl --peek --lang en
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Log formats it reads
|
|
51
|
+
|
|
52
|
+
No conversion needed. JSONL, JSON arrays, CSV/TSV, `.log` and `.gz` files are read as they are; a folder is read file by file.
|
|
53
|
+
|
|
54
|
+
| Format | |
|
|
55
|
+
|---|---|
|
|
56
|
+
| OpenAI · Anthropic | raw SDK responses (Chat Completions · Responses · Messages · Batch) |
|
|
57
|
+
| CSV · TSV · JSON array | header row = field names / one element = one call |
|
|
58
|
+
| Langfuse | observation export |
|
|
59
|
+
| LangSmith | run export |
|
|
60
|
+
| Helicone | request record |
|
|
61
|
+
| LiteLLM | spend log |
|
|
62
|
+
| Amazon Bedrock | model invocation log · Converse response |
|
|
63
|
+
| Google Vertex AI · Gemini API | raw responses |
|
|
64
|
+
| Azure OpenAI | Chat Completions log |
|
|
65
|
+
|
|
66
|
+
Any other shape: map fields in one line, no script — `--map ts=created output=data.body.text output_tokens=meta.usage.out`.
|
|
67
|
+
|
|
68
|
+
No call log, only the vendor's usage or cost file? Pass it as downloaded. It reads the OpenAI Usage and Costs APIs, OpenAI console usage and cost CSVs, the Anthropic usage report (Admin API), the Anthropic console cost CSV, the AWS Cost and Usage Report, Azure cost details, Fireworks usage and the Together cost CSV. You get spend by model, input vs output, cache reads and busy hours.
|
|
69
|
+
|
|
70
|
+
A developer using Claude Code can try it on this machine's own records: `linklbee-scan --claude-code --lang en`.
|
|
71
|
+
|
|
72
|
+
## What the report finds
|
|
73
|
+
|
|
74
|
+
- Output's share of the bill — from `model` and token counts alone
|
|
75
|
+
- How much of the output could be saved by editing the previous answer instead of writing it again
|
|
76
|
+
- Calls that could be answered without a model call
|
|
77
|
+
- Failed calls that were billed
|
|
78
|
+
- Identical calls resent within seconds
|
|
79
|
+
- Answers cut off at the length limit
|
|
80
|
+
- Tool definitions and system text serialized inconsistently, which breaks the prompt cache
|
|
81
|
+
- Prompts under the vendor's cache minimum
|
|
82
|
+
- A billing check: billed output tokens against the answer text's own token count
|
|
83
|
+
- Cache hit rate
|
|
84
|
+
- Prefixes shared across calls that could be cached
|
|
85
|
+
- Calls that could use OpenAI Flex
|
|
86
|
+
|
|
87
|
+
Each item is reported as found, none, or needs more data — with the field that would show it.
|
|
88
|
+
|
|
89
|
+
## No log file yet?
|
|
90
|
+
|
|
91
|
+
Add these lines right after each call (OpenAI SDK; for Anthropic use `resp.content[0].text`, `u.input_tokens`, `u.output_tokens`). Once calls build up, run the scanner on `calls.jsonl`.
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
import json, time
|
|
95
|
+
def log_call(resp, path="calls.jsonl"): # resp = what client.chat.completions.create(...) returned
|
|
96
|
+
u = resp.usage
|
|
97
|
+
with open(path, "a", encoding="utf-8") as f:
|
|
98
|
+
f.write(json.dumps({"ts": time.time(), "output": resp.choices[0].message.content, "model": resp.model, "input_tokens": u.prompt_tokens, "output_tokens": u.completion_tokens}, ensure_ascii=False) + "\n")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
TypeScript (Node, OpenAI SDK):
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { appendFileSync } from "node:fs";
|
|
105
|
+
export function logCall(resp: any, path = "calls.jsonl") { // resp = await client.chat.completions.create(...)
|
|
106
|
+
const u = resp.usage ?? {};
|
|
107
|
+
appendFileSync(path, JSON.stringify({ ts: Date.now() / 1000, output: resp.choices[0].message.content, model: resp.model, input_tokens: u.prompt_tokens, output_tokens: u.completion_tokens }) + "\n");
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Privacy
|
|
112
|
+
|
|
113
|
+
- **No network code.** No AI calls, no telemetry. Check it: `grep -cE "ht[t]p|sock[e]t|url[l]ib" linklbee_scan.py` prints `0`.
|
|
114
|
+
- **Standard library only.** One file, nothing else to install or trust.
|
|
115
|
+
- **Your log never leaves your machine.** Answer text is read in memory only; the report holds counts, shares and dollars — no prompts, no answers, no document keys.
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
MIT (`LICENSE`), published by NOTEGG Corp. Copyright (c) 2026 NOTEGG. The embedded o200k token table is under tiktoken's MIT license (`THIRD_PARTY_NOTICES`).
|
|
120
|
+
|
|
121
|
+
Full documentation — every field, `--flat`, `--hashify`, how to read the report, and its limits — is in [README.ko.md](https://github.com/linklbee/scan/blob/main/README.ko.md) (Korean, with the full English reference at the end under "English").
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
[한국어 → README.ko.md](https://github.com/linklbee/scan/blob/main/README.ko.md)
|
|
2
|
+
|
|
3
|
+
# Linklbee scanner
|
|
4
|
+
|
|
5
|
+
**Find where your LLM API bill leaks.** The scanner reads your LLM call log on your own machine and writes a one-page report of where token spend goes: prompts too short for the vendor's cache, the cache hit rate, prefixes repeated across calls, identical calls resent seconds apart, and failed or cut-off calls that were still billed. If your service writes new versions of the same documents, it also shows how much output could be saved by rewriting only the parts that changed.
|
|
6
|
+
|
|
7
|
+
If the log lacks a field an item needs, the report does not guess. It names the field that would show the item. Every number comes from the log you give it.
|
|
8
|
+
|
|
9
|
+
## Install and run
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
pip install linklbee-scan
|
|
13
|
+
linklbee-scan <log file or folder> --lang en --out report.html
|
|
14
|
+
linklbee-scan --demo --lang en # see a report on a [synthetic] example log first
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Python 3.9+, no dependencies. Reports are in Korean by default; `--lang en` gives English. Run it with no arguments and it looks in the current folder for something to read.
|
|
18
|
+
|
|
19
|
+
Without pip, the whole tool is one file: download `linklbee_scan.py` and run `python3 linklbee_scan.py` with the same arguments.
|
|
20
|
+
|
|
21
|
+
Not sure how your log will be read? `--peek` reads the first 200 records, prints which field comes from where, and writes nothing:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
linklbee-scan calls.jsonl --peek --lang en
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Log formats it reads
|
|
28
|
+
|
|
29
|
+
No conversion needed. JSONL, JSON arrays, CSV/TSV, `.log` and `.gz` files are read as they are; a folder is read file by file.
|
|
30
|
+
|
|
31
|
+
| Format | |
|
|
32
|
+
|---|---|
|
|
33
|
+
| OpenAI · Anthropic | raw SDK responses (Chat Completions · Responses · Messages · Batch) |
|
|
34
|
+
| CSV · TSV · JSON array | header row = field names / one element = one call |
|
|
35
|
+
| Langfuse | observation export |
|
|
36
|
+
| LangSmith | run export |
|
|
37
|
+
| Helicone | request record |
|
|
38
|
+
| LiteLLM | spend log |
|
|
39
|
+
| Amazon Bedrock | model invocation log · Converse response |
|
|
40
|
+
| Google Vertex AI · Gemini API | raw responses |
|
|
41
|
+
| Azure OpenAI | Chat Completions log |
|
|
42
|
+
|
|
43
|
+
Any other shape: map fields in one line, no script — `--map ts=created output=data.body.text output_tokens=meta.usage.out`.
|
|
44
|
+
|
|
45
|
+
No call log, only the vendor's usage or cost file? Pass it as downloaded. It reads the OpenAI Usage and Costs APIs, OpenAI console usage and cost CSVs, the Anthropic usage report (Admin API), the Anthropic console cost CSV, the AWS Cost and Usage Report, Azure cost details, Fireworks usage and the Together cost CSV. You get spend by model, input vs output, cache reads and busy hours.
|
|
46
|
+
|
|
47
|
+
A developer using Claude Code can try it on this machine's own records: `linklbee-scan --claude-code --lang en`.
|
|
48
|
+
|
|
49
|
+
## What the report finds
|
|
50
|
+
|
|
51
|
+
- Output's share of the bill — from `model` and token counts alone
|
|
52
|
+
- How much of the output could be saved by editing the previous answer instead of writing it again
|
|
53
|
+
- Calls that could be answered without a model call
|
|
54
|
+
- Failed calls that were billed
|
|
55
|
+
- Identical calls resent within seconds
|
|
56
|
+
- Answers cut off at the length limit
|
|
57
|
+
- Tool definitions and system text serialized inconsistently, which breaks the prompt cache
|
|
58
|
+
- Prompts under the vendor's cache minimum
|
|
59
|
+
- A billing check: billed output tokens against the answer text's own token count
|
|
60
|
+
- Cache hit rate
|
|
61
|
+
- Prefixes shared across calls that could be cached
|
|
62
|
+
- Calls that could use OpenAI Flex
|
|
63
|
+
|
|
64
|
+
Each item is reported as found, none, or needs more data — with the field that would show it.
|
|
65
|
+
|
|
66
|
+
## No log file yet?
|
|
67
|
+
|
|
68
|
+
Add these lines right after each call (OpenAI SDK; for Anthropic use `resp.content[0].text`, `u.input_tokens`, `u.output_tokens`). Once calls build up, run the scanner on `calls.jsonl`.
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
import json, time
|
|
72
|
+
def log_call(resp, path="calls.jsonl"): # resp = what client.chat.completions.create(...) returned
|
|
73
|
+
u = resp.usage
|
|
74
|
+
with open(path, "a", encoding="utf-8") as f:
|
|
75
|
+
f.write(json.dumps({"ts": time.time(), "output": resp.choices[0].message.content, "model": resp.model, "input_tokens": u.prompt_tokens, "output_tokens": u.completion_tokens}, ensure_ascii=False) + "\n")
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
TypeScript (Node, OpenAI SDK):
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { appendFileSync } from "node:fs";
|
|
82
|
+
export function logCall(resp: any, path = "calls.jsonl") { // resp = await client.chat.completions.create(...)
|
|
83
|
+
const u = resp.usage ?? {};
|
|
84
|
+
appendFileSync(path, JSON.stringify({ ts: Date.now() / 1000, output: resp.choices[0].message.content, model: resp.model, input_tokens: u.prompt_tokens, output_tokens: u.completion_tokens }) + "\n");
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Privacy
|
|
89
|
+
|
|
90
|
+
- **No network code.** No AI calls, no telemetry. Check it: `grep -cE "ht[t]p|sock[e]t|url[l]ib" linklbee_scan.py` prints `0`.
|
|
91
|
+
- **Standard library only.** One file, nothing else to install or trust.
|
|
92
|
+
- **Your log never leaves your machine.** Answer text is read in memory only; the report holds counts, shares and dollars — no prompts, no answers, no document keys.
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
MIT (`LICENSE`), published by NOTEGG Corp. Copyright (c) 2026 NOTEGG. The embedded o200k token table is under tiktoken's MIT license (`THIRD_PARTY_NOTICES`).
|
|
97
|
+
|
|
98
|
+
Full documentation — every field, `--flat`, `--hashify`, how to read the report, and its limits — is in [README.ko.md](https://github.com/linklbee/scan/blob/main/README.ko.md) (Korean, with the full English reference at the end under "English").
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: linklbee-scan
|
|
3
|
+
Version: 1.4.4
|
|
4
|
+
Summary: Find where your LLM API bill leaks. One file, standard library only, zero network calls.
|
|
5
|
+
Author-email: "NOTEGG Corp." <bee@linklbee.com>
|
|
6
|
+
Maintainer-email: Chungnyung Kang <bee@linklbee.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://linklbee.com
|
|
9
|
+
Project-URL: Repository, https://github.com/linklbee/scan
|
|
10
|
+
Keywords: llm,openai,anthropic,cost-optimization,token,finops,prompt-caching,observability
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Classifier: Topic :: System :: Monitoring
|
|
17
|
+
Classifier: Environment :: Console
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
[한국어 → README.ko.md](https://github.com/linklbee/scan/blob/main/README.ko.md)
|
|
25
|
+
|
|
26
|
+
# Linklbee scanner
|
|
27
|
+
|
|
28
|
+
**Find where your LLM API bill leaks.** The scanner reads your LLM call log on your own machine and writes a one-page report of where token spend goes: prompts too short for the vendor's cache, the cache hit rate, prefixes repeated across calls, identical calls resent seconds apart, and failed or cut-off calls that were still billed. If your service writes new versions of the same documents, it also shows how much output could be saved by rewriting only the parts that changed.
|
|
29
|
+
|
|
30
|
+
If the log lacks a field an item needs, the report does not guess. It names the field that would show the item. Every number comes from the log you give it.
|
|
31
|
+
|
|
32
|
+
## Install and run
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
pip install linklbee-scan
|
|
36
|
+
linklbee-scan <log file or folder> --lang en --out report.html
|
|
37
|
+
linklbee-scan --demo --lang en # see a report on a [synthetic] example log first
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Python 3.9+, no dependencies. Reports are in Korean by default; `--lang en` gives English. Run it with no arguments and it looks in the current folder for something to read.
|
|
41
|
+
|
|
42
|
+
Without pip, the whole tool is one file: download `linklbee_scan.py` and run `python3 linklbee_scan.py` with the same arguments.
|
|
43
|
+
|
|
44
|
+
Not sure how your log will be read? `--peek` reads the first 200 records, prints which field comes from where, and writes nothing:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
linklbee-scan calls.jsonl --peek --lang en
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Log formats it reads
|
|
51
|
+
|
|
52
|
+
No conversion needed. JSONL, JSON arrays, CSV/TSV, `.log` and `.gz` files are read as they are; a folder is read file by file.
|
|
53
|
+
|
|
54
|
+
| Format | |
|
|
55
|
+
|---|---|
|
|
56
|
+
| OpenAI · Anthropic | raw SDK responses (Chat Completions · Responses · Messages · Batch) |
|
|
57
|
+
| CSV · TSV · JSON array | header row = field names / one element = one call |
|
|
58
|
+
| Langfuse | observation export |
|
|
59
|
+
| LangSmith | run export |
|
|
60
|
+
| Helicone | request record |
|
|
61
|
+
| LiteLLM | spend log |
|
|
62
|
+
| Amazon Bedrock | model invocation log · Converse response |
|
|
63
|
+
| Google Vertex AI · Gemini API | raw responses |
|
|
64
|
+
| Azure OpenAI | Chat Completions log |
|
|
65
|
+
|
|
66
|
+
Any other shape: map fields in one line, no script — `--map ts=created output=data.body.text output_tokens=meta.usage.out`.
|
|
67
|
+
|
|
68
|
+
No call log, only the vendor's usage or cost file? Pass it as downloaded. It reads the OpenAI Usage and Costs APIs, OpenAI console usage and cost CSVs, the Anthropic usage report (Admin API), the Anthropic console cost CSV, the AWS Cost and Usage Report, Azure cost details, Fireworks usage and the Together cost CSV. You get spend by model, input vs output, cache reads and busy hours.
|
|
69
|
+
|
|
70
|
+
A developer using Claude Code can try it on this machine's own records: `linklbee-scan --claude-code --lang en`.
|
|
71
|
+
|
|
72
|
+
## What the report finds
|
|
73
|
+
|
|
74
|
+
- Output's share of the bill — from `model` and token counts alone
|
|
75
|
+
- How much of the output could be saved by editing the previous answer instead of writing it again
|
|
76
|
+
- Calls that could be answered without a model call
|
|
77
|
+
- Failed calls that were billed
|
|
78
|
+
- Identical calls resent within seconds
|
|
79
|
+
- Answers cut off at the length limit
|
|
80
|
+
- Tool definitions and system text serialized inconsistently, which breaks the prompt cache
|
|
81
|
+
- Prompts under the vendor's cache minimum
|
|
82
|
+
- A billing check: billed output tokens against the answer text's own token count
|
|
83
|
+
- Cache hit rate
|
|
84
|
+
- Prefixes shared across calls that could be cached
|
|
85
|
+
- Calls that could use OpenAI Flex
|
|
86
|
+
|
|
87
|
+
Each item is reported as found, none, or needs more data — with the field that would show it.
|
|
88
|
+
|
|
89
|
+
## No log file yet?
|
|
90
|
+
|
|
91
|
+
Add these lines right after each call (OpenAI SDK; for Anthropic use `resp.content[0].text`, `u.input_tokens`, `u.output_tokens`). Once calls build up, run the scanner on `calls.jsonl`.
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
import json, time
|
|
95
|
+
def log_call(resp, path="calls.jsonl"): # resp = what client.chat.completions.create(...) returned
|
|
96
|
+
u = resp.usage
|
|
97
|
+
with open(path, "a", encoding="utf-8") as f:
|
|
98
|
+
f.write(json.dumps({"ts": time.time(), "output": resp.choices[0].message.content, "model": resp.model, "input_tokens": u.prompt_tokens, "output_tokens": u.completion_tokens}, ensure_ascii=False) + "\n")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
TypeScript (Node, OpenAI SDK):
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { appendFileSync } from "node:fs";
|
|
105
|
+
export function logCall(resp: any, path = "calls.jsonl") { // resp = await client.chat.completions.create(...)
|
|
106
|
+
const u = resp.usage ?? {};
|
|
107
|
+
appendFileSync(path, JSON.stringify({ ts: Date.now() / 1000, output: resp.choices[0].message.content, model: resp.model, input_tokens: u.prompt_tokens, output_tokens: u.completion_tokens }) + "\n");
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Privacy
|
|
112
|
+
|
|
113
|
+
- **No network code.** No AI calls, no telemetry. Check it: `grep -cE "ht[t]p|sock[e]t|url[l]ib" linklbee_scan.py` prints `0`.
|
|
114
|
+
- **Standard library only.** One file, nothing else to install or trust.
|
|
115
|
+
- **Your log never leaves your machine.** Answer text is read in memory only; the report holds counts, shares and dollars — no prompts, no answers, no document keys.
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
MIT (`LICENSE`), published by NOTEGG Corp. Copyright (c) 2026 NOTEGG. The embedded o200k token table is under tiktoken's MIT license (`THIRD_PARTY_NOTICES`).
|
|
120
|
+
|
|
121
|
+
Full documentation — every field, `--flat`, `--hashify`, how to read the report, and its limits — is in [README.ko.md](https://github.com/linklbee/scan/blob/main/README.ko.md) (Korean, with the full English reference at the end under "English").
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
linklbee_scan
|