llmapi-tracker 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,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>API Tracker</title>
7
+ <script type="module" crossorigin src="/assets/index-jlcpybVb.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-3YVy8dav.css">
9
+ </head>
10
+ <body>
11
+ <div id="root"></div>
12
+ </body>
13
+ </html>
@@ -0,0 +1,225 @@
1
+ Metadata-Version: 2.4
2
+ Name: llmapi-tracker
3
+ Version: 1.0.0
4
+ Summary: Local-first API usage and cost tracking platform
5
+ Author: API Tracker
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: requests>=2.32
11
+ Requires-Dist: fastapi>=0.115
12
+ Requires-Dist: uvicorn[standard]>=0.30
13
+ Requires-Dist: sqlalchemy>=2.0
14
+ Requires-Dist: pydantic>=2.8
15
+ Provides-Extra: openai
16
+ Requires-Dist: openai>=1.40; extra == "openai"
17
+ Provides-Extra: gemini
18
+ Requires-Dist: google-genai>=0.7; extra == "gemini"
19
+ Provides-Extra: all
20
+ Requires-Dist: openai>=1.40; extra == "all"
21
+ Requires-Dist: google-genai>=0.7; extra == "all"
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=8.0; extra == "dev"
24
+ Requires-Dist: httpx>=0.27; extra == "dev"
25
+ Requires-Dist: ruff>=0.6; extra == "dev"
26
+ Requires-Dist: build>=1.2; extra == "dev"
27
+ Requires-Dist: twine>=5.1; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ # API Tracker
31
+
32
+ ## What API Tracker Is
33
+
34
+ API Tracker is a local-first API usage and cost observability tool. It records request volume, token usage, latency, status, and versioned pricing for models from providers such as OpenAI and Gemini.
35
+
36
+ The project is built to keep data local by default. It stores usage and pricing in a local SQLite database and does not persist prompts, responses, or raw API keys in the application database.
37
+
38
+ ## Features
39
+
40
+ - Local FastAPI backend with SQLite storage
41
+ - Versioned pricing records for historical cost tracking
42
+ - Usage capture for input, output, thinking, cached, and total tokens
43
+ - Cost calculation per request and across analytics views
44
+ - React + Vite dashboard for usage, analytics, providers, models, and pricing
45
+ - SDK wrappers for OpenAI and Gemini
46
+ - Packaged launcher command that starts the local app and opens the browser
47
+ - Open-source repository setup with tests, CI, and release automation
48
+
49
+ ## Installation
50
+
51
+ ### Prerequisites
52
+
53
+ - Python 3.10 or newer
54
+ - Node.js 20 or newer for frontend development
55
+
56
+ ### Local development install
57
+
58
+ ```bash
59
+ python -m venv .venv
60
+ .venv\Scripts\activate
61
+ pip install -r requirements.txt
62
+ cd frontend
63
+ npm install
64
+ ```
65
+
66
+ ### Package install
67
+
68
+ If you install this project as a package, the launcher command is:
69
+
70
+ ```bash
71
+ api-tracker
72
+ ```
73
+
74
+ ## Starting the Application
75
+
76
+ ### Backend only
77
+
78
+ ```bash
79
+ uvicorn backend.app.main:app --reload
80
+ ```
81
+
82
+ ### Frontend only
83
+
84
+ ```bash
85
+ cd frontend
86
+ npm run dev
87
+ ```
88
+
89
+ ### Packaged app
90
+
91
+ After building the frontend assets and packaging them into the backend static directory, run:
92
+
93
+ ```bash
94
+ api-tracker
95
+ ```
96
+
97
+ The launcher starts the backend server and opens the browser to the local dashboard.
98
+
99
+ ## SDK Usage
100
+
101
+ ### Initialize the SDK
102
+
103
+ ```python
104
+ import os
105
+ from sdk.api_tracker import APITracker
106
+
107
+ tracker = APITracker(
108
+ project="Pharmacy-AI",
109
+ backend_url=os.getenv("TRACKER_BACKEND_URL", "http://localhost:8000"),
110
+ openai_api_key=os.getenv("OPENAI_API_KEY"),
111
+ gemini_api_key=os.getenv("GEMINI_API_KEY"),
112
+ )
113
+ ```
114
+
115
+ ### OpenAI
116
+
117
+ ```python
118
+ response = tracker.openai.chat(
119
+ model="gpt-5",
120
+ messages=[{"role": "user", "content": "Analyze this prescription"}],
121
+ )
122
+ ```
123
+
124
+ ### Gemini
125
+
126
+ ```python
127
+ response = tracker.gemini.generate(
128
+ model="gemini-2.5-flash",
129
+ contents="Analyze this prescription",
130
+ )
131
+ ```
132
+
133
+ The SDK reads usage metadata from the provider response and sends it to the local backend automatically.
134
+
135
+ ## Database Location
136
+
137
+ By default, the SQLite database is stored in a stable user data directory so it survives uninstall and reinstall.
138
+
139
+ The path is resolved in this order:
140
+
141
+ 1. `API_TRACKER_DB_PATH` if set
142
+ 2. `DATABASE_URL` if set
143
+ 3. A user-data location based on the operating system
144
+
145
+ Typical defaults:
146
+
147
+ - Windows: `%LOCALAPPDATA%\\APITracker\\api_tracker.db`
148
+ - macOS/Linux: `~/.local/share/APITracker/api_tracker.db`
149
+
150
+ If the preferred user-data directory cannot be created, the app falls back to a writable local `.api-tracker-data/` directory in the current workspace.
151
+
152
+ ## Configuration
153
+
154
+ Environment variables:
155
+
156
+ ```bash
157
+ DATABASE_URL=sqlite:///./api_tracker.db
158
+ API_TRACKER_DATA_DIR=
159
+ API_TRACKER_DB_PATH=
160
+ API_TRACKER_HOST=127.0.0.1
161
+ API_TRACKER_PORT=8000
162
+ API_TRACKER_OPEN_BROWSER=true
163
+ OPENAI_API_KEY=
164
+ GEMINI_API_KEY=
165
+ TRACKER_BACKEND_URL=http://localhost:8000
166
+ VITE_API_BASE_URL=http://localhost:8000
167
+ ```
168
+
169
+ Notes:
170
+
171
+ - `DATABASE_URL` overrides the database connection string
172
+ - `API_TRACKER_DATA_DIR` sets the user-data root used for SQLite storage
173
+ - `API_TRACKER_DB_PATH` points directly to a specific SQLite file
174
+ - `API_TRACKER_OPEN_BROWSER=false` disables browser auto-open for the launcher
175
+
176
+ ## Development Setup
177
+
178
+ ### Backend
179
+
180
+ ```bash
181
+ python -m compileall backend sdk tests
182
+ pytest -q
183
+ ```
184
+
185
+ ### Frontend
186
+
187
+ ```bash
188
+ cd frontend
189
+ npm run build
190
+ ```
191
+
192
+ ### Packaging assets
193
+
194
+ ```bash
195
+ cd frontend
196
+ npm run build
197
+ cd ..
198
+ python scripts/package_frontend_assets.py
199
+ python scripts/verify_frontend_assets.py
200
+ ```
201
+
202
+ ## Contributing
203
+
204
+ This repository is intended to be open source and contributor friendly.
205
+
206
+ Contribution files:
207
+
208
+ - [`CONTRIBUTING.md`](L:/Personal/APITracker/CONTRIBUTING.md)
209
+ - [`CODE_OF_CONDUCT.md`](L:/Personal/APITracker/CODE_OF_CONDUCT.md)
210
+ - [`SECURITY.md`](L:/Personal/APITracker/SECURITY.md)
211
+ - [`CHANGELOG.md`](L:/Personal/APITracker/CHANGELOG.md)
212
+ - [`LICENSE`](L:/Personal/APITracker/LICENSE)
213
+
214
+ Contribution expectations:
215
+
216
+ - Open changes through pull requests
217
+ - Require review before merge
218
+ - Keep the app local-first
219
+ - Avoid storing prompts, responses, or raw API keys
220
+ - Add tests for behavior changes
221
+
222
+ ## License
223
+
224
+ API Tracker is released under the MIT License. See [`LICENSE`](L:/Personal/APITracker/LICENSE).
225
+
@@ -0,0 +1,38 @@
1
+ api_tracker/__init__.py,sha256=fztTpIXeSDMK1-QazrDvVYb0wkKcygk7bdhA6Mk4hew,179
2
+ api_tracker/client.py,sha256=s2LrRyRXanCIb8MzrvftpqWvJzQvgX2lLIe2BQDowkc,902
3
+ api_tracker/models.py,sha256=CbE8c51jIsICH5KhsvHoQmCG6V432tqhmIHOrQeLTZ4,789
4
+ api_tracker/pricing.py,sha256=ZgKphx-GntY3j6xaGJGbcWXm5aF9OFvegjipiSAOIj8,1522
5
+ api_tracker/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
6
+ api_tracker/tracker.py,sha256=qUyz8UAWaP7hGj-vKJdzmPL2nIAU-KIlFwtJeFVeR0A,1865
7
+ api_tracker/transport.py,sha256=1MAH7dBYNeIfUi4kKTpduzC9V-HhXFHgJyHb4Px3tqc,784
8
+ api_tracker/providers/__init__.py,sha256=yy8nMA1N1m4WZ0C4gGLt7V-TWbN8U5KEwY0GS-X1_rc,132
9
+ api_tracker/providers/gemini.py,sha256=1rgtAwWcdJy0YteyeMuwmWWnn6VjUsTnOT1qw59UMMw,1628
10
+ api_tracker/providers/openai.py,sha256=k46gt0xlRvj7FUHr1QJ-XkxpSS3WXdmSLKg0DP0a8qg,1584
11
+ backend/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
12
+ backend/app/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
13
+ backend/app/database.py,sha256=C9yhEByWHwqEN7DghbBFJYzenwNUKhaVFisqJTAGJG4,595
14
+ backend/app/frontend.py,sha256=cmiD7yvqmZTdQ9umapXAd2sgFgjXV8kCNG03dLDuaAc,901
15
+ backend/app/launcher.py,sha256=E5M2YYlVK-WyFaFp9woNay1d6hzL2q--ZAVJ6bnJN_I,536
16
+ backend/app/main.py,sha256=NPH1fHu6IbcWDBXArDQbRPTBuHmPcYQ_SNwzIBrOv9U,1524
17
+ backend/app/models.py,sha256=U7ON2GTajfbdYNVxCnrjyls6HEnwnsQDJIkX7Mo4GJQ,4825
18
+ backend/app/paths.py,sha256=5gIKCC4ixaZ4oThlmJNg7IMs8Rr9tiEtoBNylS15f_Q,1617
19
+ backend/app/schemas.py,sha256=0ZXb3L90uJZAQu9XqSMQbvWQHrJyW7RMcwWEPvcY22s,3123
20
+ backend/app/routes/__init__.py,sha256=jjSfbS4hkByEa5U4Ax2TL-xTOu3RtxHe7mJo0bJ5aYo,69
21
+ backend/app/routes/analytics.py,sha256=pmgB3xhqrh_wik7NfHgjMwkcdBnyrkHEAAgCAxrqsfQ,3884
22
+ backend/app/routes/models.py,sha256=oU-JNWsgps-ThNXDJYEw7CzblVjJQtfV8r5ReHNZB3M,820
23
+ backend/app/routes/pricing.py,sha256=tsf7R1W7LQw6FXhvA1ElRQi7rRvEB5CGENaYz-re6Hg,1520
24
+ backend/app/routes/projects.py,sha256=Q9hojYTVnPgWT1QePwmPylJZCz54J-xxrPip30shYtY,1899
25
+ backend/app/routes/providers.py,sha256=aQ6hnyzRA-EVjoRxg1Y0GnSFTKFq1nLWuDYIaK7r_Vg,772
26
+ backend/app/routes/usage.py,sha256=ZaQ1HVSDYcjP0nkVmSMEwZOM_UtHISpuZ1H9JytBLFk,972
27
+ backend/app/services/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
28
+ backend/app/services/cost_service.py,sha256=GD8d8FbUX_eeCGMo6UU1OLsn0kLr-dZa9-cLvPy57u8,1041
29
+ backend/app/services/usage_service.py,sha256=iFRNTuVuz11gBQUliGG6q0SQQ3wY9TG83ycBgu2LJUA,4273
30
+ backend/app/static/index.html,sha256=Pw6elIGAHhgPJkdiSN0RWzvaZOY7PibQwYHlQgSpxaM,396
31
+ backend/app/static/assets/index-3YVy8dav.css,sha256=gJnRjHH4LORyhhv0B90nVnn6Wjyl24wP8pb5qyPVdE4,6085
32
+ backend/app/static/assets/index-jlcpybVb.js,sha256=YT-ymP2ps_B2h5nkrVe864a4SGeP7rz8Z7bhkomY2eY,288914
33
+ llmapi_tracker-1.0.0.dist-info/licenses/LICENSE,sha256=zyJy1QhELa2cDPrRMG_QKs1Jt2c1LsCYbFHKji_SfV8,1081
34
+ llmapi_tracker-1.0.0.dist-info/METADATA,sha256=_398kzUAet43Ylmg_mNO57QMgjtnOFMqV9u-Ord_--I,5737
35
+ llmapi_tracker-1.0.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
36
+ llmapi_tracker-1.0.0.dist-info/entry_points.txt,sha256=TQwWQNj3F4Bdg6aVhfSI9UVgvUUY4ipJ4YTpMGsx3dk,64
37
+ llmapi_tracker-1.0.0.dist-info/top_level.txt,sha256=9zVP1897FXZEdCmec-fJYXHFGiqy2bBLEpNwKzXhrqE,20
38
+ llmapi_tracker-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ api-tracker = backend.app.launcher:launch_app
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 API Tracker contributors
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,2 @@
1
+ api_tracker
2
+ backend