OpenMeter Python Client

raw JSON →
1.0.0b227 verified Mon Apr 27 auth: no python

A Python client for OpenMeter, a real-time and scalable usage metering service. This beta version (1.0.0b227) requires Python 3.9+ and is under active development. The library provides programmatic access to OpenMeter APIs for tracking and querying usage metrics.

pip install openmeter
error import openmeter
cause Using import openmeter directly instead of importing the class.
fix
Use: from openmeter import OpenMeter
error openmeter.OpenMeter is not callable
cause Trying to instantiate OpenMeter without importing the correct symbol.
fix
Correct import: from openmeter import OpenMeter
gotcha The client uses httpx under the hood, which may cause SSL issues in some environments. If you encounter SSL errors, set verify=False in the OpenMeter constructor or configure custom SSL context.
fix client = OpenMeter(..., verify=False)
gotcha API keys are required for non-local setups. If you don't set an API key, requests might fail with 401 Unauthorized. Always provide an API key via environment variable or direct parameter.
fix Set OPENMETER_API_KEY environment variable or pass api_key='your_key'.
deprecated The library is in beta (1.0.0b227) and APIs may change without notice. Methods and parameters might be deprecated or removed in future minor versions.
fix Pin to a specific beta version and watch the changelog.

Initialize the client with a base URL and API key (optional, retrieved from environment). Then call client.meters.list() to fetch meters.

from openmeter import OpenMeter

client = OpenMeter(
    base_url="http://localhost:8888",
    api_key=os.environ.get("OPENMETER_API_KEY", "")
)
# Example: list all meters
try:
    meters = client.meters.list()
    print(meters)
except Exception as e:
    print(f"Error: {e}")