Skip to main content

Official Python SDK for LLM Cost Monitor - Track, aggregate, and analyze LLM usage costs

Project description

llmcost

Open-source LLM cost observability platform API. Track, aggregate, and analyze LLM usage costs across your applications.

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: v1.0.0
  • Package version: 1.0.0
  • Generator version: 7.18.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen

Requirements.

Python 3.9+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)

Then import the package:

import llmcost

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import llmcost

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

import llmcost
from llmcost.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost:8080
# See configuration.py for a list of all supported configuration parameters.
configuration = llmcost.Configuration(
    host = "http://localhost:8080"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'


# Enter a context with an instance of the API client
with llmcost.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = llmcost.AlertsApi(api_client)
    create_alert_request = {"threshold":100.0,"window_interval":"24h"} # CreateAlertRequest | 

    try:
        # Create budget alert
        api_response = api_instance.create_alert(create_alert_request)
        print("The response of AlertsApi->create_alert:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling AlertsApi->create_alert: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to http://localhost:8080

Class Method HTTP request Description
AlertsApi create_alert POST /v1/alerts Create budget alert
AlertsApi delete_alert DELETE /v1/alerts/{id} Delete alert
AlertsApi list_alerts GET /v1/alerts List budget alerts
EventsApi create_event POST /v1/events Track LLM usage event
EventsApi list_events GET /v1/events List LLM usage events
MetricsApi get_metrics GET /v1/metrics Get aggregated metrics
PricingApi list_pricing GET /v1/pricing List model pricing

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

ApiKeyAuth

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

Author

Project details


Download files

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

Source Distribution

llm_cost_monitor-1.0.0.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

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

llm_cost_monitor-1.0.0-py3-none-any.whl (46.6 kB view details)

Uploaded Python 3

File details

Details for the file llm_cost_monitor-1.0.0.tar.gz.

File metadata

  • Download URL: llm_cost_monitor-1.0.0.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.1

File hashes

Hashes for llm_cost_monitor-1.0.0.tar.gz
Algorithm Hash digest
SHA256 61b5451ca71be28f10391be0c5512797914ed6ef03f4e99c161027c5f7d6461c
MD5 94897ccdc191fbd92c017d9866f61581
BLAKE2b-256 812e26f531babd4b10a956978cc6487c5ad17e512e8ae0d68b28410f800570d7

See more details on using hashes here.

File details

Details for the file llm_cost_monitor-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_cost_monitor-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a04f43a53ff0ef41d5ffd629d496d7c0e8e44ebf385a2ee8e5c89d0be3ed4bd8
MD5 d4b17adc147b2d7e828ace26b148bfce
BLAKE2b-256 62c07d68f9d516be7428bd80072ad52c15324ccf0bafea0028992ddfffb157ea

See more details on using hashes here.

Supported by

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