llmapi-tracker 1.0.2__tar.gz → 1.0.4__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 (50) hide show
  1. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/PKG-INFO +234 -234
  2. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/llmapi_tracker.egg-info/PKG-INFO +234 -234
  3. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/pyproject.toml +1 -1
  4. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/sdk/api_tracker/__init__.py +1 -1
  5. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/sdk/api_tracker/client.py +37 -49
  6. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/sdk/api_tracker/models.py +4 -4
  7. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/sdk/api_tracker/pricing.py +60 -79
  8. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/sdk/api_tracker/providers/__init__.py +7 -8
  9. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/sdk/api_tracker/providers/gemini.py +24 -7
  10. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/sdk/api_tracker/providers/openai.py +15 -4
  11. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/sdk/api_tracker/tracker.py +3 -1
  12. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/sdk/api_tracker/transport.py +3 -1
  13. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/setup.cfg +4 -4
  14. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/LICENSE +0 -0
  15. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/README.md +0 -0
  16. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/__init__.py +0 -0
  17. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/__init__.py +0 -0
  18. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/database.py +0 -0
  19. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/frontend.py +0 -0
  20. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/launcher.py +0 -0
  21. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/main.py +0 -0
  22. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/models.py +0 -0
  23. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/paths.py +0 -0
  24. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/routes/__init__.py +0 -0
  25. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/routes/analytics.py +0 -0
  26. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/routes/models.py +0 -0
  27. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/routes/pricing.py +0 -0
  28. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/routes/projects.py +0 -0
  29. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/routes/providers.py +0 -0
  30. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/routes/usage.py +0 -0
  31. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/schemas.py +0 -0
  32. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/services/__init__.py +0 -0
  33. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/services/cost_service.py +0 -0
  34. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/services/usage_service.py +0 -0
  35. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/static/assets/index-3YVy8dav.css +0 -0
  36. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/static/assets/index-jlcpybVb.js +0 -0
  37. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/backend/app/static/index.html +0 -0
  38. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/llmapi_tracker.egg-info/SOURCES.txt +0 -0
  39. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/llmapi_tracker.egg-info/dependency_links.txt +0 -0
  40. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/llmapi_tracker.egg-info/entry_points.txt +0 -0
  41. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/llmapi_tracker.egg-info/requires.txt +0 -0
  42. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/llmapi_tracker.egg-info/top_level.txt +0 -0
  43. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/sdk/api_tracker/py.typed +0 -0
  44. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/tests/test_analytics_routes.py +0 -0
  45. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/tests/test_cost_service.py +0 -0
  46. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/tests/test_paths.py +0 -0
  47. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/tests/test_provider_model_routes.py +0 -0
  48. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/tests/test_routes.py +0 -0
  49. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/tests/test_tracker.py +0 -0
  50. {llmapi_tracker-1.0.2 → llmapi_tracker-1.0.4}/tests/test_usage_service.py +0 -0
@@ -1,234 +1,234 @@
1
- Metadata-Version: 2.4
2
- Name: llmapi-tracker
3
- Version: 1.0.2
4
- Summary: Local-first API usage and cost tracking platform
5
- Author: API Tracker
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/Lns9777/API-Usage-Tracker
8
- Project-URL: Repository, https://github.com/Lns9777/API-Usage-Tracker
9
- Project-URL: Issues, https://github.com/Lns9777/API-Usage-Tracker/issues
10
- Requires-Python: >=3.10
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE
13
- Requires-Dist: requests>=2.32
14
- Requires-Dist: fastapi>=0.115
15
- Requires-Dist: uvicorn[standard]>=0.30
16
- Requires-Dist: sqlalchemy>=2.0
17
- Requires-Dist: pydantic>=2.8
18
- Provides-Extra: openai
19
- Requires-Dist: openai>=1.40; extra == "openai"
20
- Provides-Extra: gemini
21
- Requires-Dist: google-genai>=0.7; extra == "gemini"
22
- Provides-Extra: all
23
- Requires-Dist: openai>=1.40; extra == "all"
24
- Requires-Dist: google-genai>=0.7; extra == "all"
25
- Provides-Extra: dev
26
- Requires-Dist: pytest>=8.0; extra == "dev"
27
- Requires-Dist: httpx>=0.27; extra == "dev"
28
- Requires-Dist: ruff>=0.6; extra == "dev"
29
- Requires-Dist: build>=1.2; extra == "dev"
30
- Requires-Dist: twine>=5.1; extra == "dev"
31
- Dynamic: license-file
32
-
33
- # llmapi-tracker
34
-
35
- ## What API Tracker Is
36
-
37
- `llmapi-tracker` is a local-first API usage and cost observability platform for LLM applications. It records request counts, token usage, latency, errors, and versioned pricing for provider models such as OpenAI and Gemini.
38
-
39
- The project is designed 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.
40
-
41
- ## Features
42
-
43
- - Local FastAPI backend with SQLite storage
44
- - Versioned pricing records for historical cost tracking
45
- - Usage capture for input, output, thinking, cached, and total tokens
46
- - Request-level and analytics-level cost calculation
47
- - React + Vite dashboard for usage, analytics, providers, models, and pricing
48
- - SDK wrappers for OpenAI and Gemini
49
- - Packaged launcher command that starts the local app and opens the browser
50
- - Open-source repository with tests, CI, and release automation
51
-
52
- ## Installation
53
-
54
- ### Prerequisites
55
-
56
- - Python 3.10 or newer
57
- - Node.js 20 or newer for frontend development
58
-
59
- ### Local development install
60
-
61
- ```bash
62
- python -m venv .venv
63
- .venv\Scripts\activate
64
- pip install -r requirements.txt
65
- cd frontend
66
- npm install
67
- ```
68
-
69
- ### Package install
70
-
71
- ```bash
72
- pip install llmapi-tracker
73
- ```
74
-
75
- If you want optional provider SDK support:
76
-
77
- ```bash
78
- pip install "llmapi-tracker[openai]"
79
- pip install "llmapi-tracker[gemini]"
80
- pip install "llmapi-tracker[all]"
81
- ```
82
-
83
- ## Starting the Application
84
-
85
- ### Backend only
86
-
87
- ```bash
88
- uvicorn backend.app.main:app --reload
89
- ```
90
-
91
- ### Frontend only
92
-
93
- ```bash
94
- cd frontend
95
- npm run dev
96
- ```
97
-
98
- ### Packaged app
99
-
100
- After the frontend assets are built and packaged into the backend static directory:
101
-
102
- ```bash
103
- api-tracker
104
- ```
105
-
106
- The launcher starts the backend server and opens the browser to the local dashboard.
107
-
108
- ## SDK Usage
109
-
110
- ### Initialize the SDK
111
-
112
- ```python
113
- import os
114
- from api_tracker import APITracker
115
-
116
- tracker = APITracker(
117
- project="Pharmacy-AI",
118
- backend_url=os.getenv("TRACKER_BACKEND_URL", "http://localhost:8000"),
119
- openai_api_key=os.getenv("OPENAI_API_KEY"),
120
- gemini_api_key=os.getenv("GEMINI_API_KEY"),
121
- )
122
- ```
123
-
124
- ### OpenAI
125
-
126
- ```python
127
- response = tracker.openai.chat(
128
- model="gpt-5",
129
- messages=[{"role": "user", "content": "Analyze this prescription"}],
130
- )
131
- ```
132
-
133
- ### Gemini
134
-
135
- ```python
136
- response = tracker.gemini.generate(
137
- model="gemini-2.5-flash",
138
- contents="Analyze this prescription",
139
- )
140
- ```
141
-
142
- The SDK reads usage metadata from the provider response and sends it to the local backend automatically.
143
-
144
- ## Database Location
145
-
146
- By default, the SQLite database is stored in a stable user data directory so it survives uninstall and reinstall.
147
-
148
- The path is resolved in this order:
149
-
150
- 1. `API_TRACKER_DB_PATH` if set
151
- 2. `DATABASE_URL` if set
152
- 3. A user-data location based on the operating system
153
-
154
- Typical defaults:
155
-
156
- - Windows: `%LOCALAPPDATA%\\APITracker\\api_tracker.db`
157
- - macOS/Linux: `~/.local/share/APITracker/api_tracker.db`
158
-
159
- 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.
160
-
161
- ## Configuration
162
-
163
- Environment variables:
164
-
165
- ```bash
166
- DATABASE_URL=sqlite:///./api_tracker.db
167
- API_TRACKER_DATA_DIR=
168
- API_TRACKER_DB_PATH=
169
- API_TRACKER_HOST=127.0.0.1
170
- API_TRACKER_PORT=8000
171
- API_TRACKER_OPEN_BROWSER=true
172
- OPENAI_API_KEY=
173
- GEMINI_API_KEY=
174
- TRACKER_BACKEND_URL=http://localhost:8000
175
- VITE_API_BASE_URL=http://localhost:8000
176
- ```
177
-
178
- Notes:
179
-
180
- - `DATABASE_URL` overrides the database connection string
181
- - `API_TRACKER_DATA_DIR` sets the user-data root used for SQLite storage
182
- - `API_TRACKER_DB_PATH` points directly to a specific SQLite file
183
- - `API_TRACKER_OPEN_BROWSER=false` disables browser auto-open for the launcher
184
-
185
- ## Development Setup
186
-
187
- ### Backend
188
-
189
- ```bash
190
- python -m compileall backend sdk tests
191
- pytest -q
192
- ```
193
-
194
- ### Frontend
195
-
196
- ```bash
197
- cd frontend
198
- npm run build
199
- ```
200
-
201
- ### Packaging assets
202
-
203
- ```bash
204
- cd frontend
205
- npm run build
206
- cd ..
207
- python scripts/package_frontend_assets.py
208
- python scripts/verify_frontend_assets.py
209
- ```
210
-
211
- ## Contributing
212
-
213
- `llmapi-tracker` is intended to be open source and contributor friendly.
214
-
215
- Contribution files:
216
-
217
- - [`CONTRIBUTING.md`](L:/Personal/APITracker/CONTRIBUTING.md)
218
- - [`CODE_OF_CONDUCT.md`](L:/Personal/APITracker/CODE_OF_CONDUCT.md)
219
- - [`SECURITY.md`](L:/Personal/APITracker/SECURITY.md)
220
- - [`CHANGELOG.md`](L:/Personal/APITracker/CHANGELOG.md)
221
- - [`LICENSE`](L:/Personal/APITracker/LICENSE)
222
-
223
- Contribution expectations:
224
-
225
- - Open changes through pull requests
226
- - Require review before merge
227
- - Keep the app local-first
228
- - Avoid storing prompts, responses, or raw API keys
229
- - Add tests for behavior changes
230
-
231
- ## License
232
-
233
- `llmapi-tracker` is released under the MIT License. See [`LICENSE`](L:/Personal/APITracker/LICENSE).
234
-
1
+ Metadata-Version: 2.4
2
+ Name: llmapi-tracker
3
+ Version: 1.0.4
4
+ Summary: Local-first API usage and cost tracking platform
5
+ Author: API Tracker
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Lns9777/API-Usage-Tracker
8
+ Project-URL: Repository, https://github.com/Lns9777/API-Usage-Tracker
9
+ Project-URL: Issues, https://github.com/Lns9777/API-Usage-Tracker/issues
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: requests>=2.32
14
+ Requires-Dist: fastapi>=0.115
15
+ Requires-Dist: uvicorn[standard]>=0.30
16
+ Requires-Dist: sqlalchemy>=2.0
17
+ Requires-Dist: pydantic>=2.8
18
+ Provides-Extra: openai
19
+ Requires-Dist: openai>=1.40; extra == "openai"
20
+ Provides-Extra: gemini
21
+ Requires-Dist: google-genai>=0.7; extra == "gemini"
22
+ Provides-Extra: all
23
+ Requires-Dist: openai>=1.40; extra == "all"
24
+ Requires-Dist: google-genai>=0.7; extra == "all"
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8.0; extra == "dev"
27
+ Requires-Dist: httpx>=0.27; extra == "dev"
28
+ Requires-Dist: ruff>=0.6; extra == "dev"
29
+ Requires-Dist: build>=1.2; extra == "dev"
30
+ Requires-Dist: twine>=5.1; extra == "dev"
31
+ Dynamic: license-file
32
+
33
+ # llmapi-tracker
34
+
35
+ ## What API Tracker Is
36
+
37
+ `llmapi-tracker` is a local-first API usage and cost observability platform for LLM applications. It records request counts, token usage, latency, errors, and versioned pricing for provider models such as OpenAI and Gemini.
38
+
39
+ The project is designed 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.
40
+
41
+ ## Features
42
+
43
+ - Local FastAPI backend with SQLite storage
44
+ - Versioned pricing records for historical cost tracking
45
+ - Usage capture for input, output, thinking, cached, and total tokens
46
+ - Request-level and analytics-level cost calculation
47
+ - React + Vite dashboard for usage, analytics, providers, models, and pricing
48
+ - SDK wrappers for OpenAI and Gemini
49
+ - Packaged launcher command that starts the local app and opens the browser
50
+ - Open-source repository with tests, CI, and release automation
51
+
52
+ ## Installation
53
+
54
+ ### Prerequisites
55
+
56
+ - Python 3.10 or newer
57
+ - Node.js 20 or newer for frontend development
58
+
59
+ ### Local development install
60
+
61
+ ```bash
62
+ python -m venv .venv
63
+ .venv\Scripts\activate
64
+ pip install -r requirements.txt
65
+ cd frontend
66
+ npm install
67
+ ```
68
+
69
+ ### Package install
70
+
71
+ ```bash
72
+ pip install llmapi-tracker
73
+ ```
74
+
75
+ If you want optional provider SDK support:
76
+
77
+ ```bash
78
+ pip install "llmapi-tracker[openai]"
79
+ pip install "llmapi-tracker[gemini]"
80
+ pip install "llmapi-tracker[all]"
81
+ ```
82
+
83
+ ## Starting the Application
84
+
85
+ ### Backend only
86
+
87
+ ```bash
88
+ uvicorn backend.app.main:app --reload
89
+ ```
90
+
91
+ ### Frontend only
92
+
93
+ ```bash
94
+ cd frontend
95
+ npm run dev
96
+ ```
97
+
98
+ ### Packaged app
99
+
100
+ After the frontend assets are built and packaged into the backend static directory:
101
+
102
+ ```bash
103
+ api-tracker
104
+ ```
105
+
106
+ The launcher starts the backend server and opens the browser to the local dashboard.
107
+
108
+ ## SDK Usage
109
+
110
+ ### Initialize the SDK
111
+
112
+ ```python
113
+ import os
114
+ from api_tracker import APITracker
115
+
116
+ tracker = APITracker(
117
+ project="Pharmacy-AI",
118
+ backend_url=os.getenv("TRACKER_BACKEND_URL", "http://localhost:8000"),
119
+ openai_api_key=os.getenv("OPENAI_API_KEY"),
120
+ gemini_api_key=os.getenv("GEMINI_API_KEY"),
121
+ )
122
+ ```
123
+
124
+ ### OpenAI
125
+
126
+ ```python
127
+ response = tracker.openai.chat(
128
+ model="gpt-5",
129
+ messages=[{"role": "user", "content": "Analyze this prescription"}],
130
+ )
131
+ ```
132
+
133
+ ### Gemini
134
+
135
+ ```python
136
+ response = tracker.gemini.generate(
137
+ model="gemini-2.5-flash",
138
+ contents="Analyze this prescription",
139
+ )
140
+ ```
141
+
142
+ The SDK reads usage metadata from the provider response and sends it to the local backend automatically.
143
+
144
+ ## Database Location
145
+
146
+ By default, the SQLite database is stored in a stable user data directory so it survives uninstall and reinstall.
147
+
148
+ The path is resolved in this order:
149
+
150
+ 1. `API_TRACKER_DB_PATH` if set
151
+ 2. `DATABASE_URL` if set
152
+ 3. A user-data location based on the operating system
153
+
154
+ Typical defaults:
155
+
156
+ - Windows: `%LOCALAPPDATA%\\APITracker\\api_tracker.db`
157
+ - macOS/Linux: `~/.local/share/APITracker/api_tracker.db`
158
+
159
+ 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.
160
+
161
+ ## Configuration
162
+
163
+ Environment variables:
164
+
165
+ ```bash
166
+ DATABASE_URL=sqlite:///./api_tracker.db
167
+ API_TRACKER_DATA_DIR=
168
+ API_TRACKER_DB_PATH=
169
+ API_TRACKER_HOST=127.0.0.1
170
+ API_TRACKER_PORT=8000
171
+ API_TRACKER_OPEN_BROWSER=true
172
+ OPENAI_API_KEY=
173
+ GEMINI_API_KEY=
174
+ TRACKER_BACKEND_URL=http://localhost:8000
175
+ VITE_API_BASE_URL=http://localhost:8000
176
+ ```
177
+
178
+ Notes:
179
+
180
+ - `DATABASE_URL` overrides the database connection string
181
+ - `API_TRACKER_DATA_DIR` sets the user-data root used for SQLite storage
182
+ - `API_TRACKER_DB_PATH` points directly to a specific SQLite file
183
+ - `API_TRACKER_OPEN_BROWSER=false` disables browser auto-open for the launcher
184
+
185
+ ## Development Setup
186
+
187
+ ### Backend
188
+
189
+ ```bash
190
+ python -m compileall backend sdk tests
191
+ pytest -q
192
+ ```
193
+
194
+ ### Frontend
195
+
196
+ ```bash
197
+ cd frontend
198
+ npm run build
199
+ ```
200
+
201
+ ### Packaging assets
202
+
203
+ ```bash
204
+ cd frontend
205
+ npm run build
206
+ cd ..
207
+ python scripts/package_frontend_assets.py
208
+ python scripts/verify_frontend_assets.py
209
+ ```
210
+
211
+ ## Contributing
212
+
213
+ `llmapi-tracker` is intended to be open source and contributor friendly.
214
+
215
+ Contribution files:
216
+
217
+ - [`CONTRIBUTING.md`](L:/Personal/APITracker/CONTRIBUTING.md)
218
+ - [`CODE_OF_CONDUCT.md`](L:/Personal/APITracker/CODE_OF_CONDUCT.md)
219
+ - [`SECURITY.md`](L:/Personal/APITracker/SECURITY.md)
220
+ - [`CHANGELOG.md`](L:/Personal/APITracker/CHANGELOG.md)
221
+ - [`LICENSE`](L:/Personal/APITracker/LICENSE)
222
+
223
+ Contribution expectations:
224
+
225
+ - Open changes through pull requests
226
+ - Require review before merge
227
+ - Keep the app local-first
228
+ - Avoid storing prompts, responses, or raw API keys
229
+ - Add tests for behavior changes
230
+
231
+ ## License
232
+
233
+ `llmapi-tracker` is released under the MIT License. See [`LICENSE`](L:/Personal/APITracker/LICENSE).
234
+