The diagnosis runs locally and does not send your logs anywhere. The source code is available in the public repository.
No extra dependencies
Python 3.9+ and the standard library only.
MIT licensed
The complete scanner source is available for review.
Your logs stay local
Reports contain no request or response content and no API keys. They provide analysis results such as usage, ratios, and cost.
# Check the network-related patterns in the scanner source
grep -cE "ht[t]p|sock[e]t|url[l]ib" linklbee_scan.py
0
SAMPLE REPORT
See how scan results are presented.
The HTML report separates cost drivers, potential improvements and the data needed for further analysis. Start with the data you have today: call logs, provider usage files, or Claude Code records. With none of these, run --demo to see a synthetic sample report first.
SAMPLE REPORT · SYNTHETIC DATA
LLM API cost diagnostics — example
🧪 [Synthetic] Generated by running the scanner on the example log. It does not represent any real company’s usage or savings.
Calls analyzed322Synthetic call records
Example log cost$1.06Calculated from example usage
Cache hit rate0.0%Input-token share in the example
Repeated calls, output limits, cache behavior and improvement candidates
Items requiring additional log fields
The distinction between estimated savings and measured savings
All sample records are synthetic. Actual savings depend on your workload and must be verified after integration. The full report opens in a new tab and can be printed to PDF.
GET STARTED
Download → run → review results
Supported input formats
OpenAI and Anthropic — raw SDK responses
CSV, TSV, JSON arrays, JSONL, .log and .gz files
Traces and usage logs exported from supported monitoring tools
Amazon Bedrock invocation logs, Google Vertex AI / Gemini and Azure OpenAI responses
Provider usage and billing files, including OpenAI, Anthropic, AWS and Azure
Only fields present in the provided data are analyzed. Missing data is identified in the report.
pip install linklbee-scan
linklbee-scan
# Create the full HTML report
linklbee-scan calls.jsonl --lang en --out report.html
# --peek previews how the fields in the first 200 lines are recognized. Leave it out to run the full diagnosis
linklbee-scan calls.jsonl --peek --lang en
To run the downloaded single-file version:
curl -fsSLO https://raw.githubusercontent.com/linklbee/scan/main/linklbee_scan.py
python3 linklbee_scan.py calls.jsonl --lang en --out report.html
The report language follows your computer’s language setting. Use --lang ko|en to choose.
For help interpreting results, use the “Request a free report review” button at the bottom of the HTML report, or share only a non-sensitive report overview with bee@linklbee.com. Do not send raw logs or API keys.
Verify the local file's SHA-256 (v1.4.13):
shasum -a 256 linklbee_scan.py
# Linux: sha256sum linklbee_scan.py
7cc055230c805677742e7ae2735ad6a89a79846a623355e9b1cc11fff64564cc
STARTING POINTS
Start from the data you have.
All three paths run on this computer. You can start without submitting raw logs or API keys to an external AI or to Linklbee.
① You have call logs
Pass a file or folder as it is, with no conversion. Check field recognition with --peek first, then create the report.
Pass the file from the console or API as it is. The scanner reads OpenAI usage and costs, Anthropic usage, AWS Cost and Usage Reports (CUR), Azure cost details, Fireworks and Together files.
“input grade D” in the first section of the report means it was read as a usage file.
You see tokens and cost by model, the input and output cost split, the cache-read share and busy hours. Items that need individual calls, such as resends and responses stopped by an output limit, need call logs.
③ You have no call logs yet
Add the logging function, add one line right after your existing API call, then scan the file that builds up. It stores the SDK response as it is, so you need no new log format and no extra package.
import json, sys, time
from openai import OpenAI
def log_call(resp, path="calls.jsonl"):
# A logging failure only prints a warning; the API response is used as usual
try:
record = resp.model_dump(mode="json")
record["ts"] = time.time()
with open(path, "a", encoding="utf-8") as f:
f.write(json.dumps(record, ensure_ascii=False) + "\n")
except Exception as e:
print("log_call skipped:", e, file=sys.stderr)
client = OpenAI()
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
)
log_call(resp) # Add this right after your existing call
print(resp.choices[0].message.content)
import { appendFileSync } from "node:fs";
import OpenAI from "openai";
export function logCall(resp: any, path = "calls.jsonl") {
// A logging failure only prints a warning; the API response is used as usual
try {
if (!resp?.model) throw new Error("no completed response");
appendFileSync(path, JSON.stringify({ ...resp, ts: Date.now() / 1000 }) + "\n");
} catch (e) {
console.error("logCall skipped:", e);
}
}
const client = new OpenAI();
const resp = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Hello" }],
});
logCall(resp); // Add this right after your existing call
console.log(resp.choices[0].message.content);
# Add this below the log_call definition and client above
with client.chat.completions.stream(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
stream_options={"include_usage": True},
) as stream:
for event in stream:
if event.type == "content.delta":
print(event.delta, end="")
log_call(stream.get_final_completion()) # Log after the stream ends
// Add this below the logCall definition and client above
const stream = client.chat.completions.stream({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Hello" }],
stream_options: { include_usage: true },
});
stream.on("content", (delta) => process.stdout.write(delta));
logCall(await stream.finalChatCompletion()); // Log after the stream ends
The logging function does not raise when a write fails. It leaves a log_call skipped warning in your run output and the API response is used as usual.
calls.jsonl stores answer text. Do not commit it to a code repository or send it elsewhere. The scan report contains no answer text.
Once calls have built up, run the same commands as path ①.
OpenAI Chat Completions and Responses, Anthropic Messages official SDKs — non-streaming
Right after the call: log_call(resp) or logCall(resp)
Answer text, token counts and cache tokens are all kept.
Same SDKs — stream helper (.stream())
Pass the final response after the stream ends. OpenAI: get_final_completion() · finalChatCompletion(). Anthropic: get_final_message() · finalMessage()
OpenAI needs include_usage turned on to keep token counts. Without it, no cost appears.
Same SDKs — code that reads a stream=True response itself
Not logged automatically. The logging function leaves a warning and skips it.
The response still passes through. Switch to the stream helper or start with path ②.
Bedrock · Vertex AI · Gemini · Azure OpenAI · other SDKs
This logging code does not cover them.
Pass provider logs or monitoring-tool exports through path ①, or start with path ②.
If you get stuck
What you see
What it means
What to do
no such file or folder
No file at that path.
Check the path and file name, then run again.
“No call records found” or “No file to analyze” with the starting options
The folder has no file to read.
Prepare a file through path ② or ③.
“0 of 0 records” from --peek, “No usable calls were read” in the report
The file is empty. If “not JSON” equals the line count, the lines could not be read.
If you use the logging code, check that the file grows after a call and look for log_call skipped in your run output. Also check there is one JSON object per line.
ts ← not found · output ← not found
The field names differ from the names the scanner reads.
Name them with --map. Example: --map ts=When output=AnswerBody --peek
No input_tokens · output_tokens · model line in --peek
There are no values to calculate cost from.
Set them with --map the same way, or keep those values in your log.
“could not be judged” in the summary
The log is missing a value that item needs. It does not mean there is nothing to improve.
Check the fields with --peek and add the values listed at the end of section 2 to your log.
If this table does not solve it, send only the error message and your environment to bee@linklbee.com. Do not send raw logs or API keys.
FURTHER GUIDANCE
Need installation or interpretation guidance?
The public documentation explains supported formats, missing fields, running without call logs, and reading diagnostic results. It is useful when working through a particular integration.
Setup and usage
Get the correct commands for your environment, without sharing logs or API keys.