Skip to main content

Python SDK

Official hatiOS Python SDK. OpenAI-compatible with LangChain, CrewAI, and ADK integrations.

Installation​

pip install hatios

Quick Start​

agent.py
import os
from hatios import HatiOS

client = HatiOS(api_key=os.environ["HATIOS_API_KEY"])

response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a procurement agent."},
{"role": "user", "content": "Find Q1 vendors under $8000"}
],
hatios={"session_id": "procurement-q1"}
)

print(response.choices[0].message.content)
print(response.hatios.trace_id)

LangChain Integration​

langchain_example.py
from hatios.integrations import HatiOSChatModel
from langchain.agents import initialize_agent, Tool

# Drop-in replacement for ChatOpenAI
llm = HatiOSChatModel(
api_key=os.environ["HATIOS_API_KEY"],
model="gpt-4o"
)

agent = initialize_agent(tools, llm, agent="zero-shot-react-description")
result = agent.run("Find logistics vendors for Q1 2026")
# All tool calls and reasoning automatically traced by hatiOS

Async Support​

async_example.py
from hatios import AsyncHatiOS

client = AsyncHatiOS(api_key=os.environ["HATIOS_API_KEY"])
response = await client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}]
)