alephantai-analytics-api 0.1.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.
Files changed (51) hide show
  1. alephantai_analytics_api-0.1.0/CHANGELOG.md +31 -0
  2. alephantai_analytics_api-0.1.0/LICENSE +21 -0
  3. alephantai_analytics_api-0.1.0/MANIFEST.in +36 -0
  4. alephantai_analytics_api-0.1.0/PKG-INFO +302 -0
  5. alephantai_analytics_api-0.1.0/README.md +267 -0
  6. alephantai_analytics_api-0.1.0/__init__.py +70 -0
  7. alephantai_analytics_api-0.1.0/alephantai_analytics_api.egg-info/PKG-INFO +302 -0
  8. alephantai_analytics_api-0.1.0/alephantai_analytics_api.egg-info/SOURCES.txt +87 -0
  9. alephantai_analytics_api-0.1.0/alephantai_analytics_api.egg-info/dependency_links.txt +1 -0
  10. alephantai_analytics_api-0.1.0/alephantai_analytics_api.egg-info/requires.txt +11 -0
  11. alephantai_analytics_api-0.1.0/alephantai_analytics_api.egg-info/top_level.txt +1 -0
  12. alephantai_analytics_api-0.1.0/analytics_atomic/__init__.py +4 -0
  13. alephantai_analytics_api-0.1.0/analytics_atomic/client.py +2630 -0
  14. alephantai_analytics_api-0.1.0/analytics_atomic/raw_client.py +3066 -0
  15. alephantai_analytics_api-0.1.0/analytics_saas/__init__.py +4 -0
  16. alephantai_analytics_api-0.1.0/analytics_saas/client.py +1482 -0
  17. alephantai_analytics_api-0.1.0/analytics_saas/raw_client.py +1708 -0
  18. alephantai_analytics_api-0.1.0/client.py +195 -0
  19. alephantai_analytics_api-0.1.0/commons/__init__.py +55 -0
  20. alephantai_analytics_api-0.1.0/commons/types/__init__.py +53 -0
  21. alephantai_analytics_api-0.1.0/commons/types/aggregate_ping_body.py +30 -0
  22. alephantai_analytics_api-0.1.0/commons/types/analytics_error_body.py +24 -0
  23. alephantai_analytics_api-0.1.0/commons/types/analytics_health_data.py +24 -0
  24. alephantai_analytics_api-0.1.0/commons/types/analytics_health_response.py +22 -0
  25. alephantai_analytics_api-0.1.0/commons/types/analytics_json_response.py +21 -0
  26. alephantai_analytics_api-0.1.0/commons/types/detail_ping_body.py +36 -0
  27. alephantai_analytics_api-0.1.0/core/__init__.py +125 -0
  28. alephantai_analytics_api-0.1.0/core/api_error.py +23 -0
  29. alephantai_analytics_api-0.1.0/core/client_wrapper.py +92 -0
  30. alephantai_analytics_api-0.1.0/core/datetime_utils.py +70 -0
  31. alephantai_analytics_api-0.1.0/core/file.py +67 -0
  32. alephantai_analytics_api-0.1.0/core/force_multipart.py +18 -0
  33. alephantai_analytics_api-0.1.0/core/http_client.py +840 -0
  34. alephantai_analytics_api-0.1.0/core/http_response.py +59 -0
  35. alephantai_analytics_api-0.1.0/core/http_sse/__init__.py +42 -0
  36. alephantai_analytics_api-0.1.0/core/http_sse/_api.py +112 -0
  37. alephantai_analytics_api-0.1.0/core/http_sse/_decoders.py +61 -0
  38. alephantai_analytics_api-0.1.0/core/http_sse/_exceptions.py +7 -0
  39. alephantai_analytics_api-0.1.0/core/http_sse/_models.py +17 -0
  40. alephantai_analytics_api-0.1.0/core/jsonable_encoder.py +108 -0
  41. alephantai_analytics_api-0.1.0/core/logging.py +107 -0
  42. alephantai_analytics_api-0.1.0/core/parse_error.py +36 -0
  43. alephantai_analytics_api-0.1.0/core/pydantic_utilities.py +634 -0
  44. alephantai_analytics_api-0.1.0/core/query_encoder.py +58 -0
  45. alephantai_analytics_api-0.1.0/core/remove_none_from_dict.py +11 -0
  46. alephantai_analytics_api-0.1.0/core/request_options.py +35 -0
  47. alephantai_analytics_api-0.1.0/core/serialization.py +276 -0
  48. alephantai_analytics_api-0.1.0/environment.py +11 -0
  49. alephantai_analytics_api-0.1.0/pyproject.toml +76 -0
  50. alephantai_analytics_api-0.1.0/setup.cfg +4 -0
  51. alephantai_analytics_api-0.1.0/setup.py +17 -0
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2026-04-08
9
+
10
+ ### Added
11
+ - Initial release of Alephant Analytics API Python client
12
+ - Support for Analytics Atomic endpoints (health, ping)
13
+ - Support for Analytics SaaS endpoints (request logs, usage analytics)
14
+ - Async and sync client implementations
15
+ - JWT and API key authentication
16
+ - Comprehensive error handling
17
+ - Type hints and Pydantic models
18
+ - Development tools configuration (black, isort, mypy)
19
+
20
+ ### Features
21
+ - Generated from Fern API definition for consistency
22
+ - Full type safety with mypy
23
+ - Async/await support
24
+ - Configurable timeouts and retries
25
+ - Environment variable configuration
26
+ - Detailed documentation and examples
27
+
28
+ ### Dependencies
29
+ - httpx >= 0.25.0
30
+ - pydantic >= 2.0.0
31
+ - typing-extensions >= 4.0.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alephant AI
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,36 @@
1
+ # Package directory mapping: pyproject.toml declares `alephant_logs_collector = "."`
2
+ # This means the entire current directory is mapped to the package name `alephant_logs_collector`
3
+ # We include specific directories and files to avoid build artifacts
4
+
5
+ include README.md
6
+ include CHANGELOG.md
7
+ include LICENSE
8
+ include pyproject.toml
9
+
10
+ # Include root-level Python files
11
+ include __init__.py
12
+ include client.py
13
+ include environment.py
14
+
15
+ # Include package directories explicitly
16
+ recursive-include core *.py
17
+ recursive-include core *.typed
18
+ recursive-include commons *.py
19
+ recursive-include commons *.typed
20
+ recursive-include analytics_atomic *.py
21
+ recursive-include analytics_atomic *.typed
22
+ recursive-include analytics_saas *.py
23
+ recursive-include analytics_saas *.typed
24
+
25
+ # Exclude test files and development artifacts
26
+ prune tests
27
+ exclude test_package.py
28
+
29
+ # Global excludes
30
+ global-exclude __pycache__
31
+ global-exclude *.py[co]
32
+ global-exclude .DS_Store
33
+ global-exclude *.egg-info
34
+ global-exclude build
35
+ global-exclude dist
36
+ global-exclude test_package.py
@@ -0,0 +1,302 @@
1
+ Metadata-Version: 2.4
2
+ Name: alephantai-analytics-api
3
+ Version: 0.1.0
4
+ Summary: Python client for Alephant Analytics API
5
+ Author-email: Alephant AI <support@alephant.io>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/alephant-ai/alephantai-analytics-api
8
+ Project-URL: Documentation, https://docs.alephant.io/analytics-api
9
+ Project-URL: Repository, https://github.com/alephant-ai/alephantai-analytics-api
10
+ Project-URL: Issues, https://github.com/alephant-ai/alephantai-analytics-api/issues
11
+ Keywords: alephant,analytics,api,client
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.8
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: httpx>=0.25.0
25
+ Requires-Dist: pydantic>=2.0.0
26
+ Requires-Dist: typing-extensions>=4.0.0
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
29
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
30
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
31
+ Requires-Dist: black>=23.0.0; extra == "dev"
32
+ Requires-Dist: isort>=5.0.0; extra == "dev"
33
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ # Alephant Analytics API Python Client
37
+
38
+ Official Python client for the Alephant Analytics API.
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ pip install alephantai-analytics-api
44
+ ```
45
+
46
+ ## Package Import
47
+
48
+ After installation, import the client using the Python package name:
49
+
50
+ ```python
51
+ # PyPI package name: alephantai-analytics-api
52
+ # Python import name: alephant_logs_collector
53
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
54
+ ```
55
+
56
+ **Note**: The PyPI package name (`alephantai-analytics-api`) differs from the Python import name (`alephant_logs_collector`) due to Fern generator naming conventions.
57
+
58
+ ## Quick Start
59
+
60
+ ```python
61
+ import os
62
+
63
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
64
+ from alephant_logs_collector.environment import LogsCollectorAnalyticsClientEnvironment
65
+
66
+ # Manually read environment variables and configure client
67
+ api_key = os.environ.get("ALEPHANT_API_KEY")
68
+ client = LogsCollectorAnalyticsClient(
69
+ environment=LogsCollectorAnalyticsClientEnvironment.PRODUCTION,
70
+ headers={"Authorization": f"Bearer {api_key}"} if api_key else None,
71
+ )
72
+
73
+ # Public health probe (auth optional)
74
+ health = client.analytics_atomic.get_health()
75
+ print(f"Service status: {health.data.status}")
76
+ ```
77
+
78
+ ## Configuration
79
+
80
+ ### Environment Variables
81
+
82
+ The SDK does not automatically read environment variables. You must manually read them in your code and pass them to the client constructor.
83
+
84
+ **Recommended environment variables**:
85
+
86
+ | Variable | Description |
87
+ |----------|-------------|
88
+ | `ALEPHANT_API_KEY` | Your API key, virtual key, or PAT — passed as Bearer token via `headers` parameter |
89
+ | `ALEPHANT_BASE_URL` | Base URL for the API (e.g. `https://analytics.alephant.io`) — passed via `base_url` parameter |
90
+
91
+ **Example with manual environment variable reading**:
92
+
93
+ ```python
94
+ import os
95
+
96
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
97
+
98
+ # Manually read environment variables
99
+ base_url = os.environ.get("ALEPHANT_BASE_URL")
100
+ api_key = os.environ.get("ALEPHANT_API_KEY")
101
+
102
+ client = LogsCollectorAnalyticsClient(
103
+ base_url=base_url,
104
+ headers={"Authorization": f"Bearer {api_key}"} if api_key else None,
105
+ )
106
+ ```
107
+
108
+ ### Client Options
109
+
110
+ ```python
111
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
112
+ from alephant_logs_collector.environment import LogsCollectorAnalyticsClientEnvironment
113
+
114
+ client = LogsCollectorAnalyticsClient(
115
+ environment=LogsCollectorAnalyticsClientEnvironment.PRODUCTION,
116
+ base_url="https://analytics.alephant.io", # optional; overrides environment URL when set
117
+ timeout=30.0, # seconds; default 60 when using the default httpx client
118
+ follow_redirects=True,
119
+ headers=None, # default headers for every request (e.g. Authorization, Cookie)
120
+ )
121
+ ```
122
+
123
+ ## Authentication
124
+
125
+ The API accepts **Bearer JWT**, **virtual key**, or **PAT** on the `Authorization` header. The Python client does not expose a dedicated `api_key` constructor argument; wire credentials using one of the patterns below.
126
+
127
+ ### API Key (Bearer token)
128
+
129
+ Pass the token on each call, or set default headers on the client.
130
+
131
+ ```python
132
+ import os
133
+
134
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
135
+ from alephant_logs_collector.environment import LogsCollectorAnalyticsClientEnvironment
136
+
137
+ token = os.environ["ALEPHANT_API_KEY"]
138
+
139
+ client = LogsCollectorAnalyticsClient(
140
+ environment=LogsCollectorAnalyticsClientEnvironment.PRODUCTION,
141
+ headers={"Authorization": f"Bearer {token}"},
142
+ )
143
+
144
+ # Or per-request (overrides / supplements per method signature)
145
+ client.analytics_atomic.get_live24h_summary(
146
+ authorization=f"Bearer {token}",
147
+ x_workspace_id="00000000-0000-0000-0000-000000000000",
148
+ )
149
+ ```
150
+
151
+ ### JWT Token
152
+
153
+ Use the same `Authorization: Bearer <jwt>` form — either via `headers=` on the client or the `authorization=` parameter on endpoints.
154
+
155
+ ```python
156
+ client = LogsCollectorAnalyticsClient(
157
+ base_url="https://analytics.alephant.io",
158
+ headers={"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."},
159
+ )
160
+ ```
161
+
162
+ ### Cookie Auth
163
+
164
+ The server also accepts the `alephant_token` cookie. Model it with default headers (or a custom `httpx` client):
165
+
166
+ ```python
167
+ import httpx
168
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
169
+
170
+ cookie_client = httpx.Client(timeout=30.0)
171
+ client = LogsCollectorAnalyticsClient(
172
+ base_url="https://analytics.alephant.io",
173
+ httpx_client=cookie_client,
174
+ headers={"Cookie": "alephant_token=YOUR_SESSION_TOKEN"},
175
+ )
176
+ ```
177
+
178
+ Authenticated routes typically require `x_workspace_id` (`X-Workspace-Id`) as well — pass `x_workspace_id="..."` on each method that supports it.
179
+
180
+ ## API Reference
181
+
182
+ For full request/response shapes, see `reference.md` in this package.
183
+
184
+ ### Analytics Atomic
185
+
186
+ | Method | Description |
187
+ |--------|-------------|
188
+ | `client.analytics_atomic.get_health()` | Public health probe (`GET` health). |
189
+ | `client.analytics_atomic.post_aggregate_ping()` | Connectivity check against aggregate tables. |
190
+ | `client.analytics_atomic.post_detail_ping()` | Connectivity check against detail/RMT paths. |
191
+ | `client.analytics_atomic.get_live24h_summary()` | Rolling ~24h workspace totals. |
192
+ | `client.analytics_atomic.get_usage_summary()` | Daily KPIs for a window vs previous period. |
193
+ | `client.analytics_atomic.get_usage_timeseries()` | Time series for cost/requests/tokens/etc. |
194
+ | `client.analytics_atomic.get_request_logs(start=..., end=...)` | Request log list for a time window. |
195
+ | `client.analytics_atomic.get_request_log_by_id(request_id=...)` | Single request log by ID. |
196
+ | `client.analytics_atomic.get_by_department()` / `get_by_agent()` / `get_by_member()` | Cost/usage breakdown helpers. |
197
+ | `client.analytics_atomic.get_master_keys_*()` | Master key vault, spend, and breakdown endpoints. |
198
+
199
+ ### Analytics SaaS
200
+
201
+ | Method | Description |
202
+ |--------|-------------|
203
+ | `client.analytics_saas.get_saas_overview()` | SaaS dashboard overview. |
204
+ | `client.analytics_saas.get_saas_live24h()` | Live-24h style panel (top models/keys, etc.). |
205
+ | `client.analytics_saas.get_saas_usage(date_from=..., date_to=...)` | Daily usage series for the workspace. |
206
+ | `client.analytics_saas.get_saas_logs(...)` | SaaS request logs listing (filters per API). |
207
+ | `client.analytics_saas.get_saas_logs_stats()` | Log statistics for the SaaS UI. |
208
+ | `client.analytics_saas.get_saas_costs()` / `get_saas_models()` / `get_saas_sparklines()` | Costs, models, sparklines. |
209
+ | `client.analytics_saas.get_saas_agent_analytics()` / `get_saas_member_analytics()` | Agent/member analytics. |
210
+
211
+ ## Error Handling
212
+
213
+ Non-2xx responses and some parse failures raise `ApiError` from `alephant_logs_collector.core`.
214
+
215
+ ```python
216
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
217
+ from alephant_logs_collector.core import ApiError
218
+ from alephant_logs_collector.environment import LogsCollectorAnalyticsClientEnvironment
219
+
220
+ client = LogsCollectorAnalyticsClient(
221
+ environment=LogsCollectorAnalyticsClientEnvironment.PRODUCTION,
222
+ headers={"Authorization": "Bearer your-token"},
223
+ )
224
+
225
+ try:
226
+ data = client.analytics_atomic.get_request_logs(
227
+ start="2025-01-01T00:00:00Z",
228
+ end="2025-01-02T00:00:00Z",
229
+ x_workspace_id="your-workspace-uuid",
230
+ )
231
+ print(data)
232
+ except ApiError as e:
233
+ # e.status_code: HTTP status; e.body: parsed JSON or raw text; e.headers: response headers
234
+ print(f"API error: status={e.status_code}, body={e.body}")
235
+ ```
236
+
237
+ ## Async Support
238
+
239
+ Use `AsyncLogsCollectorAnalyticsClient` with `async`/`await`. Method names mirror the sync client.
240
+
241
+ ```python
242
+ import asyncio
243
+ import os
244
+
245
+ from alephant_logs_collector import AsyncLogsCollectorAnalyticsClient
246
+ from alephant_logs_collector.environment import LogsCollectorAnalyticsClientEnvironment
247
+
248
+
249
+ async def main() -> None:
250
+ # Manually read environment variables
251
+ api_key = os.environ.get("ALEPHANT_API_KEY")
252
+ client = AsyncLogsCollectorAnalyticsClient(
253
+ environment=LogsCollectorAnalyticsClientEnvironment.PRODUCTION,
254
+ headers={"Authorization": f"Bearer {api_key}"} if api_key else None,
255
+ )
256
+ health = await client.analytics_atomic.get_health()
257
+ print(health.data.status)
258
+
259
+
260
+ asyncio.run(main())
261
+ ```
262
+
263
+ ## Development
264
+
265
+ From the directory that contains `pyproject.toml` (this SDK root):
266
+
267
+ ### Installing Dev Dependencies
268
+
269
+ ```bash
270
+ pip install -e ".[dev]"
271
+ ```
272
+
273
+ ### Running Tests
274
+
275
+ ```bash
276
+ pytest
277
+ ```
278
+
279
+ ### Code Formatting
280
+
281
+ ```bash
282
+ black .
283
+ isort .
284
+ ```
285
+
286
+ ### Type Checking
287
+
288
+ ```bash
289
+ mypy .
290
+ ```
291
+
292
+ ## License
293
+
294
+ This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
295
+
296
+ ## Support
297
+
298
+ For support, contact [support@alephant.io](mailto:support@alephant.io) or open an issue on GitHub.
299
+
300
+ ## Documentation
301
+
302
+ See [Alephant Analytics API documentation](https://docs.alephant.io/analytics-api) and the generated `reference.md` in this repository for endpoint-level detail.
@@ -0,0 +1,267 @@
1
+ # Alephant Analytics API Python Client
2
+
3
+ Official Python client for the Alephant Analytics API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install alephantai-analytics-api
9
+ ```
10
+
11
+ ## Package Import
12
+
13
+ After installation, import the client using the Python package name:
14
+
15
+ ```python
16
+ # PyPI package name: alephantai-analytics-api
17
+ # Python import name: alephant_logs_collector
18
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
19
+ ```
20
+
21
+ **Note**: The PyPI package name (`alephantai-analytics-api`) differs from the Python import name (`alephant_logs_collector`) due to Fern generator naming conventions.
22
+
23
+ ## Quick Start
24
+
25
+ ```python
26
+ import os
27
+
28
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
29
+ from alephant_logs_collector.environment import LogsCollectorAnalyticsClientEnvironment
30
+
31
+ # Manually read environment variables and configure client
32
+ api_key = os.environ.get("ALEPHANT_API_KEY")
33
+ client = LogsCollectorAnalyticsClient(
34
+ environment=LogsCollectorAnalyticsClientEnvironment.PRODUCTION,
35
+ headers={"Authorization": f"Bearer {api_key}"} if api_key else None,
36
+ )
37
+
38
+ # Public health probe (auth optional)
39
+ health = client.analytics_atomic.get_health()
40
+ print(f"Service status: {health.data.status}")
41
+ ```
42
+
43
+ ## Configuration
44
+
45
+ ### Environment Variables
46
+
47
+ The SDK does not automatically read environment variables. You must manually read them in your code and pass them to the client constructor.
48
+
49
+ **Recommended environment variables**:
50
+
51
+ | Variable | Description |
52
+ |----------|-------------|
53
+ | `ALEPHANT_API_KEY` | Your API key, virtual key, or PAT — passed as Bearer token via `headers` parameter |
54
+ | `ALEPHANT_BASE_URL` | Base URL for the API (e.g. `https://analytics.alephant.io`) — passed via `base_url` parameter |
55
+
56
+ **Example with manual environment variable reading**:
57
+
58
+ ```python
59
+ import os
60
+
61
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
62
+
63
+ # Manually read environment variables
64
+ base_url = os.environ.get("ALEPHANT_BASE_URL")
65
+ api_key = os.environ.get("ALEPHANT_API_KEY")
66
+
67
+ client = LogsCollectorAnalyticsClient(
68
+ base_url=base_url,
69
+ headers={"Authorization": f"Bearer {api_key}"} if api_key else None,
70
+ )
71
+ ```
72
+
73
+ ### Client Options
74
+
75
+ ```python
76
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
77
+ from alephant_logs_collector.environment import LogsCollectorAnalyticsClientEnvironment
78
+
79
+ client = LogsCollectorAnalyticsClient(
80
+ environment=LogsCollectorAnalyticsClientEnvironment.PRODUCTION,
81
+ base_url="https://analytics.alephant.io", # optional; overrides environment URL when set
82
+ timeout=30.0, # seconds; default 60 when using the default httpx client
83
+ follow_redirects=True,
84
+ headers=None, # default headers for every request (e.g. Authorization, Cookie)
85
+ )
86
+ ```
87
+
88
+ ## Authentication
89
+
90
+ The API accepts **Bearer JWT**, **virtual key**, or **PAT** on the `Authorization` header. The Python client does not expose a dedicated `api_key` constructor argument; wire credentials using one of the patterns below.
91
+
92
+ ### API Key (Bearer token)
93
+
94
+ Pass the token on each call, or set default headers on the client.
95
+
96
+ ```python
97
+ import os
98
+
99
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
100
+ from alephant_logs_collector.environment import LogsCollectorAnalyticsClientEnvironment
101
+
102
+ token = os.environ["ALEPHANT_API_KEY"]
103
+
104
+ client = LogsCollectorAnalyticsClient(
105
+ environment=LogsCollectorAnalyticsClientEnvironment.PRODUCTION,
106
+ headers={"Authorization": f"Bearer {token}"},
107
+ )
108
+
109
+ # Or per-request (overrides / supplements per method signature)
110
+ client.analytics_atomic.get_live24h_summary(
111
+ authorization=f"Bearer {token}",
112
+ x_workspace_id="00000000-0000-0000-0000-000000000000",
113
+ )
114
+ ```
115
+
116
+ ### JWT Token
117
+
118
+ Use the same `Authorization: Bearer <jwt>` form — either via `headers=` on the client or the `authorization=` parameter on endpoints.
119
+
120
+ ```python
121
+ client = LogsCollectorAnalyticsClient(
122
+ base_url="https://analytics.alephant.io",
123
+ headers={"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."},
124
+ )
125
+ ```
126
+
127
+ ### Cookie Auth
128
+
129
+ The server also accepts the `alephant_token` cookie. Model it with default headers (or a custom `httpx` client):
130
+
131
+ ```python
132
+ import httpx
133
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
134
+
135
+ cookie_client = httpx.Client(timeout=30.0)
136
+ client = LogsCollectorAnalyticsClient(
137
+ base_url="https://analytics.alephant.io",
138
+ httpx_client=cookie_client,
139
+ headers={"Cookie": "alephant_token=YOUR_SESSION_TOKEN"},
140
+ )
141
+ ```
142
+
143
+ Authenticated routes typically require `x_workspace_id` (`X-Workspace-Id`) as well — pass `x_workspace_id="..."` on each method that supports it.
144
+
145
+ ## API Reference
146
+
147
+ For full request/response shapes, see `reference.md` in this package.
148
+
149
+ ### Analytics Atomic
150
+
151
+ | Method | Description |
152
+ |--------|-------------|
153
+ | `client.analytics_atomic.get_health()` | Public health probe (`GET` health). |
154
+ | `client.analytics_atomic.post_aggregate_ping()` | Connectivity check against aggregate tables. |
155
+ | `client.analytics_atomic.post_detail_ping()` | Connectivity check against detail/RMT paths. |
156
+ | `client.analytics_atomic.get_live24h_summary()` | Rolling ~24h workspace totals. |
157
+ | `client.analytics_atomic.get_usage_summary()` | Daily KPIs for a window vs previous period. |
158
+ | `client.analytics_atomic.get_usage_timeseries()` | Time series for cost/requests/tokens/etc. |
159
+ | `client.analytics_atomic.get_request_logs(start=..., end=...)` | Request log list for a time window. |
160
+ | `client.analytics_atomic.get_request_log_by_id(request_id=...)` | Single request log by ID. |
161
+ | `client.analytics_atomic.get_by_department()` / `get_by_agent()` / `get_by_member()` | Cost/usage breakdown helpers. |
162
+ | `client.analytics_atomic.get_master_keys_*()` | Master key vault, spend, and breakdown endpoints. |
163
+
164
+ ### Analytics SaaS
165
+
166
+ | Method | Description |
167
+ |--------|-------------|
168
+ | `client.analytics_saas.get_saas_overview()` | SaaS dashboard overview. |
169
+ | `client.analytics_saas.get_saas_live24h()` | Live-24h style panel (top models/keys, etc.). |
170
+ | `client.analytics_saas.get_saas_usage(date_from=..., date_to=...)` | Daily usage series for the workspace. |
171
+ | `client.analytics_saas.get_saas_logs(...)` | SaaS request logs listing (filters per API). |
172
+ | `client.analytics_saas.get_saas_logs_stats()` | Log statistics for the SaaS UI. |
173
+ | `client.analytics_saas.get_saas_costs()` / `get_saas_models()` / `get_saas_sparklines()` | Costs, models, sparklines. |
174
+ | `client.analytics_saas.get_saas_agent_analytics()` / `get_saas_member_analytics()` | Agent/member analytics. |
175
+
176
+ ## Error Handling
177
+
178
+ Non-2xx responses and some parse failures raise `ApiError` from `alephant_logs_collector.core`.
179
+
180
+ ```python
181
+ from alephant_logs_collector import LogsCollectorAnalyticsClient
182
+ from alephant_logs_collector.core import ApiError
183
+ from alephant_logs_collector.environment import LogsCollectorAnalyticsClientEnvironment
184
+
185
+ client = LogsCollectorAnalyticsClient(
186
+ environment=LogsCollectorAnalyticsClientEnvironment.PRODUCTION,
187
+ headers={"Authorization": "Bearer your-token"},
188
+ )
189
+
190
+ try:
191
+ data = client.analytics_atomic.get_request_logs(
192
+ start="2025-01-01T00:00:00Z",
193
+ end="2025-01-02T00:00:00Z",
194
+ x_workspace_id="your-workspace-uuid",
195
+ )
196
+ print(data)
197
+ except ApiError as e:
198
+ # e.status_code: HTTP status; e.body: parsed JSON or raw text; e.headers: response headers
199
+ print(f"API error: status={e.status_code}, body={e.body}")
200
+ ```
201
+
202
+ ## Async Support
203
+
204
+ Use `AsyncLogsCollectorAnalyticsClient` with `async`/`await`. Method names mirror the sync client.
205
+
206
+ ```python
207
+ import asyncio
208
+ import os
209
+
210
+ from alephant_logs_collector import AsyncLogsCollectorAnalyticsClient
211
+ from alephant_logs_collector.environment import LogsCollectorAnalyticsClientEnvironment
212
+
213
+
214
+ async def main() -> None:
215
+ # Manually read environment variables
216
+ api_key = os.environ.get("ALEPHANT_API_KEY")
217
+ client = AsyncLogsCollectorAnalyticsClient(
218
+ environment=LogsCollectorAnalyticsClientEnvironment.PRODUCTION,
219
+ headers={"Authorization": f"Bearer {api_key}"} if api_key else None,
220
+ )
221
+ health = await client.analytics_atomic.get_health()
222
+ print(health.data.status)
223
+
224
+
225
+ asyncio.run(main())
226
+ ```
227
+
228
+ ## Development
229
+
230
+ From the directory that contains `pyproject.toml` (this SDK root):
231
+
232
+ ### Installing Dev Dependencies
233
+
234
+ ```bash
235
+ pip install -e ".[dev]"
236
+ ```
237
+
238
+ ### Running Tests
239
+
240
+ ```bash
241
+ pytest
242
+ ```
243
+
244
+ ### Code Formatting
245
+
246
+ ```bash
247
+ black .
248
+ isort .
249
+ ```
250
+
251
+ ### Type Checking
252
+
253
+ ```bash
254
+ mypy .
255
+ ```
256
+
257
+ ## License
258
+
259
+ This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
260
+
261
+ ## Support
262
+
263
+ For support, contact [support@alephant.io](mailto:support@alephant.io) or open an issue on GitHub.
264
+
265
+ ## Documentation
266
+
267
+ See [Alephant Analytics API documentation](https://docs.alephant.io/analytics-api) and the generated `reference.md` in this repository for endpoint-level detail.