Skip to content

SDK Reference

Terminal window
pip install tappass

Requires Python 3.11+.

from tappass import Agent
agent = Agent(
url="https://tappass.example.com",
api_key="tp_...",
model="gpt-4o-mini", # default model (optional)
flags={"pii": "mask"}, # default governance flags (optional)
timeout=30, # request timeout in seconds
max_retries=2, # retry on transient errors
)
response = agent.chat("What are the GDPR requirements?")
print(response.content) # LLM answer
print(response.pipeline.classification) # "PUBLIC"
print(response.pipeline.blocked) # False
print(response.usage.total_tokens) # 156

Per-call overrides:

response = agent.chat("Complex analysis", model="gpt-4o", flags={"mode": "lockdown"})
for chunk in agent.stream("Write a report"):
print(chunk, end="", flush=True)

agent.achat(message, **kwargs) / agent.astream(message, **kwargs)

Section titled “agent.achat(message, **kwargs) / agent.astream(message, **kwargs)”

Async variants:

response = await agent.achat("Analyze the data")
async for chunk in agent.astream("Summarize"):
print(chunk, end="", flush=True)

Clear conversation history:

agent.chat("My name is Alice")
agent.chat("What's my name?") # "Alice"
agent.reset()
agent.chat("What's my name?") # doesn't know

Wrap callables for audited execution:

tools = agent.govern([search, send_email, read_file])

Apply kernel-level sandbox. Irreversible for the current process.

agent.secure() # default sandbox
agent.secure(tier="worker") # read/write workspace, safe commands only
agent.secure(tier="observer") # read-only, no shell, no network
FieldTypeDescription
response.contentstrLLM response text
response.modelstrModel used
response.usage.total_tokensintTotal tokens
response.usage.prompt_tokensintPrompt tokens
response.usage.completion_tokensintCompletion tokens
response.pipeline.classificationstrPUBLIC, INTERNAL, CONFIDENTIAL, RESTRICTED
response.pipeline.blockedboolWhether the request was blocked
response.pipeline.flagsdictActive governance flags
from tappass import PolicyBlockError
from tappass.errors import TapPassConnectionError
try:
response = agent.chat("Show me all credit cards")
except PolicyBlockError as e:
print(e.blocked_by) # step that blocked
print(e.reason) # human-readable reason
except TapPassConnectionError:
print("TapPass server unreachable")

PolicyBlockError is never retried.

with Agent("https://tappass.example.com", "tp_...") as agent:
response = agent.chat("Hello")
VariableDescription
TAPPASS_URLServer URL
TAPPASS_API_KEYAgent API key
TAPPASS_FLAGSDefault flags (e.g. mode=observe, pii=mask)
TAPPASS_MODELDefault model