openmeter 1.0.0b54__py3-none-any.whl → 2.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.

Potentially problematic release.


This version of openmeter might be problematic. Click here for more details.

Files changed (132) hide show
  1. openmeter/__init__.py +89 -15
  2. openmeter/_base_client.py +2041 -0
  3. openmeter/_client.py +518 -70
  4. openmeter/_compat.py +221 -0
  5. openmeter/_constants.py +14 -0
  6. openmeter/_exceptions.py +108 -0
  7. openmeter/_files.py +127 -0
  8. openmeter/_models.py +777 -0
  9. openmeter/_qs.py +150 -0
  10. openmeter/_resource.py +43 -0
  11. openmeter/_response.py +820 -0
  12. openmeter/_streaming.py +333 -0
  13. openmeter/_types.py +222 -0
  14. openmeter/_utils/__init__.py +56 -0
  15. openmeter/_utils/_logs.py +25 -0
  16. openmeter/_utils/_proxy.py +63 -0
  17. openmeter/_utils/_reflection.py +42 -0
  18. openmeter/_utils/_streams.py +12 -0
  19. openmeter/_utils/_sync.py +81 -0
  20. openmeter/_utils/_transform.py +387 -0
  21. openmeter/_utils/_typing.py +120 -0
  22. openmeter/_utils/_utils.py +419 -0
  23. openmeter/_version.py +4 -0
  24. openmeter/lib/.keep +4 -0
  25. openmeter/py.typed +0 -1
  26. openmeter/resources/__init__.py +103 -0
  27. openmeter/resources/debug/__init__.py +33 -0
  28. openmeter/resources/debug/debug.py +102 -0
  29. openmeter/resources/debug/metrics.py +146 -0
  30. openmeter/resources/entitlements/__init__.py +47 -0
  31. openmeter/resources/entitlements/entitlements.py +450 -0
  32. openmeter/resources/entitlements/features.py +578 -0
  33. openmeter/resources/entitlements/grants.py +389 -0
  34. openmeter/resources/events.py +442 -0
  35. openmeter/resources/meters/__init__.py +33 -0
  36. openmeter/resources/meters/meters.py +666 -0
  37. openmeter/resources/meters/subjects.py +163 -0
  38. openmeter/resources/notifications/__init__.py +75 -0
  39. openmeter/resources/notifications/channels.py +686 -0
  40. openmeter/resources/notifications/events.py +365 -0
  41. openmeter/resources/notifications/notifications.py +198 -0
  42. openmeter/resources/notifications/rules.py +781 -0
  43. openmeter/resources/notifications/webhook.py +208 -0
  44. openmeter/resources/portal/__init__.py +47 -0
  45. openmeter/resources/portal/meters.py +230 -0
  46. openmeter/resources/portal/portal.py +112 -0
  47. openmeter/resources/portal/tokens.py +359 -0
  48. openmeter/resources/subjects/entitlements/__init__.py +33 -0
  49. openmeter/resources/subjects/entitlements/entitlements.py +1881 -0
  50. openmeter/resources/subjects/entitlements/grants.py +453 -0
  51. openmeter/resources/subjects.py +419 -0
  52. openmeter/types/__init__.py +21 -0
  53. openmeter/types/debug/__init__.py +5 -0
  54. openmeter/types/debug/metric_list_response.py +7 -0
  55. openmeter/types/entitlement.py +238 -0
  56. openmeter/types/entitlements/__init__.py +11 -0
  57. openmeter/types/entitlements/feature.py +61 -0
  58. openmeter/types/entitlements/feature_create_params.py +43 -0
  59. openmeter/types/entitlements/feature_list_params.py +23 -0
  60. openmeter/types/entitlements/grant_list_params.py +57 -0
  61. openmeter/types/entitlements/grant_list_response.py +11 -0
  62. openmeter/types/entitlements/grant_paginated_response.py +24 -0
  63. openmeter/types/entitlements/list_features_result.py +28 -0
  64. openmeter/types/event_ingest_params.py +46 -0
  65. openmeter/types/event_ingest_response.py +43 -0
  66. openmeter/types/event_list_params.py +22 -0
  67. openmeter/types/event_list_response.py +9 -0
  68. openmeter/types/ingested_event.py +59 -0
  69. openmeter/types/list_entitlements_result.py +28 -0
  70. openmeter/types/meter.py +53 -0
  71. openmeter/types/meter_create_params.py +50 -0
  72. openmeter/types/meter_list_response.py +9 -0
  73. openmeter/types/meter_query_params.py +50 -0
  74. openmeter/types/meter_query_result.py +35 -0
  75. openmeter/types/meters/__init__.py +5 -0
  76. openmeter/types/meters/subject_list_response.py +8 -0
  77. openmeter/types/notifications/__init__.py +18 -0
  78. openmeter/types/notifications/channel_create_params.py +34 -0
  79. openmeter/types/notifications/channel_list_params.py +41 -0
  80. openmeter/types/notifications/channel_list_response.py +24 -0
  81. openmeter/types/notifications/channel_update_params.py +34 -0
  82. openmeter/types/notifications/event_list_params.py +61 -0
  83. openmeter/types/notifications/event_list_response.py +24 -0
  84. openmeter/types/notifications/notification_channel.py +47 -0
  85. openmeter/types/notifications/notification_event.py +215 -0
  86. openmeter/types/notifications/notification_rule.py +70 -0
  87. openmeter/types/notifications/rule_create_params.py +39 -0
  88. openmeter/types/notifications/rule_list_params.py +54 -0
  89. openmeter/types/notifications/rule_list_response.py +24 -0
  90. openmeter/types/notifications/rule_update_params.py +39 -0
  91. openmeter/types/notifications/webhook_svix_params.py +26 -0
  92. openmeter/types/portal/__init__.py +10 -0
  93. openmeter/types/portal/meter_query_params.py +44 -0
  94. openmeter/types/portal/portal_token.py +28 -0
  95. openmeter/types/portal/token_create_params.py +17 -0
  96. openmeter/types/portal/token_invalidate_params.py +15 -0
  97. openmeter/types/portal/token_list_params.py +12 -0
  98. openmeter/types/portal/token_list_response.py +9 -0
  99. openmeter/types/shared/__init__.py +3 -0
  100. openmeter/types/subject.py +37 -0
  101. openmeter/types/subject_list_response.py +9 -0
  102. openmeter/types/subject_param.py +27 -0
  103. openmeter/types/subject_upsert_params.py +39 -0
  104. openmeter/types/subject_upsert_response.py +10 -0
  105. openmeter/types/subjects/__init__.py +13 -0
  106. openmeter/types/subjects/entitlement_history_params.py +35 -0
  107. openmeter/types/subjects/entitlement_history_response.py +98 -0
  108. openmeter/types/subjects/entitlement_list_response.py +10 -0
  109. openmeter/types/subjects/entitlements/__init__.py +8 -0
  110. openmeter/types/subjects/entitlements/entitlement_grant.py +103 -0
  111. openmeter/types/subjects/entitlements/grant_list_response.py +10 -0
  112. openmeter-2.0.0.dist-info/METADATA +396 -0
  113. openmeter-2.0.0.dist-info/RECORD +115 -0
  114. {openmeter-1.0.0b54.dist-info → openmeter-2.0.0.dist-info}/WHEEL +1 -1
  115. openmeter-2.0.0.dist-info/licenses/LICENSE +201 -0
  116. openmeter/_configuration.py +0 -36
  117. openmeter/_operations/__init__.py +0 -17
  118. openmeter/_operations/_operations.py +0 -2105
  119. openmeter/_operations/_patch.py +0 -20
  120. openmeter/_patch.py +0 -20
  121. openmeter/_serialization.py +0 -2008
  122. openmeter/_vendor.py +0 -24
  123. openmeter/aio/__init__.py +0 -21
  124. openmeter/aio/_client.py +0 -83
  125. openmeter/aio/_configuration.py +0 -36
  126. openmeter/aio/_operations/__init__.py +0 -17
  127. openmeter/aio/_operations/_operations.py +0 -1778
  128. openmeter/aio/_operations/_patch.py +0 -20
  129. openmeter/aio/_patch.py +0 -20
  130. openmeter/aio/_vendor.py +0 -24
  131. openmeter-1.0.0b54.dist-info/METADATA +0 -92
  132. openmeter-1.0.0b54.dist-info/RECORD +0 -21
@@ -0,0 +1,103 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Dict, Optional
4
+ from datetime import datetime
5
+ from typing_extensions import Literal
6
+
7
+ from pydantic import Field as FieldInfo
8
+
9
+ from ...._models import BaseModel
10
+
11
+ __all__ = ["EntitlementGrant", "Expiration", "Recurrence"]
12
+
13
+
14
+ class Expiration(BaseModel):
15
+ count: int
16
+ """The number of time units in the expiration period."""
17
+
18
+ duration: Literal["HOUR", "DAY", "WEEK", "MONTH", "YEAR"]
19
+ """The expiration duration enum"""
20
+
21
+
22
+ class Recurrence(BaseModel):
23
+ anchor: datetime
24
+ """A date-time anchor to base the recurring period on."""
25
+
26
+ interval: Literal["DAY", "WEEK", "MONTH", "YEAR"]
27
+ """The unit of time for the interval. One of: `day`, `week`, `month`, or `year`."""
28
+
29
+
30
+ class EntitlementGrant(BaseModel):
31
+ id: str
32
+ """Readonly unique ULID identifier."""
33
+
34
+ amount: float
35
+ """The amount to grant. Should be a positive number."""
36
+
37
+ created_at: datetime = FieldInfo(alias="createdAt")
38
+ """Timestamp of when the resource was created."""
39
+
40
+ effective_at: datetime = FieldInfo(alias="effectiveAt")
41
+ """Effective date for grants and anchor for recurring grants.
42
+
43
+ Provided value will be ceiled to metering windowSize (minute).
44
+ """
45
+
46
+ entitlement_id: str = FieldInfo(alias="entitlementId")
47
+ """The unique entitlement ULID that the grant is associated with."""
48
+
49
+ expiration: Expiration
50
+ """The grant expiration definition"""
51
+
52
+ updated_at: datetime = FieldInfo(alias="updatedAt")
53
+ """Timestamp of when the resource was last updated."""
54
+
55
+ deleted_at: Optional[datetime] = FieldInfo(alias="deletedAt", default=None)
56
+ """Timestamp of when the resource was permanently deleted."""
57
+
58
+ expires_at: Optional[datetime] = FieldInfo(alias="expiresAt", default=None)
59
+ """The time the grant expires."""
60
+
61
+ max_rollover_amount: Optional[float] = FieldInfo(alias="maxRolloverAmount", default=None)
62
+ """
63
+ Grants are rolled over at reset, after which they can have a different balance
64
+ compared to what they had before the reset. Balance after the reset is
65
+ calculated as: Balance_After_Reset = MIN(MaxRolloverAmount,
66
+ MAX(Balance_Before_Reset, MinRolloverAmount))
67
+ """
68
+
69
+ metadata: Optional[Dict[str, str]] = None
70
+ """
71
+ Set of key-value pairs. Metadata can be used to store additional information
72
+ about a resource.
73
+ """
74
+
75
+ min_rollover_amount: Optional[float] = FieldInfo(alias="minRolloverAmount", default=None)
76
+ """
77
+ Grants are rolled over at reset, after which they can have a different balance
78
+ compared to what they had before the reset. Balance after the reset is
79
+ calculated as: Balance_After_Reset = MIN(MaxRolloverAmount,
80
+ MAX(Balance_Before_Reset, MinRolloverAmount))
81
+ """
82
+
83
+ next_recurrence: Optional[datetime] = FieldInfo(alias="nextRecurrence", default=None)
84
+ """The next time the grant will recurr."""
85
+
86
+ priority: Optional[int] = None
87
+ """The priority of the grant.
88
+
89
+ Grants with higher priority are applied first. Priority is a positive decimal
90
+ numbers. With lower numbers indicating higher importance. For example, a
91
+ priority of 1 is more urgent than a priority of 2. When there are several grants
92
+ available for the same subject, the system selects the grant with the highest
93
+ priority. In cases where grants share the same priority level, the grant closest
94
+ to its expiration will be used first. In the case of two grants have identical
95
+ priorities and expiration dates, the system will use the grant that was created
96
+ first.
97
+ """
98
+
99
+ recurrence: Optional[Recurrence] = None
100
+ """Recurring period with an interval and an anchor."""
101
+
102
+ voided_at: Optional[datetime] = FieldInfo(alias="voidedAt", default=None)
103
+ """The time the grant was voided."""
@@ -0,0 +1,10 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import List
4
+ from typing_extensions import TypeAlias
5
+
6
+ from .entitlement_grant import EntitlementGrant
7
+
8
+ __all__ = ["GrantListResponse"]
9
+
10
+ GrantListResponse: TypeAlias = List[EntitlementGrant]
@@ -0,0 +1,396 @@
1
+ Metadata-Version: 2.3
2
+ Name: openmeter
3
+ Version: 2.0.0
4
+ Summary: The official Python library for the OpenMeter API
5
+ Project-URL: Homepage, https://github.com/openmeterio/openmeter-python
6
+ Project-URL: Repository, https://github.com/openmeterio/openmeter-python
7
+ Author-email: Open Meter <support@openmeter.io>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Operating System :: MacOS
13
+ Classifier: Operating System :: Microsoft :: Windows
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Operating System :: POSIX
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.8
25
+ Requires-Dist: anyio<5,>=3.5.0
26
+ Requires-Dist: cached-property; python_version < '3.8'
27
+ Requires-Dist: distro<2,>=1.7.0
28
+ Requires-Dist: httpx<1,>=0.23.0
29
+ Requires-Dist: pydantic<3,>=1.9.0
30
+ Requires-Dist: sniffio
31
+ Requires-Dist: typing-extensions<5,>=4.7
32
+ Description-Content-Type: text/markdown
33
+
34
+ # Open Meter Python API library
35
+
36
+ [![PyPI version](https://img.shields.io/pypi/v/openmeter.svg)](https://pypi.org/project/openmeter/)
37
+
38
+ The Open Meter Python library provides convenient access to the Open Meter REST API from any Python 3.8+
39
+ application. The library includes type definitions for all request params and response fields,
40
+ and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
41
+
42
+ It is generated with [Stainless](https://www.stainlessapi.com/).
43
+
44
+ ## Documentation
45
+
46
+ The REST API documentation can be found on [openmeter.io](https://openmeter.io/docs). The full API of this library can be found in [api.md](https://github.com/openmeterio/openmeter-python/tree/main/api.md).
47
+
48
+ ## Installation
49
+
50
+ ```sh
51
+ # install from the production repo
52
+ pip install git+ssh://git@github.com/openmeterio/openmeter-python.git
53
+ ```
54
+
55
+ > [!NOTE]
56
+ > Once this package is [published to PyPI](https://app.stainlessapi.com/docs/guides/publish), this will become: `pip install --pre openmeter`
57
+
58
+ ## Usage
59
+
60
+ The full API of this library can be found in [api.md](https://github.com/openmeterio/openmeter-python/tree/main/api.md).
61
+
62
+ ```python
63
+ import os
64
+ from openmeter import OpenMeter
65
+
66
+ client = OpenMeter(
67
+ # This is the default and can be omitted
68
+ cloud_api_token=os.environ.get("CLOUD_API_TOKEN"),
69
+ # defaults to "production".
70
+ environment="local",
71
+ )
72
+
73
+ meter = client.meters.create(
74
+ aggregation="SUM",
75
+ event_type="prompt",
76
+ slug="tokens_total",
77
+ window_size="MINUTE",
78
+ )
79
+ print(meter.id)
80
+ ```
81
+
82
+ While you can provide a `cloud_api_token` keyword argument,
83
+ we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
84
+ to add `CLOUD_API_TOKEN="My Cloud API Token"` to your `.env` file
85
+ so that your Cloud API Token is not stored in source control.
86
+
87
+ ## Async usage
88
+
89
+ Simply import `AsyncOpenMeter` instead of `OpenMeter` and use `await` with each API call:
90
+
91
+ ```python
92
+ import os
93
+ import asyncio
94
+ from openmeter import AsyncOpenMeter
95
+
96
+ client = AsyncOpenMeter(
97
+ # This is the default and can be omitted
98
+ cloud_api_token=os.environ.get("CLOUD_API_TOKEN"),
99
+ # defaults to "production".
100
+ environment="local",
101
+ )
102
+
103
+
104
+ async def main() -> None:
105
+ meter = await client.meters.create(
106
+ aggregation="SUM",
107
+ event_type="prompt",
108
+ slug="tokens_total",
109
+ window_size="MINUTE",
110
+ )
111
+ print(meter.id)
112
+
113
+
114
+ asyncio.run(main())
115
+ ```
116
+
117
+ Functionality between the synchronous and asynchronous clients is otherwise identical.
118
+
119
+ ## Using types
120
+
121
+ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
122
+
123
+ - Serializing back into JSON, `model.to_json()`
124
+ - Converting to a dictionary, `model.to_dict()`
125
+
126
+ Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
127
+
128
+ ## Handling errors
129
+
130
+ When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `openmeter.APIConnectionError` is raised.
131
+
132
+ When the API returns a non-success status code (that is, 4xx or 5xx
133
+ response), a subclass of `openmeter.APIStatusError` is raised, containing `status_code` and `response` properties.
134
+
135
+ All errors inherit from `openmeter.APIError`.
136
+
137
+ ```python
138
+ import openmeter
139
+ from openmeter import OpenMeter
140
+
141
+ client = OpenMeter()
142
+
143
+ try:
144
+ client.meters.create(
145
+ aggregation="SUM",
146
+ event_type="prompt",
147
+ slug="tokens_total",
148
+ window_size="MINUTE",
149
+ )
150
+ except openmeter.APIConnectionError as e:
151
+ print("The server could not be reached")
152
+ print(e.__cause__) # an underlying Exception, likely raised within httpx.
153
+ except openmeter.RateLimitError as e:
154
+ print("A 429 status code was received; we should back off a bit.")
155
+ except openmeter.APIStatusError as e:
156
+ print("Another non-200-range status code was received")
157
+ print(e.status_code)
158
+ print(e.response)
159
+ ```
160
+
161
+ Error codes are as followed:
162
+
163
+ | Status Code | Error Type |
164
+ | ----------- | -------------------------- |
165
+ | 400 | `BadRequestError` |
166
+ | 401 | `AuthenticationError` |
167
+ | 403 | `PermissionDeniedError` |
168
+ | 404 | `NotFoundError` |
169
+ | 422 | `UnprocessableEntityError` |
170
+ | 429 | `RateLimitError` |
171
+ | >=500 | `InternalServerError` |
172
+ | N/A | `APIConnectionError` |
173
+
174
+ ### Retries
175
+
176
+ Certain errors are automatically retried 2 times by default, with a short exponential backoff.
177
+ Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
178
+ 429 Rate Limit, and >=500 Internal errors are all retried by default.
179
+
180
+ You can use the `max_retries` option to configure or disable retry settings:
181
+
182
+ ```python
183
+ from openmeter import OpenMeter
184
+
185
+ # Configure the default for all requests:
186
+ client = OpenMeter(
187
+ # default is 2
188
+ max_retries=0,
189
+ )
190
+
191
+ # Or, configure per-request:
192
+ client.with_options(max_retries=5).meters.create(
193
+ aggregation="SUM",
194
+ event_type="prompt",
195
+ slug="tokens_total",
196
+ window_size="MINUTE",
197
+ )
198
+ ```
199
+
200
+ ### Timeouts
201
+
202
+ By default requests time out after 1 minute. You can configure this with a `timeout` option,
203
+ which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
204
+
205
+ ```python
206
+ from openmeter import OpenMeter
207
+
208
+ # Configure the default for all requests:
209
+ client = OpenMeter(
210
+ # 20 seconds (default is 1 minute)
211
+ timeout=20.0,
212
+ )
213
+
214
+ # More granular control:
215
+ client = OpenMeter(
216
+ timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
217
+ )
218
+
219
+ # Override per-request:
220
+ client.with_options(timeout=5.0).meters.create(
221
+ aggregation="SUM",
222
+ event_type="prompt",
223
+ slug="tokens_total",
224
+ window_size="MINUTE",
225
+ )
226
+ ```
227
+
228
+ On timeout, an `APITimeoutError` is thrown.
229
+
230
+ Note that requests that time out are [retried twice by default](https://github.com/openmeterio/openmeter-python/tree/main/#retries).
231
+
232
+ ## Advanced
233
+
234
+ ### Logging
235
+
236
+ We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.
237
+
238
+ You can enable logging by setting the environment variable `OPEN_METER_LOG` to `debug`.
239
+
240
+ ```shell
241
+ $ export OPEN_METER_LOG=debug
242
+ ```
243
+
244
+ ### How to tell whether `None` means `null` or missing
245
+
246
+ In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:
247
+
248
+ ```py
249
+ if response.my_field is None:
250
+ if 'my_field' not in response.model_fields_set:
251
+ print('Got json like {}, without a "my_field" key present at all.')
252
+ else:
253
+ print('Got json like {"my_field": null}.')
254
+ ```
255
+
256
+ ### Accessing raw response data (e.g. headers)
257
+
258
+ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,
259
+
260
+ ```py
261
+ from openmeter import OpenMeter
262
+
263
+ client = OpenMeter()
264
+ response = client.meters.with_raw_response.create(
265
+ aggregation="SUM",
266
+ event_type="prompt",
267
+ slug="tokens_total",
268
+ window_size="MINUTE",
269
+ )
270
+ print(response.headers.get('X-My-Header'))
271
+
272
+ meter = response.parse() # get the object that `meters.create()` would have returned
273
+ print(meter.id)
274
+ ```
275
+
276
+ These methods return an [`APIResponse`](https://github.com/openmeterio/openmeter-python/tree/main/src/openmeter/_response.py) object.
277
+
278
+ The async client returns an [`AsyncAPIResponse`](https://github.com/openmeterio/openmeter-python/tree/main/src/openmeter/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
279
+
280
+ #### `.with_streaming_response`
281
+
282
+ The above interface eagerly reads the full response body when you make the request, which may not always be what you want.
283
+
284
+ To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
285
+
286
+ ```python
287
+ with client.meters.with_streaming_response.create(
288
+ aggregation="SUM",
289
+ event_type="prompt",
290
+ slug="tokens_total",
291
+ window_size="MINUTE",
292
+ ) as response:
293
+ print(response.headers.get("X-My-Header"))
294
+
295
+ for line in response.iter_lines():
296
+ print(line)
297
+ ```
298
+
299
+ The context manager is required so that the response will reliably be closed.
300
+
301
+ ### Making custom/undocumented requests
302
+
303
+ This library is typed for convenient access to the documented API.
304
+
305
+ If you need to access undocumented endpoints, params, or response properties, the library can still be used.
306
+
307
+ #### Undocumented endpoints
308
+
309
+ To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
310
+ http verbs. Options on the client will be respected (such as retries) will be respected when making this
311
+ request.
312
+
313
+ ```py
314
+ import httpx
315
+
316
+ response = client.post(
317
+ "/foo",
318
+ cast_to=httpx.Response,
319
+ body={"my_param": True},
320
+ )
321
+
322
+ print(response.headers.get("x-foo"))
323
+ ```
324
+
325
+ #### Undocumented request params
326
+
327
+ If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request
328
+ options.
329
+
330
+ #### Undocumented response properties
331
+
332
+ To access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You
333
+ can also get all the extra fields on the Pydantic model as a dict with
334
+ [`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).
335
+
336
+ ### Configuring the HTTP client
337
+
338
+ You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:
339
+
340
+ - Support for proxies
341
+ - Custom transports
342
+ - Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality
343
+
344
+ ```python
345
+ from openmeter import OpenMeter, DefaultHttpxClient
346
+
347
+ client = OpenMeter(
348
+ # Or use the `OPEN_METER_BASE_URL` env var
349
+ base_url="http://my.test.server.example.com:8083",
350
+ http_client=DefaultHttpxClient(
351
+ proxies="http://my.test.proxy.example.com",
352
+ transport=httpx.HTTPTransport(local_address="0.0.0.0"),
353
+ ),
354
+ )
355
+ ```
356
+
357
+ You can also customize the client on a per-request basis by using `with_options()`:
358
+
359
+ ```python
360
+ client.with_options(http_client=DefaultHttpxClient(...))
361
+ ```
362
+
363
+ ### Managing HTTP resources
364
+
365
+ By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.
366
+
367
+ ## Versioning
368
+
369
+ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
370
+
371
+ 1. Changes that only affect static types, without breaking runtime behavior.
372
+ 2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_.
373
+ 3. Changes that we do not expect to impact the vast majority of users in practice.
374
+
375
+ We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
376
+
377
+ We are keen for your feedback; please open an [issue](https://www.github.com/openmeterio/openmeter-python/issues) with questions, bugs, or suggestions.
378
+
379
+ ### Determining the installed version
380
+
381
+ If you've upgraded to the latest version but aren't seeing any new features you were expecting then your python environment is likely still using an older version.
382
+
383
+ You can determine the version that is being used at runtime with:
384
+
385
+ ```py
386
+ import openmeter
387
+ print(openmeter.__version__)
388
+ ```
389
+
390
+ ## Requirements
391
+
392
+ Python 3.8 or higher.
393
+
394
+ ## Contributing
395
+
396
+ See [the contributing documentation](https://github.com/openmeterio/openmeter-python/tree/main/./CONTRIBUTING.md).
@@ -0,0 +1,115 @@
1
+ openmeter/__init__.py,sha256=m3pCzDjAFz2dH-jauMrMXWNZFDzXrkFZiwgEoifDtPI,2505
2
+ openmeter/_base_client.py,sha256=RcvQTwPqUB21eaSwp9QeSY4ZFD8L89AEOcqdRf-fE-Y,67847
3
+ openmeter/_client.py,sha256=HnHdsQ5K3Uk5ZJDNuQn69FtAYrHh7UPwoolz-HcYpQ8,22021
4
+ openmeter/_compat.py,sha256=fQkXUY7reJc8m_yguMWSjHBfO8lNzw4wOAxtkhP9d1Q,6607
5
+ openmeter/_constants.py,sha256=JE8kyZa2Q4NK_i4fO--8siEYTzeHnT0fYbOFDgDP4uk,464
6
+ openmeter/_exceptions.py,sha256=90y75NKYQ_PvELLA4zJV7JbiEjESBHqRC84VppqkDVQ,3226
7
+ openmeter/_files.py,sha256=me2eyWzJCM4YKh10Gzkxw4YyIEJoikzD4BVu_20UUc0,3565
8
+ openmeter/_models.py,sha256=tnjnnf22ouqEzhnpab7w4LQtnEUvUOm-IMIdTYrsNbM,28095
9
+ openmeter/_qs.py,sha256=AOkSz4rHtK4YI3ZU_kzea-zpwBUgEY8WniGmTPyEimc,4846
10
+ openmeter/_resource.py,sha256=rtjrHOv-NUIiOZcI11j-GUD0RAmNMU_0LOaVY8dkZdo,1118
11
+ openmeter/_response.py,sha256=XOaYD7lsKAFS25J_UUBPEjrSvf24jbmARRiAJl7d4f4,28393
12
+ openmeter/_streaming.py,sha256=jh1H8yDPO-LtHVPtGcJttzm-1Rt-TEpyCpZ9aaZPgzI,10112
13
+ openmeter/_types.py,sha256=bqYeAizA2dfPuDc4LvDALrZdla15wHCUlBO0YVxzCDM,6194
14
+ openmeter/_version.py,sha256=oWONkXIgfeHE7fQ0xtwSUbPbCN63IQNpvwKcpWNTWBM,161
15
+ openmeter/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ openmeter/_utils/__init__.py,sha256=k266EatJr88V8Zseb7xUimTlCeno9SynRfLwadHP1b4,2016
17
+ openmeter/_utils/_logs.py,sha256=t5NNCGJM3SJ9kLGddvXgAgGUaR-xpbxYPQ_Zn3hXOlE,784
18
+ openmeter/_utils/_proxy.py,sha256=DjcB-BBIRagSbMut2pF_jZavjda9sPvmQCKtVXBhs0I,1910
19
+ openmeter/_utils/_reflection.py,sha256=k20KwLejVHcQCvu4mT2S61NDvbmuXF7KsMDapiocYS0,1364
20
+ openmeter/_utils/_streams.py,sha256=SMC90diFFecpEg_zgDRVbdR3hSEIgVVij4taD-noMLM,289
21
+ openmeter/_utils/_sync.py,sha256=9ex9pfOyd8xAF1LxpFx4IkqL8k0vk8srE2Ee-OTMQ0A,2840
22
+ openmeter/_utils/_transform.py,sha256=GcsgDf2GwWGI6a7DTKRKa7JPdzcv2EFK8IHFG_8Cw5E,13226
23
+ openmeter/_utils/_typing.py,sha256=tFbktdpdHCQliwzGsWysgn0P5H0JRdagkZdb_LegGkY,3838
24
+ openmeter/_utils/_utils.py,sha256=TjqUNM5JTUa6RBa1y5_QGo2qHVC9fC0st-3iVqvZnwo,11979
25
+ openmeter/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
26
+ openmeter/resources/__init__.py,sha256=a_VUYEW8TZwhFlr_7saScHjyoBClbrKyIFhoP1lBn84,3434
27
+ openmeter/resources/events.py,sha256=T-WmpAfLiUagYg21kYLMIxiT1yJBxhdi0ps9IX1oGVs,15533
28
+ openmeter/resources/subjects.py,sha256=Ipy3tOZwcvCJZBuxVIjvgvgYl1PYqhR4bI55bQFkd3s,15991
29
+ openmeter/resources/debug/__init__.py,sha256=i1DiHRclbk3bxJ7_ULHtmFH16PvBnzCeR2rR9V__bxA,1002
30
+ openmeter/resources/debug/debug.py,sha256=trR4yTf_tQlRe_p6hOdGMlqIUqrRP4KUOzQvt_wvyNA,3616
31
+ openmeter/resources/debug/metrics.py,sha256=_dlLhJht61vHdzmgNR12AVEplLH9iXUT8oPKWe-PXgo,5322
32
+ openmeter/resources/entitlements/__init__.py,sha256=sH3TZEftiMyF1LGBrxrc52S8gmIa45Xc3gCyu0BSqYQ,1556
33
+ openmeter/resources/entitlements/entitlements.py,sha256=RQjcfQd__EIxRrRSjVPMW6DR2RJQAgxU5E-9U6vLoR8,16589
34
+ openmeter/resources/entitlements/features.py,sha256=osjbTfC9Ug-bP0lPSpUxuwpJ6zovGHlKie0neO_F1Pw,21935
35
+ openmeter/resources/entitlements/grants.py,sha256=nn4sRT760jtZVgRksgyZ5H4l0o3mDmp78DjMkDiUW5w,14664
36
+ openmeter/resources/meters/__init__.py,sha256=Yzi9o-c85IYuJGNTCZ71i5oXucN5wrgmW27qgcUufPM,1028
37
+ openmeter/resources/meters/meters.py,sha256=kSAKsgXG1GNAdRU-eFOPZ5EenKGLdyhuzO4-G5CSn-o,25299
38
+ openmeter/resources/meters/subjects.py,sha256=2VKJrjArilHnKVGDix0QDjOlon16jojw-KprDrgbGxw,6026
39
+ openmeter/resources/notifications/__init__.py,sha256=rPipbEGzscTomYuuHocZWjMBHQgGYwgXurOKkOkcQJg,2469
40
+ openmeter/resources/notifications/channels.py,sha256=_A9oLIn1T6qh7CCvFYH12GdDHwbhyERJsT7_Pd9efpA,25331
41
+ openmeter/resources/notifications/events.py,sha256=KO1uB1Rl8CMgyfGoSjNi7JykSI4pwf2uUhMK2TkurBU,12994
42
+ openmeter/resources/notifications/notifications.py,sha256=ca1QTXicxVxPeIO4u77RCFdY3Y0LIO5zZv0TygNuzNA,7224
43
+ openmeter/resources/notifications/rules.py,sha256=Sj6eJ_WHlK0Z2km2FeeiZTlYznnMq0-CBnlCuoQJD3A,28768
44
+ openmeter/resources/notifications/webhook.py,sha256=fsuufYggql_Kt-TLwdEXSjkJVAypNUsGqWHro-QFx30,7236
45
+ openmeter/resources/portal/__init__.py,sha256=F0jw0w_2ZU7NQpg0rzVe1R68q39YCUe5sdjmaFKncH4,1452
46
+ openmeter/resources/portal/meters.py,sha256=VF2xfF3KVY2a_-MyYuOb4CFWAxisV-gy-4q_6UDJGew,8594
47
+ openmeter/resources/portal/portal.py,sha256=lpfIatZ-Q_j5JcsZhore0AO18vfTmwosOneQtVmH8K4,3642
48
+ openmeter/resources/portal/tokens.py,sha256=p0wT7gHVyWUavZHJP__TjSlvqpwcGT_DddjHeCMcQ3M,12600
49
+ openmeter/resources/subjects/entitlements/__init__.py,sha256=1ul6sMHxM9mEYY7bAkBeILnOVgZBGNJ5StB_6IBAwZE,1080
50
+ openmeter/resources/subjects/entitlements/entitlements.py,sha256=cuTHxkv0RM-oI0zaryV3G-9ZifYdCz0rbllpX9UN7Ss,86053
51
+ openmeter/resources/subjects/entitlements/grants.py,sha256=lTp_J4ZQ9-0vtYmKIzIEp6MUkFBf90DKlTE-lhD5pkc,19986
52
+ openmeter/types/__init__.py,sha256=5MJGEqE5KV53tO3jVQZZcOiLf-bouJjjv2zwTZwAunU,1289
53
+ openmeter/types/entitlement.py,sha256=VbaQ1hs7n5cRynMbWz8wnBx_o86c4LWiY6HbkA6j5-I,8255
54
+ openmeter/types/event_ingest_params.py,sha256=EE2SPurSNx7iZWcRFyvN7BsCxUTty9c91T_2AskWTms,1320
55
+ openmeter/types/event_ingest_response.py,sha256=b9z1NLs8zH6oXciD7Q2vBZlf6WweE3B8LtI5Ju1AiQQ,1139
56
+ openmeter/types/event_list_params.py,sha256=zdmbT9gLnvxbB6xtRAqv_9MWMazvuIsI6a5uxuC9Hag,671
57
+ openmeter/types/event_list_response.py,sha256=lFStCFHlE9fviXND1hwunx8vCkpwlLZ7IgW16lvQP4Y,228
58
+ openmeter/types/ingested_event.py,sha256=o89TYjZ0JbvTTqbpAMucglJe0CmZ0e61jGPMUwYfSJY,1635
59
+ openmeter/types/list_entitlements_result.py,sha256=tzL9SwndEvDR9OLEwUO_CBP4816cd1BFKwktUhiGCrM,793
60
+ openmeter/types/meter.py,sha256=rX35jBhpLYKQuXnauSSM4NhGOXE8Fk6jZ8KZa7J0oDI,1642
61
+ openmeter/types/meter_create_params.py,sha256=G_iispWeVoGjvDTveH3tXtrDFS7eCFJaWl7UrXJWQrI,1667
62
+ openmeter/types/meter_list_response.py,sha256=6EYkMkg3--fozx8aQRCuGnkEY4vAof6fhVVhIj0xuxo,203
63
+ openmeter/types/meter_query_params.py,sha256=OOa4104XIL5PBTQqEUl3j8YcVOvqXu-hWpZQZUdN6xA,1712
64
+ openmeter/types/meter_query_result.py,sha256=cg5uXbi8Su1m11CwIf4cjr6tTztuSk5TKzv1anUrC00,935
65
+ openmeter/types/subject.py,sha256=jqbnQGO1H0QvTooLvh4RZhnesO1KNFcHR9AETwaDhWs,1098
66
+ openmeter/types/subject_list_response.py,sha256=Oxqqex9oJ5dnJ1d6941QRfo-IvfYHQ33GP2AAz7r4hg,213
67
+ openmeter/types/subject_param.py,sha256=65AgajeEGIeyWjtsB3ZOf7cA5rdjlAC8J23F5yoS5Ow,859
68
+ openmeter/types/subject_upsert_params.py,sha256=0Ll9vVvW46rR0BhynQmYYEdczZUxyNmlVgQnz6OoaRQ,1270
69
+ openmeter/types/subject_upsert_response.py,sha256=RLkFv3MIaoe68s2HTX_9XeZWw_9CBfdxSsy6hAdx0Gw,268
70
+ openmeter/types/debug/__init__.py,sha256=QhiMy8QbFXw6F2pjAdR1RNtMxx6UYxU-a9NWpCTiNAU,198
71
+ openmeter/types/debug/metric_list_response.py,sha256=KXKg38t_U4lSIGZRbGObJM_mYt0Qew6y6OP7mN59sv0,198
72
+ openmeter/types/entitlements/__init__.py,sha256=W9aSVa_7hzF6CiRQKB2Fu7_2nHg8lj_Lj4Lc1o4DjCs,613
73
+ openmeter/types/entitlements/feature.py,sha256=KxEoVEDTR4ecEeKkdtu0RamyOO1wHZ_W8vyZyacs58k,2117
74
+ openmeter/types/entitlements/feature_create_params.py,sha256=mIL481W8dm_Wy4L2tg87AlU1-vw27j6ftH9T12pLMdI,1517
75
+ openmeter/types/entitlements/feature_list_params.py,sha256=lRD4CqCsM0HHzsZcdBFJMhyZTfhY0D-z_5LeJS7W0ME,646
76
+ openmeter/types/entitlements/grant_list_params.py,sha256=uFShJs6Qhi3GFT1feyL4_posoPwAuaTxL5skCGVvg4Y,1225
77
+ openmeter/types/entitlements/grant_list_response.py,sha256=mTY0SCA3ctEFgnfacSasAwQ4-MTYw9xeYjXEAWEsHIY,410
78
+ openmeter/types/entitlements/grant_paginated_response.py,sha256=mA6dgbNLunEbTcpo2Wd13J-q2LXsup7u4Ke1c9tRb4s,655
79
+ openmeter/types/entitlements/list_features_result.py,sha256=KbncqHS6a84bV-Typlt-FIq9YoluwfXzU3-Ggm6bbMQ,758
80
+ openmeter/types/meters/__init__.py,sha256=NmZqQXB-C1cgrVLbB7x70B9KR5E2-2CTfb0XX0k47-A,201
81
+ openmeter/types/meters/subject_list_response.py,sha256=tQnTfNA2eLkOC-Nizg1W0J175QjeYvbN7g5DmRFRy10,230
82
+ openmeter/types/notifications/__init__.py,sha256=uOd-oWkxWTsUIeurlIa8l1CB7K9EJR6aY41LfdpKEAg,1125
83
+ openmeter/types/notifications/channel_create_params.py,sha256=jQptAB61qYzyA1fh4ys13TFgOzI9asAPn7PedhhNTLQ,1050
84
+ openmeter/types/notifications/channel_list_params.py,sha256=Ywo6-l2SPYc2E65vmkTXRTfZIaB7oPUUtnzpJ3ACPdU,1069
85
+ openmeter/types/notifications/channel_list_response.py,sha256=WTigqJUwMslMTQCAufxwB-h48WjRJ8iDujy0yOLzdn8,635
86
+ openmeter/types/notifications/channel_update_params.py,sha256=S0qJ_-i7AsXOZsys44JVZbPtu-sv20UvwAOCeE6oE9g,1050
87
+ openmeter/types/notifications/event_list_params.py,sha256=u4qtQEGKFbzF95USxMQiBeF0sMsaVyzvzwmXWGcHlR4,1593
88
+ openmeter/types/notifications/event_list_response.py,sha256=smq00WziFL-XA_9SXe8ZsDMdSXPS6oSlHYNC_FQr0MI,625
89
+ openmeter/types/notifications/notification_channel.py,sha256=bBuiQBNBQblXkWERn02eiluEUcSfILd-gD-sCrDUiVQ,1491
90
+ openmeter/types/notifications/notification_event.py,sha256=vmJwx-Gor4GWmdDZZv1c_sUCMat38SO_01O1L1l6gjo,7275
91
+ openmeter/types/notifications/notification_rule.py,sha256=SuSF7WCUF9Bc1x8-z2xE5hoCfwzRvYdEhf2otRHQFLU,1960
92
+ openmeter/types/notifications/rule_create_params.py,sha256=Oj_-KpVQukMF8S2a3nzggb70A2l8eJzqfwy42Ae4AfY,1137
93
+ openmeter/types/notifications/rule_list_params.py,sha256=IrVH_tJ9S1ZL1fvvFsvdfil4DSmgNcyNF_-NFf8Q3MU,1383
94
+ openmeter/types/notifications/rule_list_response.py,sha256=cveRoTMYUzTT1OGK7lpReVJf6SZEfQtogeyWjRnwfBw,620
95
+ openmeter/types/notifications/rule_update_params.py,sha256=jP2nJHzoipMEEr4QXXSxD-ZNghalB743TOQCb4rU398,1137
96
+ openmeter/types/notifications/webhook_svix_params.py,sha256=q4wzb0lpZ-gKNAzoYH754PdFqJu8kuTkCqbtcbsYl4Q,752
97
+ openmeter/types/portal/__init__.py,sha256=gI33ROkgvYRxW3NkRa7hjbsoTvhOpbN-39G7BhBq7Fg,539
98
+ openmeter/types/portal/meter_query_params.py,sha256=ouiwPhawBCQhrwAALqx_toPERVlWE-q3c3K964AFduY,1591
99
+ openmeter/types/portal/portal_token.py,sha256=BSphEYFgAdVsiJ6QGlEII5QpScu1lm6TjUsT768Uqjw,785
100
+ openmeter/types/portal/token_create_params.py,sha256=utND-6gSL9qkzt3swiwqwaBr9B9iAyW0bcg72UwTZB0,516
101
+ openmeter/types/portal/token_invalidate_params.py,sha256=1ouivcYJmFjoQHtNmWv5MeYyR5JtSHCKzkVbdeSJYpI,382
102
+ openmeter/types/portal/token_list_params.py,sha256=sbBS7NG5S3r7UFEC9u4iDY7b6sYnyaThZ_hhgMXo2E4,318
103
+ openmeter/types/portal/token_list_response.py,sha256=8C8OatX2OxwolBAdUU9Z_A-s2t18kOP3V8CLJr_eQUA,222
104
+ openmeter/types/shared/__init__.py,sha256=mGzQA_VTLBYC3uoEIsYVNFSzaIpraFcEXfIJIJKCdmw,156
105
+ openmeter/types/subjects/__init__.py,sha256=6ugje4JohPzxHUW0hdWay6mpsjqomw8RuAEuiJVTSqk,917
106
+ openmeter/types/subjects/entitlement_history_params.py,sha256=urxLIbaHaeIEFnKXv3p1dicV0l-UVY9JUaKNRwlpn2s,1261
107
+ openmeter/types/subjects/entitlement_history_response.py,sha256=MPT9UImu2Rs3NFFG-W5zw3Q_JSMggiE73na9cbzDEIY,2809
108
+ openmeter/types/subjects/entitlement_list_response.py,sha256=YAbG2paLTkrRyzBcz9hy44AMobjgUOmjO1KgOUnm-Qo,285
109
+ openmeter/types/subjects/entitlements/__init__.py,sha256=LfpcXqUtZD38OvRqWMPd1K-uXgclcYtsEm7MaL-rjK4,401
110
+ openmeter/types/subjects/entitlements/entitlement_grant.py,sha256=F37q1ZfXhn_d8M-CfJzsIymfCNFzt5eV_JfC2qkOOoI,3823
111
+ openmeter/types/subjects/entitlements/grant_list_response.py,sha256=nqhIEbp0mrg6NmaSYoWlWNYYJpK0O4-BY269JpBU9Es,288
112
+ openmeter-2.0.0.dist-info/METADATA,sha256=w5N-hKfMFRMq_wZYqqkFa4fHVkm3LS2WLP1jRHlGqoI,13516
113
+ openmeter-2.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
114
+ openmeter-2.0.0.dist-info/licenses/LICENSE,sha256=6EZqtGryus-cRnaX-f1Ro8tjdJ4h-Jb_GmfG3GCpN7Q,11340
115
+ openmeter-2.0.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: hatchling 1.25.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any