Metadata-Version: 2.4
Name: torrix
Version: 0.2.0
Summary: Python SDK for Torrix AI observability and tracing
License: MIT
Keywords: llm,observability,tracing,openai,anthropic
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Provides-Extra: openai
Requires-Dist: openai>=1.0; extra == "openai"
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.20; extra == "anthropic"
Provides-Extra: all
Requires-Dist: openai>=1.0; extra == "all"
Requires-Dist: anthropic>=0.20; extra == "all"

# Torrix Python SDK

[Torrix](https://torrix.ai) is a self-hosted LLM observability platform. This SDK wraps your OpenAI and Anthropic clients to log every call automatically. Tokens, cost, latency, and full prompt traces go straight to your dashboard.

## Installation

```bash
pip install torrix
```

## Quick start

```python
import torrix
from openai import OpenAI

torrix.init(api_key="trxk_...", base_url="http://localhost:8088")
client = torrix.wrap(OpenAI(api_key="sk-..."))

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
```

## Anthropic

```python
from anthropic import Anthropic

client = torrix.wrap(Anthropic(api_key="sk-ant-..."))

response = client.messages.create(
    model="claude-3-5-sonnet-20241022",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.content[0].text)
```

## LangChain

```python
from torrix.wrappers.langchain_callback import TorrixCallbackHandler
from langchain_openai import ChatOpenAI

torrix.init(api_key="trxk_...", base_url="http://localhost:8088")
handler = TorrixCallbackHandler()

llm = ChatOpenAI(model="gpt-4o-mini", callbacks=[handler])
response = llm.invoke("What is the capital of France?")
```

## Optional extras

```bash
pip install torrix[openai]      # pins openai>=1.0
pip install torrix[anthropic]   # pins anthropic>=0.20
pip install torrix[all]         # both
```

## Running Torrix

```bash
curl -o docker-compose.yml https://raw.githubusercontent.com/torrix-ai/install/main/docker-compose.community.yml
docker compose up
```

Opens at [http://localhost:8088](http://localhost:8088). Community edition is free forever.

## Links

- [Documentation](https://github.com/torrix-ai/install)
- [Website](https://torrix.ai)
- [Contact](mailto:contact@torrix.ai)
