Skip to main content

Python SDK for Torrix AI observability and tracing

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torrix-0.2.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torrix-0.2.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file torrix-0.2.0.tar.gz.

File metadata

  • Download URL: torrix-0.2.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for torrix-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f75d7f0b9fc109ad25b74ba27c97b896b89fe242efb77d29ea6733d02d7435cd
MD5 6c5970c86c750c18edabf864699b69f5
BLAKE2b-256 6569c71a72eb63dfcd74eca4509ef87d4224b2b7255c7c343c43b759e316496b

See more details on using hashes here.

File details

Details for the file torrix-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: torrix-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for torrix-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d95f20a3710cc96022de927d5930a818cc5273b79be5da8703931a0189a50fa9
MD5 e85404a5083de8ff8ab010a3b6cab4c6
BLAKE2b-256 f1d22eeaed0e850e8322fc0c11ab434ac7a2d5da34723550657e9ac515eb6467

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page