Metadata-Version: 2.4
Name: sabrix
Version: 0.3.0
Summary: Universal Python SDK for Sabrix AI Proxy — sub-millisecond AI firewall, zero-trust governance, and multi-tenant security.
Author-email: Sabrix AI Engineering <engineering@sabrix.ai>
License-Expression: Apache-2.0
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: openai
Requires-Dist: openai>=1.0.0; extra == "openai"
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.20.0; extra == "anthropic"
Provides-Extra: llamaindex
Requires-Dist: llama-index-core>=0.10.0; extra == "llamaindex"
Provides-Extra: all
Requires-Dist: openai>=1.0.0; extra == "all"
Requires-Dist: anthropic>=0.20.0; extra == "all"
Requires-Dist: llama-index-core>=0.10.0; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"

# Sabrix AI — Universal In-Process Context Compactor

[![PyPI Version](https://img.shields.io/pypi/v/sabrix.svg)](https://pypi.org/project/sabrix/)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

In-process prompt cache optimization for AI agents. Automatically compacts repetitive tool outputs and preserves prompt cache prefixes with **zero external network hops** and **fail-safe pass-through**.

## Installation

```bash
pip install "sabrix[openai]"       # For OpenAI client
# or: pip install "sabrix[all]"    # For Anthropic, Gemini, LiteLLM, LangChain
```

## Quickstart

Wrap any client in 1 line:

```python
from openai import OpenAI
from sabrix.compactor import wrap_client

client = wrap_client(OpenAI())

# All client.chat.completions.create calls automatically compact prior tool observations
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Ping"}]
)
```

## Configuration

| Parameter | Default | Description |
| :--- | :--- | :--- |
| `sliding_window` | `2` | Recent turns preserved byte-for-byte immutable |
| `truncate_head_chars` | `250` | Characters preserved before truncation notice |
| `min_bytes` | `256` | Minimum payload size before compaction evaluates |

## Invariants

- **100% In-Process**: Runs synchronously within your process memory; zero cloud egress.
- **Fail-Safe Pass-Through**: Any unexpected error or schema mismatch aborts cleanly to the original, unmodified input.

## License

Apache-2.0
