Metadata-Version: 2.1
Name: openmeter
Version: 1.0.0b32
Summary: Client for OpenMeter: Real-Time and Scalable Usage Metering
Home-page: https://openmeter.io
License: Apache-2.0
Keywords: openmeter,api,client,usage,usage-based,metering,ai,aggregation,real-time,billing,cloud
Author: Andras Toth
Author-email: 4157749+tothandras@users.noreply.github.com
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Provides-Extra: aio
Requires-Dist: aiohttp (>=3.0) ; extra == "aio"
Requires-Dist: azure-core (>=1.29.4,<2.0.0)
Requires-Dist: cloudevents (>=1.10.0,<2.0.0)
Requires-Dist: isodate (>=0.6.1,<0.7.0)
Project-URL: Repository, https://github.com/openmeter/openmeter
Description-Content-Type: text/markdown

# OpenMeter Python SDK

[https://pypi.org/project/openmeter](On PyPI)

## Prerequisites

Python version: >= 3.9

## Install

> The Python SDK is in preview mode.

```sh
pip install openmeter
```

## Quickstart

The client can be initialized with `openmeter.Client()`:

```python
from os import environ
from openmeter import Client

ENDPOINT = environ.get("OPENMETER_ENDPOINT") or "http://localhost:8888"

# it's recommended to also set the Accept header at the client level
client = Client(
    endpoint=ENDPOINT,
    headers={"Accept": "application/json"},
)
```

**Async** client can be initialized by importing the `Client` from `openmeter.aio`.

Ingest events:

```python
from cloudevents.http import CloudEvent
from cloudevents.conversion import to_dict

event = CloudEvent(
    attributes={
        "type": "tokens",
        "source": "openmeter-python",
        "subject": "user-id",
    },
    data={
        "prompt_tokens": 5,
        "completion_tokens": 10,
        "total_tokens": 15,
        "model": "gpt-3.5-turbo",
    },
)

resp = client.ingest_events(to_dict(event))
```

## Publish

Update version number in `pyproject.toml`.
Run the following commands:

```sh
poetry config pypi-token.pypi {your_pypi_api_token}
poetry publish --build
```

