Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

OpenMeter Python SDK

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

Prerequisites

Python version: >= 3.9

Install

The Python SDK is in preview mode.

pip install openmeter

Quickstart

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

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:

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:

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

Release files for openmeter 1.0.0b149

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openmeter 1.0.0b149
File Size Uploaded
openmeter-1.0.0b149.tar.gz 64.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openmeter 1.0.0b149
File Interpreter ABI Platform
openmeter-1.0.0b149-py3-none-any.whl Python 3 none any Details

Total release size: 134.9 kB

Release files / openmeter-1.0.0b149.tar.gz

Download URL openmeter-1.0.0b149.tar.gz
Size 64.0 kB
Tags Source
SHA-256 checksum
How to use checksums
945b85c72f950618bb6530ff1fe6e00ba1d4b7d0f4121d1b677c90374f4e2f8b
BLAKE2b-256 checksum
How to use checksums
542f0324f76919271ae9ff2c130602c5e16583e702816cb7e67aa859ccf27961
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 PyPy/7.3.16 Linux/6.5.0-1024-aws

Release files / openmeter-1.0.0b149-py3-none-any.whl

Download URL openmeter-1.0.0b149-py3-none-any.whl
Size 71.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ea4354379e693b4a7a27814efa61660345e53abbdcbcf317093445251b55226
BLAKE2b-256 checksum
How to use checksums
8f86bdca71d8a7587d4d68bdd4b9c143e3344b5c0697a19aae92042ac6176ae0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 PyPy/7.3.16 Linux/6.5.0-1024-aws

Release history Release notifications | RSS feed

2.0.0

2 release files

This release

1.0.0b149 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page