Metadata-Version: 2.4
Name: gavio
Version: 0.2.0
Summary: The open standard AI gateway for production systems — PII protection, audit trails, reliability, and cost control as composable interceptors.
Project-URL: Homepage, https://gavio.io
Project-URL: Repository, https://github.com/gavio-ai/gavio
Project-URL: Changelog, https://github.com/gavio-ai/gavio/blob/main/CHANGELOG.md
Author: Manoj Mallick
License: MIT
Keywords: ai,ai-gateway,anthropic,audit,cost-tracking,gateway,interceptor,llm,llm-gateway,llmops,observability,openai,pii,pii-redaction,reliability
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.10
Provides-Extra: all
Requires-Dist: elasticsearch; extra == 'all'
Requires-Dist: opentelemetry-exporter-otlp; extra == 'all'
Requires-Dist: opentelemetry-sdk; extra == 'all'
Requires-Dist: pgvector; extra == 'all'
Requires-Dist: presidio-analyzer; extra == 'all'
Requires-Dist: psycopg2; extra == 'all'
Requires-Dist: redis; extra == 'all'
Requires-Dist: spacy; extra == 'all'
Provides-Extra: dev
Requires-Dist: mypy>=1.8; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Provides-Extra: elasticsearch
Requires-Dist: elasticsearch; extra == 'elasticsearch'
Provides-Extra: otel
Requires-Dist: opentelemetry-exporter-otlp; extra == 'otel'
Requires-Dist: opentelemetry-sdk; extra == 'otel'
Provides-Extra: pgvector
Requires-Dist: pgvector; extra == 'pgvector'
Requires-Dist: psycopg2; extra == 'pgvector'
Provides-Extra: presidio
Requires-Dist: presidio-analyzer; extra == 'presidio'
Requires-Dist: spacy; extra == 'presidio'
Provides-Extra: redis
Requires-Dist: redis; extra == 'redis'
Description-Content-Type: text/markdown

# Gavio — Python SDK

> The open standard AI gateway for production systems. PII protection, audit
> trails, reliability, and cost control as composable interceptors.

`gavio` sits between your application and any LLM provider. The same request
passes through a pre/post interceptor chain — PII redaction, retries, cost
tracking, audit logging — before and after the provider call.

Part of the [Gavio](https://gavio.io) project. MIT licensed.

## Install

```bash
pip install gavio            # zero mandatory dependencies
pip install gavio[dev]       # + pytest, ruff, mypy
```

Requires Python 3.10+.

## Quick start (dev mode — no API key, no network)

```python
import asyncio
from gavio import Gateway
from gavio.interceptors.pii import PiiGuard

gw = (
    Gateway.builder()
    .dev_mode(True)                 # MockProvider + stdout audit
    .use(PiiGuard())                # redact PII before it leaves the process
    .build()
)

async def main():
    resp = await gw.complete(
        messages=[{"role": "user", "content": "Email jan@example.com about NL91ABNA0417164300"}],
        agent_id="demo",
    )
    print(resp.content)             # PII restored in the reply
    print(f"cost=${resp.cost_usd:.6f} latency={resp.latency_ms}ms")
    print("pii types:", resp.audit.pii_entity_types)

asyncio.run(main())
```

## Real providers

```python
from gavio import Gateway, Provider
from gavio.interceptors.pii import PiiGuard
from gavio.interceptors.audit import AuditInterceptor
from gavio.interceptors.reliability import RetryInterceptor, TimeoutPolicy

gw = (
    Gateway.builder()
    .provider(Provider.ANTHROPIC)          # reads ANTHROPIC_API_KEY
    .model("claude-sonnet-4-6")
    .use(PiiGuard(sensitivity="strict"))
    .use(AuditInterceptor(sink="stdout://"))
    .use(TimeoutPolicy(timeout_seconds=30))
    .use(RetryInterceptor(max_attempts=3))
    .build()
)

resp = await gw.complete(messages=[{"role": "user", "content": "Hi"}])
```

`OPENAI_API_KEY` / `Provider.OPENAI` work the same way.

## What ships in v0.1.0

- **Core** — `Gateway` fluent builder, `InterceptorChain`, `GavioRequest` /
  `GavioResponse`, UUID v7 `trace_id`, `agent_id` / `parent_trace_id`.
- **PII Guard (F-SEC-01)** — Email, IBAN (mod-97), BSN (11-proef),
  CreditCard (Luhn), Phone, IP, SSN scanners, redact/mask/tag/block, restore.
- **Secret Scanner (F-SEC-04)** — API keys, JWTs, PEM keys, DB URLs.
- **Reliability** — retry with backoff (F-REL-01), fallback chain (F-REL-02),
  timeout (F-REL-07).
- **Cost tracking (F-GOV-01)** — per-request `cost_usd`.
- **Audit (F-OBS-01)** — `AuditRecord` + `StdoutSink` (F-OBS-05).
- **Dev mode (F-DX-01)** and **dry-run mode (F-DX-02)**.
- **Providers** — OpenAI, Anthropic, Mock.

See the [Python guide](../../docs/packages/python.md) and [CHANGELOG.md](../../CHANGELOG.md).

## Tests

```bash
pip install -e ".[dev]"
pytest tests/unit -v
ruff check gavio
```
