etuki-cost-gate 1.0.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.
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.4
2
+ Name: etuki-cost-gate
3
+ Version: 1.0.0
4
+ Summary: Open-source CLI to prevent LLM API token cost regressions in CI/CD and audit prompt-cache savings (powered by Etuki.com)
5
+ Author-email: Rain Lobet <support@etuki.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://www.etuki.com
8
+ Project-URL: Repository, https://github.com/cooyun/etuki-gate
9
+ Keywords: llm,finops,ai-cost,prompt-cache,claude,openai,gemini,ci-cd
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+
13
+ # Etuki Cost Gate (`etuki-cost-gate`)
14
+
15
+ Prevent LLM API token and cost regressions in GitHub Pull Requests, and audit prompt-cache multipliers across 563+ AI models.
16
+
17
+ - Free Local Browser CSV Bill Auditor (Zero Upload): https://www.etuki.com/audit
18
+ - 10-Turn Prompt Cache and Coding Plan Calculator: https://www.etuki.com/calculator
19
+ - Live Embeddable Cost Badges for GitHub READMEs: https://www.etuki.com/badges
20
+ - Open-Source MCP Server: https://github.com/cooyun/etuki-gate
21
+
22
+ ## Quick Install
23
+ pip install etuki-cost-gate
@@ -0,0 +1,11 @@
1
+ # Etuki Cost Gate (`etuki-cost-gate`)
2
+
3
+ Prevent LLM API token and cost regressions in GitHub Pull Requests, and audit prompt-cache multipliers across 563+ AI models.
4
+
5
+ - Free Local Browser CSV Bill Auditor (Zero Upload): https://www.etuki.com/audit
6
+ - 10-Turn Prompt Cache and Coding Plan Calculator: https://www.etuki.com/calculator
7
+ - Live Embeddable Cost Badges for GitHub READMEs: https://www.etuki.com/badges
8
+ - Open-Source MCP Server: https://github.com/cooyun/etuki-gate
9
+
10
+ ## Quick Install
11
+ pip install etuki-cost-gate
@@ -0,0 +1 @@
1
+ __version__ = '1.0.0'
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """Etuki AI Cost Regression Gate CLI — Prevents Pull Request Token & Cost Regressions"""
4
+ import sys, json, argparse
5
+
6
+ def evaluate_regression(baseline, current, max_cost_inc_pct=10.0, max_p95_inc_pct=15.0, min_quality=90.0):
7
+ b_cost = float(baseline["avg_request_cost_usd"])
8
+ c_cost = float(current["avg_request_cost_usd"])
9
+ b_p95 = float(baseline["p95_request_cost_usd"])
10
+ c_p95 = float(current["p95_request_cost_usd"])
11
+ c_qual = float(current.get("quality_score", 0.0))
12
+
13
+ cost_delta_pct = ((c_cost - b_cost) / b_cost) * 100.0 if b_cost > 0 else 0.0
14
+ p95_delta_pct = ((c_p95 - b_p95) / b_p95) * 100.0 if b_p95 > 0 else 0.0
15
+
16
+ violations = []
17
+ if cost_delta_pct > max_cost_inc_pct:
18
+ violations.append(f"AVG_COST_REGRESSION: +{cost_delta_pct:.2f}% exceeds +{max_cost_inc_pct}% limit (${b_cost:.4f} -> ${c_cost:.4f})")
19
+ if p95_delta_pct > max_p95_inc_pct:
20
+ violations.append(f"P95_COST_REGRESSION: +{p95_delta_pct:.2f}% exceeds +{max_p95_inc_pct}% limit (${b_p95:.4f} -> ${c_p95:.4f})")
21
+ if c_qual < min_quality:
22
+ violations.append(f"QUALITY_FLOOR_BREACH: quality_score {c_qual} < minimum {min_quality}")
23
+ if baseline.get("model_id") != current.get("model_id") and not current.get("model_change_authorized", False):
24
+ violations.append(f"UNAUTHORIZED_MODEL_SUBSTITUTION: {baseline.get('model_id')} -> {current.get('model_id')}")
25
+
26
+ return {
27
+ "gate_passed": len(violations) == 0,
28
+ "cost_delta_pct": round(cost_delta_pct, 2),
29
+ "p95_delta_pct": round(p95_delta_pct, 2),
30
+ "quality_score": c_qual,
31
+ "violations": violations
32
+ }
33
+
34
+ def main():
35
+ p = argparse.ArgumentParser()
36
+ p.add_argument("--baseline", required=True)
37
+ p.add_argument("--current", required=True)
38
+ p.add_argument("--max-cost-increase", type=float, default=10.0)
39
+ p.add_argument("--max-p95-increase", type=float, default=15.0)
40
+ p.add_argument("--min-quality", type=float, default=90.0)
41
+ args = p.parse_args()
42
+ res = evaluate_regression(
43
+ json.load(open(args.baseline, "r", encoding="utf-8")),
44
+ json.load(open(args.current, "r", encoding="utf-8")),
45
+ args.max_cost_increase, args.max_p95_increase, args.min_quality
46
+ )
47
+ print(json.dumps(res, indent=2))
48
+ sys.exit(0 if res["gate_passed"] else 1)
49
+
50
+
51
+ if __name__ == "__main__":
52
+ main()
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.4
2
+ Name: etuki-cost-gate
3
+ Version: 1.0.0
4
+ Summary: Open-source CLI to prevent LLM API token cost regressions in CI/CD and audit prompt-cache savings (powered by Etuki.com)
5
+ Author-email: Rain Lobet <support@etuki.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://www.etuki.com
8
+ Project-URL: Repository, https://github.com/cooyun/etuki-gate
9
+ Keywords: llm,finops,ai-cost,prompt-cache,claude,openai,gemini,ci-cd
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+
13
+ # Etuki Cost Gate (`etuki-cost-gate`)
14
+
15
+ Prevent LLM API token and cost regressions in GitHub Pull Requests, and audit prompt-cache multipliers across 563+ AI models.
16
+
17
+ - Free Local Browser CSV Bill Auditor (Zero Upload): https://www.etuki.com/audit
18
+ - 10-Turn Prompt Cache and Coding Plan Calculator: https://www.etuki.com/calculator
19
+ - Live Embeddable Cost Badges for GitHub READMEs: https://www.etuki.com/badges
20
+ - Open-Source MCP Server: https://github.com/cooyun/etuki-gate
21
+
22
+ ## Quick Install
23
+ pip install etuki-cost-gate
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ etuki_cost_gate/__init__.py
4
+ etuki_cost_gate/cli.py
5
+ etuki_cost_gate.egg-info/PKG-INFO
6
+ etuki_cost_gate.egg-info/SOURCES.txt
7
+ etuki_cost_gate.egg-info/dependency_links.txt
8
+ etuki_cost_gate.egg-info/entry_points.txt
9
+ etuki_cost_gate.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ etuki-cost-gate = etuki_cost_gate.cli:main
@@ -0,0 +1 @@
1
+ etuki_cost_gate
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "etuki-cost-gate"
7
+ version = "1.0.0"
8
+ description = "Open-source CLI to prevent LLM API token cost regressions in CI/CD and audit prompt-cache savings (powered by Etuki.com)"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "Rain Lobet", email = "support@etuki.com" }]
13
+ keywords = ["llm", "finops", "ai-cost", "prompt-cache", "claude", "openai", "gemini", "ci-cd"]
14
+
15
+ [project.urls]
16
+ Homepage = "https://www.etuki.com"
17
+ Repository = "https://github.com/cooyun/etuki-gate"
18
+
19
+ [project.scripts]
20
+ etuki-cost-gate = "etuki_cost_gate.cli:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+