llmapi-tracker 1.0.0__tar.gz → 1.0.3__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 (53) hide show
  1. {llmapi_tracker-1.0.0/llmapi_tracker.egg-info → llmapi_tracker-1.0.3}/PKG-INFO +234 -225
  2. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/README.md +17 -11
  3. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/database.py +0 -2
  4. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/frontend.py +5 -3
  5. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/launcher.py +5 -1
  6. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/main.py +0 -2
  7. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/models.py +18 -7
  8. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/paths.py +0 -1
  9. llmapi_tracker-1.0.3/backend/app/routes/__init__.py +0 -0
  10. llmapi_tracker-1.0.3/backend/app/routes/analytics.py +171 -0
  11. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/routes/models.py +4 -1
  12. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/routes/pricing.py +3 -1
  13. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/routes/projects.py +3 -1
  14. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/routes/usage.py +1 -1
  15. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/schemas.py +19 -19
  16. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/services/usage_service.py +10 -4
  17. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3/llmapi_tracker.egg-info}/PKG-INFO +234 -225
  18. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/llmapi_tracker.egg-info/SOURCES.txt +0 -4
  19. llmapi_tracker-1.0.3/pyproject.toml +83 -0
  20. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/sdk/api_tracker/client.py +48 -48
  21. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/sdk/api_tracker/pricing.py +78 -78
  22. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/sdk/api_tracker/providers/__init__.py +7 -7
  23. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/setup.cfg +4 -4
  24. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/tests/test_analytics_routes.py +0 -2
  25. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/tests/test_paths.py +4 -3
  26. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/tests/test_routes.py +16 -6
  27. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/tests/test_tracker.py +3 -1
  28. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/tests/test_usage_service.py +17 -7
  29. llmapi_tracker-1.0.0/backend/app/routes/__init__.py +0 -1
  30. llmapi_tracker-1.0.0/backend/app/routes/analytics.py +0 -91
  31. llmapi_tracker-1.0.0/backend/app/static/assets/index-3YVy8dav.css +0 -1
  32. llmapi_tracker-1.0.0/backend/app/static/assets/index-jlcpybVb.js +0 -75
  33. llmapi_tracker-1.0.0/backend/app/static/index.html +0 -13
  34. llmapi_tracker-1.0.0/pyproject.toml +0 -45
  35. llmapi_tracker-1.0.0/sdk/api_tracker/py.typed +0 -1
  36. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/LICENSE +0 -0
  37. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/__init__.py +0 -0
  38. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/__init__.py +0 -0
  39. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/routes/providers.py +0 -0
  40. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/services/__init__.py +0 -0
  41. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/backend/app/services/cost_service.py +0 -0
  42. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/llmapi_tracker.egg-info/dependency_links.txt +0 -0
  43. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/llmapi_tracker.egg-info/entry_points.txt +0 -0
  44. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/llmapi_tracker.egg-info/requires.txt +0 -0
  45. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/llmapi_tracker.egg-info/top_level.txt +0 -0
  46. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/sdk/api_tracker/__init__.py +0 -0
  47. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/sdk/api_tracker/models.py +0 -0
  48. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/sdk/api_tracker/providers/gemini.py +0 -0
  49. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/sdk/api_tracker/providers/openai.py +0 -0
  50. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/sdk/api_tracker/tracker.py +0 -0
  51. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/sdk/api_tracker/transport.py +0 -0
  52. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/tests/test_cost_service.py +0 -0
  53. {llmapi_tracker-1.0.0 → llmapi_tracker-1.0.3}/tests/test_provider_model_routes.py +0 -0
@@ -1,225 +1,234 @@
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
-
1
+ Metadata-Version: 2.4
2
+ Name: llmapi-tracker
3
+ Version: 1.0.3
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,21 +1,21 @@
1
- # API Tracker
1
+ # llmapi-tracker
2
2
 
3
3
  ## What API Tracker Is
4
4
 
5
- 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.
5
+ `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.
6
6
 
7
- 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.
7
+ 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.
8
8
 
9
9
  ## Features
10
10
 
11
11
  - Local FastAPI backend with SQLite storage
12
12
  - Versioned pricing records for historical cost tracking
13
13
  - Usage capture for input, output, thinking, cached, and total tokens
14
- - Cost calculation per request and across analytics views
14
+ - Request-level and analytics-level cost calculation
15
15
  - React + Vite dashboard for usage, analytics, providers, models, and pricing
16
16
  - SDK wrappers for OpenAI and Gemini
17
17
  - Packaged launcher command that starts the local app and opens the browser
18
- - Open-source repository setup with tests, CI, and release automation
18
+ - Open-source repository with tests, CI, and release automation
19
19
 
20
20
  ## Installation
21
21
 
@@ -36,10 +36,16 @@ npm install
36
36
 
37
37
  ### Package install
38
38
 
39
- If you install this project as a package, the launcher command is:
39
+ ```bash
40
+ pip install llmapi-tracker
41
+ ```
42
+
43
+ If you want optional provider SDK support:
40
44
 
41
45
  ```bash
42
- api-tracker
46
+ pip install "llmapi-tracker[openai]"
47
+ pip install "llmapi-tracker[gemini]"
48
+ pip install "llmapi-tracker[all]"
43
49
  ```
44
50
 
45
51
  ## Starting the Application
@@ -59,7 +65,7 @@ npm run dev
59
65
 
60
66
  ### Packaged app
61
67
 
62
- After building the frontend assets and packaging them into the backend static directory, run:
68
+ After the frontend assets are built and packaged into the backend static directory:
63
69
 
64
70
  ```bash
65
71
  api-tracker
@@ -73,7 +79,7 @@ The launcher starts the backend server and opens the browser to the local dashbo
73
79
 
74
80
  ```python
75
81
  import os
76
- from sdk.api_tracker import APITracker
82
+ from api_tracker import APITracker
77
83
 
78
84
  tracker = APITracker(
79
85
  project="Pharmacy-AI",
@@ -172,7 +178,7 @@ python scripts/verify_frontend_assets.py
172
178
 
173
179
  ## Contributing
174
180
 
175
- This repository is intended to be open source and contributor friendly.
181
+ `llmapi-tracker` is intended to be open source and contributor friendly.
176
182
 
177
183
  Contribution files:
178
184
 
@@ -192,5 +198,5 @@ Contribution expectations:
192
198
 
193
199
  ## License
194
200
 
195
- API Tracker is released under the MIT License. See [`LICENSE`](L:/Personal/APITracker/LICENSE).
201
+ `llmapi-tracker` is released under the MIT License. See [`LICENSE`](L:/Personal/APITracker/LICENSE).
196
202
 
@@ -1,7 +1,5 @@
1
1
  from __future__ import annotations
2
2
 
3
- import os
4
-
5
3
  from sqlalchemy import create_engine
6
4
  from sqlalchemy.orm import declarative_base, sessionmaker
7
5
 
@@ -1,7 +1,5 @@
1
1
  from __future__ import annotations
2
2
 
3
- from pathlib import Path
4
-
5
3
  from fastapi import APIRouter
6
4
  from fastapi.responses import FileResponse
7
5
  from fastapi.staticfiles import StaticFiles
@@ -12,7 +10,11 @@ from .paths import get_frontend_dist_dir
12
10
  def mount_frontend(app, prefix: str = "") -> None:
13
11
  static_dir = get_frontend_dist_dir()
14
12
  if static_dir.exists():
15
- app.mount(prefix or "/assets", StaticFiles(directory=static_dir / "assets"), name="assets")
13
+ app.mount(
14
+ prefix or "/assets",
15
+ StaticFiles(directory=static_dir / "assets"),
16
+ name="assets",
17
+ )
16
18
 
17
19
 
18
20
  def register_frontend_routes(router: APIRouter) -> None:
@@ -10,7 +10,11 @@ import uvicorn
10
10
  def launch_app() -> None:
11
11
  host = os.getenv("API_TRACKER_HOST", "127.0.0.1")
12
12
  port = int(os.getenv("API_TRACKER_PORT", "8000"))
13
- open_browser = os.getenv("API_TRACKER_OPEN_BROWSER", "true").lower() not in {"0", "false", "no"}
13
+ open_browser = os.getenv("API_TRACKER_OPEN_BROWSER", "true").lower() not in {
14
+ "0",
15
+ "false",
16
+ "no",
17
+ }
14
18
  if open_browser:
15
19
  url = f"http://{host}:{port}"
16
20
  threading.Timer(1.0, lambda: webbrowser.open(url)).start()
@@ -1,5 +1,3 @@
1
- from pathlib import Path
2
-
3
1
  from fastapi import FastAPI
4
2
  from fastapi.middleware.cors import CORSMiddleware
5
3
  from fastapi.responses import FileResponse
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from datetime import datetime
3
+ from datetime import datetime, timezone
4
4
 
5
5
  from sqlalchemy import (
6
6
  JSON,
@@ -20,7 +20,8 @@ from .database import Base
20
20
 
21
21
 
22
22
  def utcnow() -> datetime:
23
- return datetime.utcnow()
23
+ # return datetime.utcnow()
24
+ return datetime.now(timezone.utc)
24
25
 
25
26
 
26
27
  class Project(Base):
@@ -42,21 +43,29 @@ class Provider(Base):
42
43
  name = Column(String(100), unique=True, nullable=False, index=True)
43
44
  created_at = Column(DateTime, default=utcnow, nullable=False)
44
45
 
45
- models = relationship("Model", back_populates="provider", cascade="all, delete-orphan")
46
+ models = relationship(
47
+ "Model", back_populates="provider", cascade="all, delete-orphan"
48
+ )
46
49
 
47
50
 
48
51
  class Model(Base):
49
52
  __tablename__ = "models"
50
- __table_args__ = (UniqueConstraint("provider_id", "model_name", name="uq_provider_model_name"),)
53
+ __table_args__ = (
54
+ UniqueConstraint("provider_id", "model_name", name="uq_provider_model_name"),
55
+ )
51
56
 
52
57
  id = Column(Integer, primary_key=True, index=True)
53
- provider_id = Column(Integer, ForeignKey("providers.id"), nullable=False, index=True)
58
+ provider_id = Column(
59
+ Integer, ForeignKey("providers.id"), nullable=False, index=True
60
+ )
54
61
  model_name = Column(String(150), nullable=False, index=True)
55
62
  model_type = Column(String(50), default="text", nullable=False)
56
63
  created_at = Column(DateTime, default=utcnow, nullable=False)
57
64
 
58
65
  provider = relationship("Provider", back_populates="models")
59
- pricing = relationship("ModelPricing", back_populates="model", cascade="all, delete-orphan")
66
+ pricing = relationship(
67
+ "ModelPricing", back_populates="model", cascade="all, delete-orphan"
68
+ )
60
69
  usage = relationship("ApiUsage", back_populates="model_ref")
61
70
 
62
71
 
@@ -86,7 +95,9 @@ class ApiUsage(Base):
86
95
 
87
96
  id = Column(Integer, primary_key=True, index=True)
88
97
  project_id = Column(Integer, ForeignKey("projects.id"), nullable=False, index=True)
89
- provider_id = Column(Integer, ForeignKey("providers.id"), nullable=False, index=True)
98
+ provider_id = Column(
99
+ Integer, ForeignKey("providers.id"), nullable=False, index=True
100
+ )
90
101
  model_id = Column(Integer, ForeignKey("models.id"), nullable=False, index=True)
91
102
  internal_request_id = Column(String(255), nullable=False, unique=True, index=True)
92
103
  provider_request_id = Column(String(255), nullable=True, index=True)
@@ -3,7 +3,6 @@ from __future__ import annotations
3
3
  import os
4
4
  from pathlib import Path
5
5
 
6
-
7
6
  APP_NAME = "API Tracker"
8
7
 
9
8
 
File without changes