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)

# 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.2.0

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.2.0
File Size Uploaded
fiscallm-0.2.0.tar.gz 8.8 kB Details

Built distribution (wheel)

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

Total release size: 16.7 kB

Release files / fiscallm-0.2.0.tar.gz

Download URL fiscallm-0.2.0.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a1e55cdbf806761e83434b063b5086c9a34ceb73340724ceb8a3c25c18dbe78e
BLAKE2b-256 checksum
How to use checksums
f7f61571efb3615b221e1f62c9904ad5aea7b0377396e734a1114d9ebf35df4d
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.2.0-py3-none-any.whl

Download URL fiscallm-0.2.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43289b320dda38a0f56ba3032b6c39f858d6c7d0bc30a87eacf0e60536456ebf
BLAKE2b-256 checksum
How to use checksums
37d42be131f8d0c1039a9c3ec11efeaff5ab391c548b5e7cbbfeab923be241a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release history Release notifications | RSS feed

0.3.1

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

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