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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openmeter-1.0.0b176.tar.gz (64.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openmeter-1.0.0b176-py3-none-any.whl (71.1 kB view details)

Uploaded Python 3

File details

Details for the file openmeter-1.0.0b176.tar.gz.

File metadata

  • Download URL: openmeter-1.0.0b176.tar.gz
  • Upload date:
  • Size: 64.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 PyPy/7.3.16 Linux/6.5.0-1024-aws

File hashes

Hashes for openmeter-1.0.0b176.tar.gz
Algorithm Hash digest
SHA256 362f78fc0edb51c527fde5e4681cc33c3eed47e9437e4d0f33a164943d21ebac
MD5 e6975c616063ac32ee5a887bec40d31e
BLAKE2b-256 47511d1c0d3c653bc7d2a73189cff24479a3b6ebcc72a197218b9e8963d985b1

See more details on using hashes here.

File details

Details for the file openmeter-1.0.0b176-py3-none-any.whl.

File metadata

  • Download URL: openmeter-1.0.0b176-py3-none-any.whl
  • Upload date:
  • Size: 71.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 PyPy/7.3.16 Linux/6.5.0-1024-aws

File hashes

Hashes for openmeter-1.0.0b176-py3-none-any.whl
Algorithm Hash digest
SHA256 0119747b496e941a5e140d16f6a7e6734f3bee2ac3c6f5db32355c324209873e
MD5 549f5de05aa98d394c92532b6ed2dab5
BLAKE2b-256 2f964110f3ed25fa4191e22d5665948cc7db735c15331b166fe2a4b2a64af402

See more details on using hashes here.

Release history Release notifications | RSS feed

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page