acretix-verify-sdk 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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Acretix
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 @@
1
+ exclude test_acretix_verify.py
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: acretix-verify-sdk
3
+ Version: 0.1.0
4
+ Summary: Python client for the AI Verify API - rubric-based verdicts with signed, re-verifiable proofs.
5
+ License: MIT
6
+ Project-URL: Documentation, https://api.acretix.io/docs
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Dynamic: license-file
13
+
14
+ # acretix-verify-sdk
15
+
16
+ Python client for the [AI Verify API](https://api.acretix.io/docs) — submit work against a rubric
17
+ and receive a scored, explained verdict with an Ed25519-signed, independently re-verifiable proof.
18
+
19
+ ```python
20
+ import os
21
+ from acretix_verify import AcretixVerify
22
+
23
+ client = AcretixVerify(api_key=os.environ["VERIFY_API_KEY"])
24
+
25
+ rubric = client.compile_rubric({
26
+ "name": "invoice-check",
27
+ "criteria": [
28
+ {"key": "total_present", "type": "must_have", "primitive": "regex_match@1",
29
+ "config": {"pattern": r"Total: \$[0-9]+"}},
30
+ ],
31
+ })
32
+
33
+ verdict = client.submit_verification(
34
+ rubric_id=rubric["rubric_id"],
35
+ submission={"inline": "Invoice... Total: $420"},
36
+ wait_ms=30000,
37
+ idempotency_key="invoice-001",
38
+ )
39
+ # verdict["determination"]: "met" | "partial" | "not_met" — flagged=True means needs_review:
40
+ # below the confidence threshold the engine abstains rather than asserting a verdict.
41
+
42
+ report = client.reverify(verdict["verification_id"])
43
+ # report["ok"] and report["chain_ok"] — the proof verifies against the published public key.
44
+ ```
45
+
46
+ - Verdicts below the confidence threshold are **flagged `needs_review`** — the engine abstains
47
+ instead of guessing; your application decides what happens next.
48
+ - Proofs are signed with Ed25519 and re-verifiable by any third party against the published
49
+ public key — see the [docs](https://api.acretix.io/docs) for the proof format.
50
+ - Also available: `get_verification`, `wait_for_verification`, `get_proof`, `get_usage`, `submit_feedback`.
51
+ - Usage is metered per verification by judge tier.
52
+
53
+ Standard library only (urllib). Python 3.9+.
54
+
55
+ License: MIT
@@ -0,0 +1,42 @@
1
+ # acretix-verify-sdk
2
+
3
+ Python client for the [AI Verify API](https://api.acretix.io/docs) — submit work against a rubric
4
+ and receive a scored, explained verdict with an Ed25519-signed, independently re-verifiable proof.
5
+
6
+ ```python
7
+ import os
8
+ from acretix_verify import AcretixVerify
9
+
10
+ client = AcretixVerify(api_key=os.environ["VERIFY_API_KEY"])
11
+
12
+ rubric = client.compile_rubric({
13
+ "name": "invoice-check",
14
+ "criteria": [
15
+ {"key": "total_present", "type": "must_have", "primitive": "regex_match@1",
16
+ "config": {"pattern": r"Total: \$[0-9]+"}},
17
+ ],
18
+ })
19
+
20
+ verdict = client.submit_verification(
21
+ rubric_id=rubric["rubric_id"],
22
+ submission={"inline": "Invoice... Total: $420"},
23
+ wait_ms=30000,
24
+ idempotency_key="invoice-001",
25
+ )
26
+ # verdict["determination"]: "met" | "partial" | "not_met" — flagged=True means needs_review:
27
+ # below the confidence threshold the engine abstains rather than asserting a verdict.
28
+
29
+ report = client.reverify(verdict["verification_id"])
30
+ # report["ok"] and report["chain_ok"] — the proof verifies against the published public key.
31
+ ```
32
+
33
+ - Verdicts below the confidence threshold are **flagged `needs_review`** — the engine abstains
34
+ instead of guessing; your application decides what happens next.
35
+ - Proofs are signed with Ed25519 and re-verifiable by any third party against the published
36
+ public key — see the [docs](https://api.acretix.io/docs) for the proof format.
37
+ - Also available: `get_verification`, `wait_for_verification`, `get_proof`, `get_usage`, `submit_feedback`.
38
+ - Usage is metered per verification by judge tier.
39
+
40
+ Standard library only (urllib). Python 3.9+.
41
+
42
+ License: MIT
@@ -0,0 +1,123 @@
1
+ """AI Verify Python SDK — stdlib-only thin client (DRAFT, internal, never published).
2
+
3
+ Mirrors sdks/typescript/src/client.ts. Uses urllib so no dependency is required;
4
+ pass a custom ``transport`` callable for tests (signature: (method, url, headers, body) ->
5
+ (status, body_text)).
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import json
10
+ import time
11
+ import urllib.error
12
+ import urllib.request
13
+ from typing import Any, Callable, Optional
14
+
15
+ Transport = Callable[[str, str, dict, Optional[bytes]], tuple]
16
+
17
+
18
+ class AcretixVerifyError(Exception):
19
+ """problem+json error carrying status + RFC-7807 fields."""
20
+
21
+ def __init__(self, status: int, problem: dict):
22
+ super().__init__(f"{status} {problem.get('title', 'request failed')}")
23
+ self.status = status
24
+ self.problem = problem
25
+
26
+
27
+ def _default_transport(method: str, url: str, headers: dict, body: Optional[bytes]) -> tuple:
28
+ request = urllib.request.Request(url, data=body, headers=headers, method=method)
29
+ try:
30
+ with urllib.request.urlopen(request, timeout=70) as response:
31
+ return response.status, response.read().decode("utf-8")
32
+ except urllib.error.HTTPError as error: # non-2xx still carries the problem body
33
+ return error.code, error.read().decode("utf-8")
34
+
35
+
36
+ class AcretixVerify:
37
+ def __init__(self, api_key: str, base_url: str = "http://localhost:3000",
38
+ transport: Transport = _default_transport):
39
+ if not api_key.startswith("avk_"):
40
+ raise ValueError("api_key must be an AI Verify key (avk_...)")
41
+ self._api_key = api_key
42
+ self._base_url = base_url.rstrip("/")
43
+ self._transport = transport
44
+
45
+ # -- surface -----------------------------------------------------------------
46
+ def compile_rubric(self, spec: dict) -> dict:
47
+ return self._request("POST", "/api/v1/rubrics", spec)
48
+
49
+ def submit_verification(self, rubric_id: str, submission: dict,
50
+ idempotency_key: Optional[str] = None,
51
+ wait_ms: Optional[int] = None,
52
+ max_judge_tier: Optional[int] = None,
53
+ reference_set_id: Optional[str] = None,
54
+ callback_url: Optional[str] = None) -> dict:
55
+ payload: dict[str, Any] = {"rubric_id": rubric_id, "submission": submission}
56
+ if reference_set_id is not None:
57
+ payload["reference_set_id"] = reference_set_id
58
+ if callback_url is not None: # top-level contract field, NOT inside options
59
+ payload["callback_url"] = callback_url
60
+ options: dict[str, Any] = {}
61
+ if wait_ms is not None:
62
+ options["wait_ms"] = wait_ms
63
+ if max_judge_tier is not None:
64
+ options["max_judge_tier"] = max_judge_tier
65
+ if options:
66
+ payload["options"] = options
67
+ headers = {"idempotency-key": idempotency_key} if idempotency_key else {}
68
+ return self._request("POST", "/api/v1/verify", payload, headers)
69
+
70
+ def get_verification(self, verification_id: str) -> dict:
71
+ return self._request("GET", f"/api/v1/verifications/{verification_id}")
72
+
73
+ def wait_for_verification(self, verification_id: str, timeout_s: float = 120.0) -> dict:
74
+ started = time.monotonic()
75
+ delay = 0.5
76
+ while True:
77
+ row = self.get_verification(verification_id)
78
+ if row.get("status") in ("succeeded", "failed"):
79
+ return row
80
+ if time.monotonic() - started > timeout_s:
81
+ raise AcretixVerifyError(408, {"title": "timed out waiting for verification"})
82
+ time.sleep(delay)
83
+ delay = min(delay * 2, 2.0)
84
+
85
+ def get_proof(self, verification_id: str) -> dict:
86
+ return self._request("GET", f"/api/v1/verifications/{verification_id}/proof")
87
+
88
+ def reverify(self, verification_id: str) -> dict:
89
+ return self._request("POST", f"/api/v1/verifications/{verification_id}/reverify")
90
+
91
+ def get_usage(self, from_day: Optional[str] = None, to_day: Optional[str] = None) -> dict:
92
+ query = []
93
+ if from_day:
94
+ query.append(f"from={from_day}")
95
+ if to_day:
96
+ query.append(f"to={to_day}")
97
+ suffix = ("?" + "&".join(query)) if query else ""
98
+ return self._request("GET", f"/api/v1/usage{suffix}")
99
+
100
+ def submit_feedback(self, verification_id: str, outcome: str, note: Optional[str] = None) -> dict:
101
+ return self._request("POST", f"/api/v1/verifications/{verification_id}/feedback",
102
+ {"outcome": outcome, "note": note})
103
+
104
+ # -- plumbing ----------------------------------------------------------------
105
+ def _request(self, method: str, path: str, body: Optional[dict] = None,
106
+ extra_headers: Optional[dict] = None) -> dict:
107
+ headers = {"authorization": f"Bearer {self._api_key}", **(extra_headers or {})}
108
+ encoded = None
109
+ if body is not None:
110
+ headers["content-type"] = "application/json"
111
+ encoded = json.dumps(body).encode("utf-8")
112
+ status, text = self._transport(method, f"{self._base_url}{path}", headers, encoded)
113
+ try:
114
+ parsed = json.loads(text) if text else None
115
+ except json.JSONDecodeError:
116
+ parsed = {"title": "non-JSON response", "detail": text[:200]}
117
+ if status >= 400:
118
+ raise AcretixVerifyError(status, parsed or {"title": "request failed"})
119
+ return parsed or {}
120
+
121
+
122
+ if __name__ == "__main__":
123
+ pass
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: acretix-verify-sdk
3
+ Version: 0.1.0
4
+ Summary: Python client for the AI Verify API - rubric-based verdicts with signed, re-verifiable proofs.
5
+ License: MIT
6
+ Project-URL: Documentation, https://api.acretix.io/docs
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Dynamic: license-file
13
+
14
+ # acretix-verify-sdk
15
+
16
+ Python client for the [AI Verify API](https://api.acretix.io/docs) — submit work against a rubric
17
+ and receive a scored, explained verdict with an Ed25519-signed, independently re-verifiable proof.
18
+
19
+ ```python
20
+ import os
21
+ from acretix_verify import AcretixVerify
22
+
23
+ client = AcretixVerify(api_key=os.environ["VERIFY_API_KEY"])
24
+
25
+ rubric = client.compile_rubric({
26
+ "name": "invoice-check",
27
+ "criteria": [
28
+ {"key": "total_present", "type": "must_have", "primitive": "regex_match@1",
29
+ "config": {"pattern": r"Total: \$[0-9]+"}},
30
+ ],
31
+ })
32
+
33
+ verdict = client.submit_verification(
34
+ rubric_id=rubric["rubric_id"],
35
+ submission={"inline": "Invoice... Total: $420"},
36
+ wait_ms=30000,
37
+ idempotency_key="invoice-001",
38
+ )
39
+ # verdict["determination"]: "met" | "partial" | "not_met" — flagged=True means needs_review:
40
+ # below the confidence threshold the engine abstains rather than asserting a verdict.
41
+
42
+ report = client.reverify(verdict["verification_id"])
43
+ # report["ok"] and report["chain_ok"] — the proof verifies against the published public key.
44
+ ```
45
+
46
+ - Verdicts below the confidence threshold are **flagged `needs_review`** — the engine abstains
47
+ instead of guessing; your application decides what happens next.
48
+ - Proofs are signed with Ed25519 and re-verifiable by any third party against the published
49
+ public key — see the [docs](https://api.acretix.io/docs) for the proof format.
50
+ - Also available: `get_verification`, `wait_for_verification`, `get_proof`, `get_usage`, `submit_feedback`.
51
+ - Usage is metered per verification by judge tier.
52
+
53
+ Standard library only (urllib). Python 3.9+.
54
+
55
+ License: MIT
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ acretix_verify.py
5
+ pyproject.toml
6
+ acretix_verify_sdk.egg-info/PKG-INFO
7
+ acretix_verify_sdk.egg-info/SOURCES.txt
8
+ acretix_verify_sdk.egg-info/dependency_links.txt
9
+ acretix_verify_sdk.egg-info/top_level.txt
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "acretix-verify-sdk"
7
+ version = "0.1.0"
8
+ description = "Python client for the AI Verify API - rubric-based verdicts with signed, re-verifiable proofs."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3",
14
+ "License :: OSI Approved :: MIT License",
15
+ ]
16
+
17
+ [project.urls]
18
+ Documentation = "https://api.acretix.io/docs"
19
+
20
+ [tool.setuptools]
21
+ py-modules = ["acretix_verify"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+