zing-audit 0.2.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 (74) hide show
  1. zing_audit-0.2.0/.gitignore +32 -0
  2. zing_audit-0.2.0/CHANGELOG.md +64 -0
  3. zing_audit-0.2.0/LICENSE +201 -0
  4. zing_audit-0.2.0/NOTICE +10 -0
  5. zing_audit-0.2.0/PKG-INFO +230 -0
  6. zing_audit-0.2.0/README.md +192 -0
  7. zing_audit-0.2.0/README.zh-CN.md +172 -0
  8. zing_audit-0.2.0/docs/METHODOLOGY.md +734 -0
  9. zing_audit-0.2.0/docs/PUBLISHING.md +47 -0
  10. zing_audit-0.2.0/examples/zing.yaml +34 -0
  11. zing_audit-0.2.0/pyproject.toml +99 -0
  12. zing_audit-0.2.0/tests/conftest.py +286 -0
  13. zing_audit-0.2.0/tests/test_anthropic.py +193 -0
  14. zing_audit-0.2.0/tests/test_billing.py +29 -0
  15. zing_audit-0.2.0/tests/test_client.py +185 -0
  16. zing_audit-0.2.0/tests/test_connectivity.py +57 -0
  17. zing_audit-0.2.0/tests/test_context_window.py +50 -0
  18. zing_audit-0.2.0/tests/test_knowledge.py +145 -0
  19. zing_audit-0.2.0/tests/test_model_identity.py +70 -0
  20. zing_audit-0.2.0/tests/test_redaction.py +81 -0
  21. zing_audit-0.2.0/tests/test_roadmap_security.py +173 -0
  22. zing_audit-0.2.0/tests/test_scoring.py +227 -0
  23. zing_audit-0.2.0/tests/test_security.py +26 -0
  24. zing_audit-0.2.0/tests/test_utils.py +244 -0
  25. zing_audit-0.2.0/zing/__init__.py +12 -0
  26. zing_audit-0.2.0/zing/__main__.py +6 -0
  27. zing_audit-0.2.0/zing/cli.py +476 -0
  28. zing_audit-0.2.0/zing/clients/__init__.py +47 -0
  29. zing_audit-0.2.0/zing/clients/anthropic.py +320 -0
  30. zing_audit-0.2.0/zing/clients/base.py +132 -0
  31. zing_audit-0.2.0/zing/clients/openai_compatible.py +218 -0
  32. zing_audit-0.2.0/zing/config.py +215 -0
  33. zing_audit-0.2.0/zing/context.py +57 -0
  34. zing_audit-0.2.0/zing/detectors/__init__.py +32 -0
  35. zing_audit-0.2.0/zing/detectors/base.py +104 -0
  36. zing_audit-0.2.0/zing/detectors/billing.py +247 -0
  37. zing_audit-0.2.0/zing/detectors/capability.py +494 -0
  38. zing_audit-0.2.0/zing/detectors/connectivity.py +103 -0
  39. zing_audit-0.2.0/zing/detectors/context_window.py +424 -0
  40. zing_audit-0.2.0/zing/detectors/determinism.py +202 -0
  41. zing_audit-0.2.0/zing/detectors/helpers.py +159 -0
  42. zing_audit-0.2.0/zing/detectors/injected_prompt.py +186 -0
  43. zing_audit-0.2.0/zing/detectors/integrity.py +167 -0
  44. zing_audit-0.2.0/zing/detectors/model_identity.py +444 -0
  45. zing_audit-0.2.0/zing/detectors/prompt_cache.py +120 -0
  46. zing_audit-0.2.0/zing/detectors/protocol.py +256 -0
  47. zing_audit-0.2.0/zing/detectors/quality_judge.py +280 -0
  48. zing_audit-0.2.0/zing/detectors/reliability.py +210 -0
  49. zing_audit-0.2.0/zing/detectors/security.py +202 -0
  50. zing_audit-0.2.0/zing/detectors/streaming.py +198 -0
  51. zing_audit-0.2.0/zing/judge/__init__.py +11 -0
  52. zing_audit-0.2.0/zing/judge/judge.py +70 -0
  53. zing_audit-0.2.0/zing/knowledge/__init__.py +24 -0
  54. zing_audit-0.2.0/zing/knowledge/data/__init__.py +7 -0
  55. zing_audit-0.2.0/zing/knowledge/data/anthropic.yaml +609 -0
  56. zing_audit-0.2.0/zing/knowledge/data/deepseek.yaml +261 -0
  57. zing_audit-0.2.0/zing/knowledge/data/gemini.yaml +508 -0
  58. zing_audit-0.2.0/zing/knowledge/data/glm.yaml +730 -0
  59. zing_audit-0.2.0/zing/knowledge/data/moonshot.yaml +450 -0
  60. zing_audit-0.2.0/zing/knowledge/data/openai.yaml +702 -0
  61. zing_audit-0.2.0/zing/knowledge/data/qwen.yaml +712 -0
  62. zing_audit-0.2.0/zing/knowledge/loader.py +69 -0
  63. zing_audit-0.2.0/zing/knowledge/schema.py +158 -0
  64. zing_audit-0.2.0/zing/models.py +263 -0
  65. zing_audit-0.2.0/zing/report/__init__.py +14 -0
  66. zing_audit-0.2.0/zing/report/render.py +537 -0
  67. zing_audit-0.2.0/zing/report/writer.py +68 -0
  68. zing_audit-0.2.0/zing/runner.py +145 -0
  69. zing_audit-0.2.0/zing/scoring.py +283 -0
  70. zing_audit-0.2.0/zing/utils/__init__.py +1 -0
  71. zing_audit-0.2.0/zing/utils/redact.py +118 -0
  72. zing_audit-0.2.0/zing/utils/sse.py +68 -0
  73. zing_audit-0.2.0/zing/utils/stats.py +66 -0
  74. zing_audit-0.2.0/zing/utils/tokenize.py +92 -0
@@ -0,0 +1,32 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+ *.whl
9
+
10
+ # Virtual envs
11
+ .venv/
12
+ venv/
13
+ env/
14
+
15
+ # Tooling caches
16
+ .pytest_cache/
17
+ .ruff_cache/
18
+ .mypy_cache/
19
+ .coverage
20
+ htmlcov/
21
+
22
+ # zing output
23
+ reports/
24
+ *.zing.json
25
+
26
+ # Reference material (ChatGPT v0 seed, not part of the project)
27
+ tmp/
28
+
29
+ # OS / editor
30
+ .DS_Store
31
+ .idea/
32
+ .vscode/
@@ -0,0 +1,64 @@
1
+ # Changelog
2
+
3
+ All notable changes to **zing** are documented here. The format is based on
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres
5
+ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.2.0] — Anthropic support & roadmap security detectors
10
+
11
+ ### Added
12
+
13
+ - **Anthropic Messages API support.** zing now audits Anthropic-native relays
14
+ (`/v1/messages`) as well as OpenAI Chat Completions, behind one detector
15
+ interface. The protocol is auto-detected from the base_url/model or forced with
16
+ `--api openai|anthropic` (and `--target-api` / `--baseline-api` for `compare`).
17
+ - **Three new `deep`-suite security detectors** (formerly roadmap):
18
+ - `injected_prompt` — detects a hidden, silently-prepended system prompt from a
19
+ large *fixed* input-token overhead (measured across two message sizes) plus a
20
+ leak probe; needs both signals to warn.
21
+ - `integrity` — known-answer URL/package canaries catch in-flight response/tool-call
22
+ tampering (value substituted, structure preserved). CRITICAL only when a trusted
23
+ baseline returns the canary intact; otherwise MEDIUM.
24
+ - `prompt_cache` — flags prompt-prefix caching by TTFT timing (informational; states
25
+ that cross-user cache sharing is not provable from a single key).
26
+ - Automated PyPI publishing via GitHub Actions + Trusted Publishing
27
+ (`.github/workflows/release.yml`); see `docs/PUBLISHING.md`.
28
+
29
+ ## [0.1.0] — first public alpha
30
+
31
+ First public release. A local-first CLI that audits whether an OpenAI-compatible
32
+ API relay (中转站 / reseller / proxy) actually serves the model it claims to —
33
+ or quietly substitutes a cheaper one, truncates the context window, fakes
34
+ streaming, or inflates token billing (货不对板检测).
35
+
36
+ ### Added
37
+
38
+ - `zing check` — audit one relay endpoint against what it claims (model id +
39
+ optional provider hint).
40
+ - `zing compare` — audit a relay against a trusted baseline of the same declared
41
+ model (the strongest downgrade evidence).
42
+ - `zing models` — probe an endpoint's `GET /v1/models` list.
43
+ - `zing kb` — inspect the bundled knowledge base.
44
+ - `zing init` — write a starter `zing.yaml` config.
45
+ - Eleven detectors across nine scored dimensions: model identity & downgrade
46
+ fingerprinting, real context window & truncation, capability claims, token/usage
47
+ billing, streaming authenticity, OpenAI-protocol conformance, determinism/cache
48
+ correctness, concurrent reliability, transport/secret-handling security, plus
49
+ connectivity and an optional LLM-judged quality assessment (`--judge`).
50
+ - Bundled knowledge base of **85 native model profiles across 7 platforms**
51
+ (OpenAI, Anthropic, Google Gemini, DeepSeek, Qwen, GLM, Moonshot), editable as
52
+ YAML and overridable via `--kb-dir` / `ZING_KB_DIR`.
53
+ - Two detection modes: pure-code deterministic probes (default) and a code+LLM
54
+ hybrid that consults a separate trusted judge model.
55
+ - JSON, Markdown, and HTML reports; `--json` for machine/agent consumption.
56
+ - Evidence-first verdicts (CLEAN / LOW / MEDIUM / HIGH / INCONCLUSIVE) with
57
+ confidence, designed to avoid false accusations of honest relays.
58
+ - Secret hygiene: API keys are fingerprinted (never stored) and relay-controlled
59
+ text is redacted before it reaches any report (JSON/Markdown/HTML).
60
+ - `--fail-under` / `--fail-on-risk` exit-code gates for CI use.
61
+
62
+ [Unreleased]: https://github.com/cenbonew/zing/compare/v0.2.0...HEAD
63
+ [0.2.0]: https://github.com/cenbonew/zing/compare/v0.1.0...v0.2.0
64
+ [0.1.0]: https://github.com/cenbonew/zing/releases/tag/v0.1.0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 zing contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,10 @@
1
+ zing — LLM relay reality check
2
+ Copyright 2026 zing contributors
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see the LICENSE
5
+ file). You may not use this product except in compliance with that License.
6
+
7
+ zing is a black-box auditing aid. It gathers reproducible evidence of behavioral
8
+ divergence and risk — not cryptographic proof of model identity or fraud. See
9
+ README.md ("Responsible use") and docs/METHODOLOGY.md before publishing any
10
+ report that names a vendor.
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.4
2
+ Name: zing-audit
3
+ Version: 0.2.0
4
+ Summary: LLM relay reality check — a CLI that audits whether an API relay actually serves the model it claims (货不对板检测).
5
+ Project-URL: Homepage, https://github.com/cenbonew/zing
6
+ Project-URL: Repository, https://github.com/cenbonew/zing
7
+ Project-URL: Issues, https://github.com/cenbonew/zing/issues
8
+ Author: zing contributors
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Keywords: api,audit,context-window,llm,model-fingerprinting,openai,proxy,relay
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Quality Assurance
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: httpx>=0.27
25
+ Requires-Dist: pydantic>=2.6
26
+ Requires-Dist: pyyaml>=6.0
27
+ Requires-Dist: rich>=13.7
28
+ Requires-Dist: typer>=0.12
29
+ Provides-Extra: dev
30
+ Requires-Dist: mypy>=1.10; extra == 'dev'
31
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
32
+ Requires-Dist: pytest>=8.0; extra == 'dev'
33
+ Requires-Dist: ruff>=0.5; extra == 'dev'
34
+ Requires-Dist: types-pyyaml>=6.0; extra == 'dev'
35
+ Provides-Extra: tokenizers
36
+ Requires-Dist: tiktoken>=0.7; extra == 'tokenizers'
37
+ Description-Content-Type: text/markdown
38
+
39
+ # zing — LLM relay reality check
40
+
41
+ > **English** · [中文](README.zh-CN.md)
42
+
43
+ [![CI](https://github.com/cenbonew/zing/actions/workflows/ci.yml/badge.svg)](https://github.com/cenbonew/zing/actions/workflows/ci.yml)
44
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
45
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](pyproject.toml)
46
+
47
+ **zing** is a local-first CLI that audits whether an API relay (中转站 / reseller /
48
+ proxy) actually serves the model it claims to — or quietly substitutes a cheaper
49
+ one, truncates your context window, fakes streaming, or inflates token billing
50
+ (**货不对板检测**). It speaks both **OpenAI Chat Completions** and the
51
+ **Anthropic Messages API** (auto-detected, or forced with `--api`).
52
+
53
+ You point it at a relay endpoint and the model it advertises; zing runs a battery
54
+ of black-box probes, compares the observed behavior against a bundled knowledge
55
+ base of **85 native model profiles across 7 platforms**, and prints a clear,
56
+ evidence-backed verdict — for a human, or as JSON for another tool / LLM to read.
57
+
58
+ > zing reports **black-box evidence of divergence and risk, not cryptographic
59
+ > proof of fraud.** See [Responsible use](#responsible-use).
60
+
61
+ ---
62
+
63
+ ## Why
64
+
65
+ The relay-key market is full of "GPT-4o for 1/10th the price" offers. Many are
66
+ honest. Some are not — and the dishonest ones are hard to catch by eye:
67
+
68
+ - You ask for `gpt-4o`; you're quietly served `gpt-4o-mini` or an open model.
69
+ - The relay advertises a 1M-token context but silently truncates to 32K.
70
+ - "Streaming" is the full response buffered and re-chunked, with no latency win.
71
+ - Reported `usage` tokens are inflated, so your balance burns faster than it should.
72
+ - A model that should support tool-calling / JSON mode quietly doesn't.
73
+
74
+ zing turns "this feels off" into a reproducible report.
75
+
76
+ ## Install
77
+
78
+ Requires Python 3.10+.
79
+
80
+ ```bash
81
+ # from PyPI
82
+ pip install zing-audit # the `zing` command
83
+
84
+ # or from source
85
+ git clone https://github.com/cenbonew/zing
86
+ cd zing
87
+ pip install -e .
88
+ ```
89
+
90
+ (Maintainers: see [docs/PUBLISHING.md](docs/PUBLISHING.md) for the release process.)
91
+
92
+ Optional: install the `tokenizers` extra for accurate OpenAI-family token
93
+ counting in the billing audit:
94
+
95
+ ```bash
96
+ pip install -e '.[tokenizers]'
97
+ ```
98
+
99
+ ## Quick start
100
+
101
+ ```bash
102
+ # 1) audit a relay against what it claims (model id + provider hint)
103
+ export ZING_API_KEY=sk-your-relay-key
104
+ zing check \
105
+ --base-url https://relay.example.com/v1 \
106
+ --api-key env:ZING_API_KEY \
107
+ --model gpt-4o \
108
+ --suite standard
109
+
110
+ # 2) the strongest check: compare against a trusted baseline of the same model
111
+ export OPENAI_API_KEY=sk-your-openai-key
112
+ zing compare \
113
+ --target-base-url https://relay.example.com/v1 --target-api-key env:ZING_API_KEY --target-model gpt-4o \
114
+ --baseline-base-url https://api.openai.com/v1 --baseline-api-key env:OPENAI_API_KEY --baseline-model gpt-4o \
115
+ --suite deep
116
+
117
+ # 3) audit an Anthropic-native (Messages API) relay — protocol is auto-detected
118
+ # from the base_url/model, or force it with --api anthropic
119
+ zing check --base-url https://relay.example.com/v1 --model claude-opus-4-8 \
120
+ --api-key env:ZING_API_KEY --api anthropic
121
+
122
+ # 4) inspect the bundled knowledge base
123
+ zing kb # all 85 models
124
+ zing kb deepseek # one provider
125
+
126
+ # 5) generate a config you can commit
127
+ zing init # writes zing.yaml
128
+ zing check -c zing.yaml
129
+ ```
130
+
131
+ ### As a tool for an LLM / agent
132
+
133
+ `--json` prints the structured report to stdout instead of writing files — feed
134
+ it straight to another program or model:
135
+
136
+ ```bash
137
+ zing check --base-url ... --model gpt-4o --json | jq .verdict
138
+ ```
139
+
140
+ ## What it checks
141
+
142
+ zing scores nine dimensions. The three that most directly reveal 货不对板
143
+ (model identity, real context window, capability claims) carry the most weight.
144
+
145
+ | Dimension | What it catches |
146
+ |---|---|
147
+ | **model_identity** | Silent model downgrade/substitution — self-identification, knowledge-cutoff, tokenizer fingerprints, the echoed `model` field |
148
+ | **context_window** | Silent context truncation (claim 1M, recall fails at 32K) and lost-in-the-middle from cheap RAG/summarization shims, via needle-in-a-haystack + binary search |
149
+ | **capability** | Tool-calling / JSON-mode / json-schema / max-output claims that aren't actually delivered (or *over*-delivered, hinting at a substitute) |
150
+ | **billing** | Token/usage inflation and missing/unverifiable usage accounting, via an independent tokenizer estimate |
151
+ | **streaming** | Fake streaming (buffer-then-chunk) detected from chunk count and inter-chunk timing |
152
+ | **protocol** | OpenAI-compatibility conformance: multi-turn, stop sequences, response shape, error schema — and a determinism sub-check for response caching that ignores temperature/seed |
153
+ | **reliability** | Concurrent success rate and latency (HTTP 429 throttling bucketed separately) |
154
+ | **connectivity** | Endpoint reachability and the advertised `/v1/models` list |
155
+ | **security** | Transport (HTTPS), header hygiene, secret echo; hidden injected system prompt (fixed input-token overhead + leak), in-flight response/tool-call tampering via known-answer canaries (URL/package substitution), and prompt-prefix caching (timing) |
156
+
157
+ See [docs/METHODOLOGY.md](docs/METHODOLOGY.md) for the technique behind each check,
158
+ which relay trick it maps to, and its false-positive caveats.
159
+
160
+ ## Two detection modes
161
+
162
+ - **Pure code (default):** every deterministic probe — fingerprints, context
163
+ sweep, billing math, streaming timing. No second model needed; fully
164
+ reproducible.
165
+ - **Code + LLM hybrid (`--judge`):** additionally consults a *trusted* judge
166
+ model (configured separately, never the target) to assess fuzzy signals like
167
+ quality and reasoning depth that pure code can't decide. Powers the
168
+ `quality_judge` detector.
169
+
170
+ ```bash
171
+ zing check --base-url ... --model gpt-4o --suite deep --judge \
172
+ --judge-base-url https://api.openai.com/v1 --judge-api-key env:OPENAI_API_KEY --judge-model gpt-4o-mini
173
+ ```
174
+
175
+ ## Suites
176
+
177
+ | Suite | Detectors | Cost |
178
+ |---|---|---|
179
+ | `smoke` | connectivity, security | very low |
180
+ | `standard` | + protocol, model_identity, capability, streaming, billing, reliability | low–medium |
181
+ | `deep` | + context_window, determinism, injected_prompt, integrity, prompt_cache, quality_judge (if `--judge`) | higher (long-context & timing probes cost tokens) |
182
+ | `full` | everything | highest |
183
+
184
+ The context-window probe is bounded by `--max-context-tokens` (default 200K) so
185
+ auditing a 1M-token model stays affordable.
186
+
187
+ ## Example verdict
188
+
189
+ ```text
190
+ ╭─ ✗ HIGH RISK — Strong evidence the relay does not deliver the claimed model… ─╮
191
+ │ Target : my-relay · model gpt-4o · provider openai │
192
+ │ Mode : check · suite deep │
193
+ │ Score : 53.5/100 (rating F) · confidence medium │
194
+ │ │
195
+ │ Overall health score 53.5/100. Findings: 3 high. … │
196
+ ╰───────────────────────────────────────────────────────────────────────────────╯
197
+ • Self-identifies as a rival brand (anthropic) under the claimed model id gpt-4o
198
+ • Real context window ~8000 << declared 128000 (silent truncation suspected)
199
+ • Reported prompt tokens far exceed independent estimate
200
+ ```
201
+
202
+ Reports are written to `reports/` as JSON, Markdown, and HTML.
203
+
204
+ ## Knowledge base
205
+
206
+ Profiles live in [`zing/knowledge/data/`](zing/knowledge/data) as editable YAML —
207
+ one per provider (OpenAI, Anthropic, Google Gemini, DeepSeek, Qwen, GLM,
208
+ Moonshot). Each model carries its native context window, max output, tokenizer,
209
+ capability flags, identity keywords, and behavioral fingerprints. Add or override
210
+ profiles without forking:
211
+
212
+ ```bash
213
+ zing check --kb-dir ./my-profiles ... # or set ZING_KB_DIR
214
+ ```
215
+
216
+ ## Responsible use
217
+
218
+ zing is a black-box auditing aid. It **cannot prove**:
219
+
220
+ - that a provider stores or trains on your prompts,
221
+ - that it always routes to one exact model (relays can route probabilistically),
222
+ - billing fraud beyond what independent token estimation can suggest.
223
+
224
+ Use reports for your own due diligence. **Do not publicly accuse a vendor** based
225
+ on a single run without reviewing sample size, cost settings, and local law. Run
226
+ `zing compare` against a trusted baseline before drawing strong conclusions.
227
+
228
+ ## License
229
+
230
+ [Apache-2.0](LICENSE)