aetus 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.
aetus-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aetus
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.
aetus-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: aetus
3
+ Version: 1.0.0
4
+ Summary: Reduce your AI bill up to 78% — context compression for OpenAI and Anthropic.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://aetus.ai
7
+ Project-URL: Documentation, https://aetus.ai/docs
8
+ Project-URL: Repository, https://github.com/aetus-ai/aetus-python
9
+ Keywords: openai,anthropic,llm,compression,tokens,cost
10
+ Classifier: Programming Language :: Python :: 3
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Provides-Extra: openai
15
+ Requires-Dist: openai>=1.0; extra == "openai"
16
+ Provides-Extra: anthropic
17
+ Requires-Dist: anthropic>=0.20; extra == "anthropic"
18
+ Provides-Extra: all
19
+ Requires-Dist: openai>=1.0; extra == "all"
20
+ Requires-Dist: anthropic>=0.20; extra == "all"
21
+ Dynamic: license-file
22
+
23
+ # aetus
24
+
25
+ Python SDK for Aetus context compression.
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ pip install aetus
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ```python
36
+ from aetus import Aetus
37
+
38
+ aetus = Aetus()
39
+ result = aetus.compress(
40
+ messages,
41
+ query="What should the model answer next?",
42
+ )
43
+
44
+ print(result["compressed"])
45
+ print(result["savings_pct"])
46
+ ```
47
+
48
+ Set `AETUS_API_KEY` to a key created at
49
+ [aetus.vercel.app/dashboard/keys](https://aetus.vercel.app/dashboard/keys).
50
+
51
+ Pass `base_url` to override the hosted API.
aetus-1.0.0/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # aetus
2
+
3
+ Python SDK for Aetus context compression.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install aetus
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from aetus import Aetus
15
+
16
+ aetus = Aetus()
17
+ result = aetus.compress(
18
+ messages,
19
+ query="What should the model answer next?",
20
+ )
21
+
22
+ print(result["compressed"])
23
+ print(result["savings_pct"])
24
+ ```
25
+
26
+ Set `AETUS_API_KEY` to a key created at
27
+ [aetus.vercel.app/dashboard/keys](https://aetus.vercel.app/dashboard/keys).
28
+
29
+ Pass `base_url` to override the hosted API.
@@ -0,0 +1,198 @@
1
+ """
2
+ aetus — Python SDK for Aetus context compression.
3
+
4
+ Quickstart (proxy — zero other code changes):
5
+ from aetus import Aetus
6
+ import openai
7
+
8
+ aetus = Aetus("aet_live_...")
9
+ client = aetus.openai("sk-openai-...") # drop-in OpenAI client
10
+ # Every call is now auto-compressed. That's it.
11
+
12
+ Quickstart (direct compress):
13
+ compressed = aetus.compress(messages, query=current_message)
14
+ response = openai_client.chat.completions.create(
15
+ model="gpt-4.1",
16
+ messages=compressed["compressed"]
17
+ )
18
+
19
+ Monitoring:
20
+ stats = aetus.usage() # tokens saved, credits used, sessions
21
+ """
22
+
23
+ from __future__ import annotations
24
+
25
+ import os
26
+ import urllib.request
27
+ import urllib.error
28
+ import json
29
+ from typing import Optional
30
+
31
+
32
+ BASE_URL = "https://aetus-production.up.railway.app"
33
+
34
+
35
+ class AetusError(Exception):
36
+ def __init__(self, message: str, status_code: int = 0):
37
+ super().__init__(message)
38
+ self.status_code = status_code
39
+
40
+
41
+ class Aetus:
42
+ """
43
+ Aetus client. Instantiate once, use everywhere.
44
+
45
+ aetus = Aetus(api_key="aet_live_...")
46
+ """
47
+
48
+ def __init__(
49
+ self,
50
+ api_key: Optional[str] = None,
51
+ base_url: str = BASE_URL,
52
+ ):
53
+ self.api_key = api_key or os.environ.get("AETUS_API_KEY") or ""
54
+ self.base_url = base_url.rstrip("/")
55
+
56
+ if not self.api_key:
57
+ raise AetusError(
58
+ "No API key provided. Pass api_key= or set AETUS_API_KEY env var. "
59
+ "Get one free at aetus.ai/dashboard"
60
+ )
61
+
62
+ # ── Core: compress ────────────────────────────────────────────────────────
63
+
64
+ def compress(
65
+ self,
66
+ messages: list[dict],
67
+ query: str = "",
68
+ model: str = "gpt-4.1",
69
+ always_keep_last_n: int = 1,
70
+ recency_factor: float = 0.85,
71
+ ) -> dict:
72
+ """
73
+ Compress message history. Returns same dict shape as /compress endpoint.
74
+
75
+ compressed["compressed"] → drop-in replacement for your messages list
76
+ compressed["savings_pct"] → e.g. 91.4
77
+ compressed["tokens_saved"] → e.g. 24832
78
+ """
79
+ return self._post("/compress", {
80
+ "messages": messages,
81
+ "query": query,
82
+ "model": model,
83
+ "always_keep_last_n": always_keep_last_n,
84
+ "recency_factor": recency_factor,
85
+ })
86
+
87
+ # ── Proxy: drop-in OpenAI client ──────────────────────────────────────────
88
+
89
+ def openai(self, provider_key: Optional[str] = None) -> "object":
90
+ """
91
+ Returns an OpenAI client pre-configured to route through Aetus.
92
+ Every chat.completions.create() call is auto-compressed.
93
+
94
+ client = aetus.openai("sk-...")
95
+ resp = client.chat.completions.create(model="gpt-4.1", messages=msgs)
96
+ # resp.aetus.tokens_saved is available on the response object
97
+ """
98
+ try:
99
+ import openai as _openai
100
+ except ImportError:
101
+ raise AetusError("openai package not installed. Run: pip install openai")
102
+
103
+ pk = provider_key or os.environ.get("OPENAI_API_KEY") or ""
104
+ if not pk:
105
+ raise AetusError(
106
+ "No provider key. Pass provider_key= or set OPENAI_API_KEY env var."
107
+ )
108
+
109
+ return _openai.OpenAI(
110
+ api_key = pk,
111
+ base_url = f"{self.base_url}/v1",
112
+ default_headers = {"X-Aetus-Key": self.api_key},
113
+ )
114
+
115
+ def async_openai(self, provider_key: Optional[str] = None) -> "object":
116
+ """Async version of openai()."""
117
+ try:
118
+ import openai as _openai
119
+ except ImportError:
120
+ raise AetusError("openai package not installed. Run: pip install openai")
121
+
122
+ pk = provider_key or os.environ.get("OPENAI_API_KEY") or ""
123
+ return _openai.AsyncOpenAI(
124
+ api_key = pk,
125
+ base_url = f"{self.base_url}/v1",
126
+ default_headers = {"X-Aetus-Key": self.api_key},
127
+ )
128
+
129
+ def anthropic(self, provider_key: Optional[str] = None) -> "object":
130
+ """
131
+ Returns an Anthropic client routed through Aetus.
132
+
133
+ client = aetus.anthropic("sk-ant-...")
134
+ resp = client.messages.create(model="claude-sonnet-4-5", ...)
135
+ """
136
+ try:
137
+ import anthropic as _anthropic
138
+ except ImportError:
139
+ raise AetusError("anthropic package not installed. Run: pip install anthropic")
140
+
141
+ pk = provider_key or os.environ.get("ANTHROPIC_API_KEY") or ""
142
+ return _anthropic.Anthropic(
143
+ api_key = pk,
144
+ base_url = f"{self.base_url}/v1",
145
+ default_headers = {"X-Aetus-Key": self.api_key},
146
+ )
147
+
148
+ # ── Monitoring ────────────────────────────────────────────────────────────
149
+
150
+ def usage(self, days: int = 7) -> dict:
151
+ """Return usage stats: tokens saved, credits used, requests."""
152
+ return self._get(f"/billing/usage?days={days}")
153
+
154
+ def credits(self) -> dict:
155
+ """Return current credit balance."""
156
+ return self._get("/billing/credits")
157
+
158
+ def me(self) -> dict:
159
+ """Return org info, plan, limits."""
160
+ return self._get("/auth/me")
161
+
162
+ # ── HTTP internals ────────────────────────────────────────────────────────
163
+
164
+ def _post(self, path: str, body: dict) -> dict:
165
+ data = json.dumps(body).encode()
166
+ headers = {
167
+ "Content-Type": "application/json",
168
+ "Authorization": f"Bearer {self.api_key}",
169
+ }
170
+ req = urllib.request.Request(
171
+ f"{self.base_url}{path}", data=data, headers=headers, method="POST"
172
+ )
173
+ try:
174
+ with urllib.request.urlopen(req) as resp:
175
+ return json.loads(resp.read())
176
+ except urllib.error.HTTPError as e:
177
+ body_text = e.read().decode(errors="replace")
178
+ try:
179
+ detail = json.loads(body_text).get("detail", body_text)
180
+ except Exception:
181
+ detail = body_text
182
+ raise AetusError(detail, e.code)
183
+
184
+ def _get(self, path: str) -> dict:
185
+ headers = {"Authorization": f"Bearer {self.api_key}"}
186
+ req = urllib.request.Request(
187
+ f"{self.base_url}{path}", headers=headers, method="GET"
188
+ )
189
+ try:
190
+ with urllib.request.urlopen(req) as resp:
191
+ return json.loads(resp.read())
192
+ except urllib.error.HTTPError as e:
193
+ body_text = e.read().decode(errors="replace")
194
+ try:
195
+ detail = json.loads(body_text).get("detail", body_text)
196
+ except Exception:
197
+ detail = body_text
198
+ raise AetusError(detail, e.code)
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: aetus
3
+ Version: 1.0.0
4
+ Summary: Reduce your AI bill up to 78% — context compression for OpenAI and Anthropic.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://aetus.ai
7
+ Project-URL: Documentation, https://aetus.ai/docs
8
+ Project-URL: Repository, https://github.com/aetus-ai/aetus-python
9
+ Keywords: openai,anthropic,llm,compression,tokens,cost
10
+ Classifier: Programming Language :: Python :: 3
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Provides-Extra: openai
15
+ Requires-Dist: openai>=1.0; extra == "openai"
16
+ Provides-Extra: anthropic
17
+ Requires-Dist: anthropic>=0.20; extra == "anthropic"
18
+ Provides-Extra: all
19
+ Requires-Dist: openai>=1.0; extra == "all"
20
+ Requires-Dist: anthropic>=0.20; extra == "all"
21
+ Dynamic: license-file
22
+
23
+ # aetus
24
+
25
+ Python SDK for Aetus context compression.
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ pip install aetus
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ```python
36
+ from aetus import Aetus
37
+
38
+ aetus = Aetus()
39
+ result = aetus.compress(
40
+ messages,
41
+ query="What should the model answer next?",
42
+ )
43
+
44
+ print(result["compressed"])
45
+ print(result["savings_pct"])
46
+ ```
47
+
48
+ Set `AETUS_API_KEY` to a key created at
49
+ [aetus.vercel.app/dashboard/keys](https://aetus.vercel.app/dashboard/keys).
50
+
51
+ Pass `base_url` to override the hosted API.
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ aetus/__init__.py
5
+ aetus.egg-info/PKG-INFO
6
+ aetus.egg-info/SOURCES.txt
7
+ aetus.egg-info/dependency_links.txt
8
+ aetus.egg-info/requires.txt
9
+ aetus.egg-info/top_level.txt
@@ -0,0 +1,10 @@
1
+
2
+ [all]
3
+ openai>=1.0
4
+ anthropic>=0.20
5
+
6
+ [anthropic]
7
+ anthropic>=0.20
8
+
9
+ [openai]
10
+ openai>=1.0
@@ -0,0 +1 @@
1
+ aetus
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "aetus"
7
+ version = "1.0.0"
8
+ description = "Reduce your AI bill up to 78% — context compression for OpenAI and Anthropic."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ keywords = ["openai", "anthropic", "llm", "compression", "tokens", "cost"]
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ ]
16
+
17
+ [project.optional-dependencies]
18
+ openai = ["openai>=1.0"]
19
+ anthropic = ["anthropic>=0.20"]
20
+ all = ["openai>=1.0", "anthropic>=0.20"]
21
+
22
+ [project.urls]
23
+ Homepage = "https://aetus.ai"
24
+ Documentation = "https://aetus.ai/docs"
25
+ Repository = "https://github.com/aetus-ai/aetus-python"
aetus-1.0.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+