Documentation

Lutflow SDK

Budget enforcement for AI inference workloads. 3 lines of code. Result in 60 seconds.

OpenAI
Anthropic
Google Gemini
Self-hosted (vLLM)

Quickstart

Get running in under 60 seconds

1
Install the SDK
pip install lutflow
2
Wrap your AI client
from lutflow import Client
import openai

client = Client(tenant_id="acme", budget_usd=10.00)
wrapped = client.wrap(openai.OpenAI())
response = wrapped.chat.completions.create(model="gpt-4o", messages=[{"role": "user", "content": "Hello!"}])
3
Done. Lutflow tracks every token and enforces your budget.

No API key required for local mode

The SDK works entirely offline. Add an API key later to enable cloud reporting and the full kill path.

Provider Examples

from lutflow import Client
import openai

client = Client(tenant_id="acme", budget_usd=10.00)
wrapped = client.wrap(openai.OpenAI())
response = wrapped.chat.completions.create(model="gpt-4o", messages=[{"role": "user", "content": "Hello!"}])

Supports chat completions, embeddings, and streaming.

Budget Strategies

RAISE_ERROR

Raises BudgetExceededError (default)

WARN_ONLY

Logs warning, continues execution

CALLBACK

Calls your custom function

SELF_KILL

Sends SIGKILL to the process

from lutflow import Client, BudgetStrategy

# Option 1: Raise error (default)
client = Client(
    tenant_id="acme",
    budget_usd=10.00,
    on_budget_exceeded=BudgetStrategy.RAISE_ERROR,
)

# Option 2: Warning only
client = Client(
    tenant_id="acme",
    budget_usd=10.00,
    on_budget_exceeded=BudgetStrategy.WARN_ONLY,
)

# Option 3: Custom callback
def my_handler(spent: float, budget: float):
    send_slack_alert(f"Budget exceeded: ${spent:.2f} / ${budget:.2f}")

client = Client(
    tenant_id="acme",
    budget_usd=10.00,
    on_budget_exceeded=BudgetStrategy.CALLBACK,
    on_exceeded_callback=my_handler,
)

CLI Commands

# Install
pip install lutflow

# GPU price lookup
lutflow lookup --gpu nvidia-l4

# Model recommendation
lutflow recommend --task text-classification --budget 0.50

# Live dashboard (simulated)
lutflow watch

Installation Options

pip install lutflowCore + CLI
pip install lutflow[openai]With OpenAI wrapper
pip install lutflow[anthropic]With Anthropic wrapper
pip install lutflow[gemini]With Google Gemini wrapper
pip install lutflow[all]All providers + Kafka transport

Ready to control your AI costs?

Start with the free SDK for local budget tracking. Upgrade to Lutflow Cloud for real-time enforcement and the full kill path.