Skip to main content

Torrix Python SDK

Torrix 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

pip install torrix

Quick start

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

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

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

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

Running Torrix

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. Community edition is free forever.

Links

Metadata

Release files for torrix 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torrix 0.3.0
File Size Uploaded
torrix-0.3.0.tar.gz 9.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for torrix 0.3.0
File Interpreter ABI Platform
torrix-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.2 kB

Release files / torrix-0.3.0.tar.gz

Download URL torrix-0.3.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f765f890bf86ba8d9e70f67185630363865376bb4b4390cfbcde27d50d860a18
BLAKE2b-256 checksum
How to use checksums
88e4e52f5acde712950e95772b0a05b9a36f90c203eaae80aefe6c8a4c2ccdb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.4

Release files / torrix-0.3.0-py3-none-any.whl

Download URL torrix-0.3.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0621a9996c1515e8d6be08f8470934df9f4dd973bec88e32a25f6d2497eadba9
BLAKE2b-256 checksum
How to use checksums
1a5a27f8a93c407aa43bae4960572cb7d9ba1c1081870a505a498faec6986cc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.4

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page