Metadata-Version: 2.4
Name: lutflow
Version: 0.1.0a1
Summary: GPU Financial Firewall — budget enforcement for AI inference
Project-URL: Homepage, https://lutflow.dev
Project-URL: Documentation, https://docs.lutflow.dev/sdk/python
Project-URL: Repository, https://github.com/Lutflow/lutflow
Project-URL: Issues, https://github.com/Lutflow/lutflow/issues
Author-email: "Lutflow Inc." <oscar@lutflow.com>
License: Business Source License 1.1
        
        Parameters
        
        Licensor:             Lutflow Inc.
        Licensed Work:        Lutflow SDK
                              The Licensed Work is (c) 2026 Lutflow Inc.
        Additional Use Grant: You may make use of the Licensed Work, provided that
                              you do not use the Licensed Work for a GPU Cost Management
                              Service.
        
                              A "GPU Cost Management Service" is a commercial offering
                              that allows third parties to access the functionality of
                              the Licensed Work by performing any of the following:
                              (a) offering budget enforcement, cost tracking, or kill-path
                                  functionality for GPU or AI inference workloads as a
                                  managed service;
                              (b) offering the Licensed Work to third parties as a
                                  commercial cloud service, hosted service, or
                                  software-as-a-service.
        
                              For clarity, the following uses are permitted:
                              - Internal use within your organization
                              - Development, testing, and evaluation
                              - Non-commercial and educational use
                              - Integration into your own products that do not compete
                                with Lutflow's commercial offerings
        
        Change Date:          March 29, 2030
        Change License:       Apache License, Version 2.0
        
        For information about alternative licensing arrangements for the Licensed Work,
        please contact: licensing@lutflow.com
        
        -----------------------------------------------------------------------------
        
        Business Source License 1.1
        
        License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
        "Business Source License" is a trademark of MariaDB Corporation Ab.
        
        Terms
        
        The Licensor hereby grants you the right to copy, modify, create derivative
        works, redistribute, and make non-production use of the Licensed Work. The
        Licensor may make an Additional Use Grant, above, permitting limited
        production use.
        
        Effective on the Change Date, or the fourth anniversary of the first publicly
        available distribution of a specific version of the Licensed Work under this
        License, whichever comes first, the Licensor hereby grants you rights under
        the terms of the Change License, and the rights granted in the paragraph
        above terminate.
        
        If your use of the Licensed Work does not comply with the requirements
        currently in effect as described in this License, you must purchase a
        commercial license from the Licensor, its affiliated entities, or authorized
        resellers, or you must refrain from using the Licensed Work.
        
        All copies of the original and modified Licensed Work, and derivative works
        of the Licensed Work, are subject to this License. This License applies
        separately for each version of the Licensed Work and the Change Date may vary
        for each version of the Licensed Work released by Licensor.
        
        You must conspicuously display this License on each original or modified copy
        of the Licensed Work. If you receive the Licensed Work in original or
        modified form from a third party, the terms and conditions set forth in this
        License apply to your use of that work.
        
        Any use of the Licensed Work in violation of this License will automatically
        terminate your rights under this License for the current and all other
        versions of the Licensed Work.
        
        This License does not grant you any right in any trademark or logo of
        Licensor or its affiliates (provided that you may use a trademark or logo of
        Licensor as expressly required by this License).
        
        TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
        AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
        EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
        MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
        TITLE.
        
        MariaDB hereby grants you permission to use this License's text to license
        your works, and to refer to it using the trademark "Business Source License",
        as long as you comply with the Covenants of Licensor below.
        
        Covenants of Licensor
        
        In consideration of the right to use this License's text and the "Business
        Source License" name and trademark, Licensor covenants to MariaDB, and to all
        other recipients of the licensed work to be provided by Licensor:
        
        1. To specify as the Change License the GPL Version 2.0 or any later version,
           or a license that is compatible with GPL Version 2.0 or a later version,
           where "compatible" means that software provided under the Change License can
           be included in a program with software provided under GPL Version 2.0 or a
           later version. Licensor may specify additional Change Licenses without
           limitation.
        
        2. To either: (a) specify an additional grant of rights to use that does not
           impose any additional restriction on the right granted in this License, as
           the Additional Use Grant; or (b) insert the text "None".
        
        3. To specify a Change Date.
        
        4. Not to modify this License in any other way.
License-File: LICENSE
Keywords: ai,anthropic,budget,cost-management,enforcement,finops,gpu,llm,openai
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Requires-Dist: click>=8.1.0
Requires-Dist: httpx>=0.25.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: rich>=13.0.0
Requires-Dist: tiktoken>=0.5.0
Provides-Extra: all
Requires-Dist: anthropic>=1.0.0; extra == 'all'
Requires-Dist: confluent-kafka>=2.3.0; extra == 'all'
Requires-Dist: fastavro>=1.9.0; extra == 'all'
Requires-Dist: openai>=1.0.0; extra == 'all'
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.18.0; extra == 'anthropic'
Provides-Extra: dev
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: kafka
Requires-Dist: confluent-kafka>=2.3.0; extra == 'kafka'
Requires-Dist: fastavro>=1.9.0; extra == 'kafka'
Provides-Extra: openai
Requires-Dist: openai>=1.0.0; extra == 'openai'
Description-Content-Type: text/markdown

# Lutflow — GPU Financial Firewall

Budget enforcement for AI inference workloads. Track costs, enforce budgets, kill runaway GPU spending in real time.

```bash
pip install lutflow
```

## 5-Line Quickstart

```python
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!"}])
```

Lutflow tracks every token, calculates cost, and terminates the process if the budget is exceeded.

## CLI

```bash
# GPU price lookup (powered by TinyFish)
lutflow lookup --gpu nvidia-l4

# Deploy with budget enforcement
lutflow deploy --model TinyLlama/TinyLlama-1.1B-Chat-v1.0 --budget 0.10

# Live dashboard
lutflow watch

# Check deployment status
lutflow status <deployment_id>

# Manual kill
lutflow kill <deployment_id> --reason overspend
```

## Installation

```bash
pip install lutflow            # Core + CLI
pip install lutflow[openai]    # With OpenAI wrapper
pip install lutflow[anthropic] # With Anthropic wrapper
pip install lutflow[all]       # All providers + Kafka transport
```

## SDK Usage

### Token-Based Pricing (API Providers)

```python
from lutflow import Client, BudgetStrategy

client = Client(
    tenant_id="my-tenant",
    api_key="lut_xxx",
    budget_usd=10.00,
    on_budget_exceeded=BudgetStrategy.RAISE_ERROR,
)

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

print(f"Spent: ${client.accumulated_cost_usd:.4f}")
print(f"Remaining: ${client.remaining_budget_usd:.4f}")
```

### GPU-Time Pricing (Self-Hosted Models)

```python
from lutflow import Client, PricingMode

client = Client(
    tenant_id="my-tenant",
    budget_usd=5.00,
    pricing_mode=PricingMode.GPU_TIME,
    gpu_type="nvidia-l4",
)

client.start_gpu_timer()
# ... run inference ...
cost = client.stop_gpu_timer()
```

### GPU Price Lookup (TinyFish)

```python
from lutflow.tinyfish import TinyFishClient

tf = TinyFishClient()  # Uses TINYFISH_API_KEY env var
result = tf.fetch_all_prices(gpu_type="nvidia-l4")

best = result.cheapest
print(f"Cheapest: {best.provider} at ${best.spot_usd_per_hour:.2f}/hr")
```

## Budget Strategies

| Strategy | Behavior |
|----------|----------|
| `SELF_KILL` | Sends `SIGKILL` to the process (default) |
| `RAISE_ERROR` | Raises `BudgetExceededError` |
| `WARN_ONLY` | Logs warning, continues execution |
| `CALLBACK` | Calls a custom function you provide |

## Supported Providers

- **OpenAI** — GPT-4o, GPT-4, GPT-3.5, embeddings
- **Anthropic** — Claude 3.5, Claude 3 Opus/Sonnet/Haiku
- **Google** — Gemini 1.5 Pro/Flash
- **Self-hosted** — vLLM, TGI, BentoML (GPU-time pricing)

## Environment Variables

| Variable | Description |
|----------|-------------|
| `LUTFLOW_ENDPOINT` | API endpoint (default: `https://api.lutflow.dev`) |
| `TINYFISH_API_KEY` | TinyFish API key for live GPU pricing |

## Links

- **Website**: [lutflow.dev](https://lutflow.dev)
- **Docs**: [docs.lutflow.dev/sdk/python](https://docs.lutflow.dev/sdk/python)
- **GitHub**: [github.com/Lutflow/lutflow](https://github.com/Lutflow/lutflow)

## License

Business Source License 1.1 (BSL 1.1)

- **Free for**: internal use, development, testing, evaluation, non-commercial use
- **Commercial license required for**: offering GPU cost management as a service
- **Change Date**: March 29, 2030 (converts to Apache 2.0)

See [LICENSE](LICENSE) for full terms. For commercial licensing: licensing@lutflow.com
