kalaa 1.0.0__py3-none-any.whl

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,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: kalaa
3
+ Version: 1.0.0
4
+ Summary: Drop-in AI cost tracking for Python. Auto-instruments OpenAI, Anthropic, and Gemini with zero code at the call site.
5
+ License: MIT
6
+ Project-URL: Homepage, https://kalaa.cc
7
+ Project-URL: Repository, https://github.com/YOUR_ORG/kalaa-python
8
+ Keywords: ai,llm,cost-tracking,openai,anthropic,gemini,observability,monitoring,flask,fastapi
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: requests>=2.28
13
+ Requires-Dist: mutagen>=1.47
14
+ Provides-Extra: openai
15
+ Requires-Dist: openai>=1.0; extra == "openai"
16
+ Provides-Extra: anthropic
17
+ Requires-Dist: anthropic>=0.25; extra == "anthropic"
18
+ Provides-Extra: gemini
19
+ Requires-Dist: google-genai>=1.0; extra == "gemini"
20
+ Dynamic: license-file
21
+
22
+ # kalaa
23
+
24
+ Drop-in AI cost tracking for Python. Patches the OpenAI, Anthropic, and
25
+ Gemini client libraries at the class level, so every client you create —
26
+ before or after `observe()`, sync or async — is already instrumented.
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ pip install kalaa
32
+ ```
33
+
34
+ ## Setup
35
+
36
+ ```python
37
+ import kalaa
38
+ kalaa.observe()
39
+ app = kalaa.init_app(app) # auto-detects Flask vs. FastAPI
40
+ ```
41
+
42
+ That's it. Put `KALAA_KEY=cm_live_xxx` in your environment and every
43
+ OpenAI, Anthropic, and Gemini call your app makes from here on is tracked
44
+ automatically — including the user who made the request, with zero extra
45
+ code, if you're running Flask or FastAPI.
46
+
47
+ If `init_app` doesn't recognize your setup, wire the right middleware
48
+ directly:
49
+
50
+ ```python
51
+ # Flask / any WSGI app:
52
+ app.wsgi_app = kalaa.wsgi_middleware(app.wsgi_app)
53
+
54
+ # FastAPI / Starlette / any ASGI app:
55
+ app = kalaa.asgi_middleware(app)
56
+ ```
57
+
58
+ ## Tagging a user manually
59
+
60
+ Automatic detection covers most setups (reads `X-User-Id`, a decoded JWT,
61
+ or a client-side anonymous id). If yours doesn't fit that shape:
62
+
63
+ ```python
64
+ kalaa.set_user(current_user.id)
65
+ ```
66
+
67
+ ## Background jobs / cron
68
+
69
+ No request to hang a route off of, so give it a label instead:
70
+
71
+ ```python
72
+ with kalaa.with_context("nightly-digest"):
73
+ run_the_job()
74
+ ```
75
+
76
+ ## What's tracked automatically
77
+
78
+ - OpenAI: chat completions, sync and async, including streaming
79
+ - Anthropic: messages, sync and async, including streaming
80
+ - Gemini: `generate_content`, sync and async (via the current `google.genai`
81
+ package — the older `google.generativeai` package is deprecated and not
82
+ supported)
83
+ - Whisper/audio transcription duration, read from the file itself and
84
+ parsed in an isolated subprocess with a timeout — a malformed file can
85
+ never hang your app, only cost a few seconds and an unmeasured duration
86
+
87
+ ## Configuration
88
+
89
+ | Option | Env var | Default |
90
+ |---|---|---|
91
+ | `key` | `KALAA_KEY` | — |
92
+ | `endpoint` | `KALAA_ENDPOINT` | `https://api.kalaa.cc/api/ingest` |
93
+ | `env` | `KALAA_ENV` | `production` |
94
+ | `debug` | `KALAA_DEBUG=1` | `false` |
95
+
96
+ ## Failure behavior
97
+
98
+ This package never touches a database and never sits in the path of your
99
+ AI calls. If the ingest endpoint is unreachable, events are buffered and
100
+ retried on the next flush cycle — your app is never blocked or crashed by
101
+ a tracking failure.
102
+
103
+ ## License
104
+
105
+ MIT
@@ -0,0 +1,5 @@
1
+ kalaa-1.0.0.dist-info/licenses/LICENSE,sha256=mqXvA9uBFpXf4Wke2Ciuo0eyVShpYMl1oRaRCQJexPw,1074
2
+ kalaa-1.0.0.dist-info/METADATA,sha256=pS6TZdRMSLFfXYH6Mh24aMPKz5odHLneLaMUCZQ7cuc,3116
3
+ kalaa-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
4
+ kalaa-1.0.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
5
+ kalaa-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Francois Ssennoga
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
+