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").
Metadata
Release files for fiscallm 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fiscallm-0.3.1.tar.gz | 9.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fiscallm-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.2 kB
Release files / fiscallm-0.3.1.tar.gz
| Download URL | fiscallm-0.3.1.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fadb33cccecd4c3c61ca4dec21b7c536dd483eebac673ddecc2ccca51dd2274a
|
|
BLAKE2b-256 checksum How to use checksums |
ef6665a11e483f6c1c4f968ca1ccc3e0c724d34071941b52866e9fbc782b70e6
|
| 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.1-py3-none-any.whl
| Download URL | fiscallm-0.3.1-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9495f35f54102ef3afc5859c97a8259ad86bc90a4d09ab2626147b6d871d7ac
|
|
BLAKE2b-256 checksum How to use checksums |
7ea7bde9a5eead773ca794f166b57fb25f50cf4f5ede2991bb2f2ee2100b05a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|