Skip to main content

fiscallm

Track the AI cost of each user of your app against their subscription revenue. Zero dependencies, Python 3.9+.

The SDK never sits in the path of your AI calls: tracking only queues an event, a background thread sends batches, and it never raises. Prompts and responses are never sent, only token counts.

pip install fiscallm
import os
from fiscallm import Meter

meter = Meter(api_key=os.environ["FISCALLM_KEY"])  # one per process

# user_id must be the user's RevenueCat app user ID.
res = openai_client.chat.completions.create(model=model, messages=messages)
meter.track_openai(res, user_id=user_id, feature="chat")

meter.track_anthropic(message, user_id=user_id)
meter.track_gemini(result, user_id=user_id)

# Streams (sync or async): iterate the returned stream.
stream = meter.track_stream(
    openai_client.chat.completions.create(model=model, messages=messages, stream=True,
                                          stream_options={"include_usage": True}),
    user_id=user_id,
)

# Priced per unit (FiscaLLM knows the price): minutes, seconds, characters, images
meter.track(user_id=user_id, provider="openai", model="whisper-1", units=12.5, unit="minute")
meter.track(user_id=user_id, provider="google", model="veo-3.1-fast-generate-preview",
            units=8, unit="second", variant="1080p")

# Anything else: the exact cost
meter.track(user_id=user_id, provider="fal", model="flux-pro", cost_usd=0.05)

# No RevenueCat? Report payments yourself:
meter.track_revenue(id=invoice_id, user_id=user_id, type="renewal", amount_usd=9.99, fee_pct=0.15)

# Serverless (AWS Lambda, Cloud Functions): before returning
meter.flush()          # or: await meter.aflush()

OpenAI-compatible APIs work with meter.track_openai(res, user_id=user_id, provider="groq").

Docs: https://fiscallm.com/docs

Metadata

Release files for fiscallm 0.3.2

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

Source distribution (sdist)

Source distribution for fiscallm 0.3.2
File Size Uploaded Provenance
fiscallm-0.3.2.tar.gz 10.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 18.8 kB

Release files / fiscallm-0.3.2.tar.gz

Download URL fiscallm-0.3.2.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e4be0a48ec12888d5c871e22ba181144915da97082f8f716608cca3e78234c42
BLAKE2b-256 checksum
How to use checksums
a737a65be05aceecc48f9dd4c1a9af035aba56f533227e296df2fd3ca4f0d37b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release files / fiscallm-0.3.2-py3-none-any.whl

Download URL fiscallm-0.3.2-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4cdd32aa36a5fd8921989e29b43ba94ed316254136b9409e81244a664d045308
BLAKE2b-256 checksum
How to use checksums
e5ef7d04801c4389b4e7e02b3aa441a1dd7f370ac74e971daa38522910ea79a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Security for fiscallm 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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