Skip to main content

Tool for monitoring LLM inference metrics

Project description

llm-perf-tools

Prerequisites

  • Python 3.10+
  • pyenv (recommended)
  • Poetry
  • OpenAI API access

Setup

pyenv local 3.10
python -m venv .venv
source .venv/bin/activate
make install

Environment

Create .env file:

# OpenAI config
OPENAI_API_KEY=your_api_key_here
OPENAI_BASE_URL=https://api.openai.com/v1/

# Optional: Langfuse config
LANGFUSE_SECRET_KEY=your_secret_key
LANGFUSE_PUBLIC_KEY=your_public_key
LANGFUSE_HOST=https://us.cloud.langfuse.com

Usage

Basic InferenceTracker usage:

import asyncio
import os
from openai import AsyncOpenAI
from llm_perf_tools import InferenceTracker
from dotenv import load_dotenv

load_dotenv()


async def main():
    client = AsyncOpenAI(
        api_key=os.getenv("OPENAI_API_KEY"),
        base_url=os.getenv("OPENAI_BASE_URL", "https://api.openai.com/v1"),
    )
    tracker = InferenceTracker(client)

    # Track a request
    response = await tracker.create_chat_completion(
        messages=[{"role": "user", "content": "Hello"}],
        model="gpt-5",
    )
    print(response)

    # Get performance metrics
    stats = tracker.compute_metrics()
    print("Metrics:\n")
    print(f"TTFT: {stats.avg_ttft:.3f}s")
    print(f"Throughput: {stats.rps:.2f} req/s")


asyncio.run(main())

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_perf_tools-0.1.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

llm_perf_tools-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file llm_perf_tools-0.1.0.tar.gz.

File metadata

  • Download URL: llm_perf_tools-0.1.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.5 Darwin/24.6.0

File hashes

Hashes for llm_perf_tools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9dda04a17953e9fe6e1187e42af3be1f4a4b90c41b58456cd887d1276d961694
MD5 c2647d68c93691529df46d7ac4f69619
BLAKE2b-256 fda2a12c47114fc353c05c6cb19da0ee0f97b34bcf4634c11488847edbd10e39

See more details on using hashes here.

File details

Details for the file llm_perf_tools-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: llm_perf_tools-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.5 Darwin/24.6.0

File hashes

Hashes for llm_perf_tools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d8c6a9e2f13d3646344bf3b0255b03394103620a418c5a0c84f1756bdfa8177
MD5 92caf99505897787daf6c656dd891830
BLAKE2b-256 d584bbd4010002f31bbe58716d96f13730da904ea67b4a01c453fd5617998512

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