Skip to main content

observe() — Python API

The zero-config entry point to TealTiger governance for Python. Wraps any supported LLM provider client with cost tracking, audit logging, PII detection, and behavioral baseline construction.

observe()

Parameters

Returns

ObserveProxy — A transparent proxy with the same API surface as the original client, plus governance methods.

Raises

Example


Async Usage

observe() works with both sync and async clients:

ObserveProxy Methods

The proxy returned by observe() has the same method surface as the original client, plus these governance methods:

get_cost()

Returns the accumulated cost for this session and agent.
Example:

get_baseline()

Returns the behavioral baseline, or None if the baseline window hasn’t been filled yet.
Example:

get_agent_id()

Returns the agent ID (auto-generated or configured).

get_session_id()

Returns the session ID (auto-generated or configured).

get_burn_rate()

Returns the current USD/minute spend rate based on recent requests.

get_cost_by_agent()

Returns cost breakdown by agent ID.

freeze()

Immediately registers the given agent ID in the FreezeRegistry. All subsequent requests for that agent will be blocked with a FrozenAgentError.

Parameters

Behavior

  • Idempotent: Calling freeze(id) multiple times is equivalent to calling it once
  • Immediate: Takes effect for the very next request
  • In-memory: No external service needed, persists for process lifetime
  • Wildcard: freeze("*") freezes all agents, including agents created after the freeze call

Example


unfreeze()

Removes the given agent ID from the FreezeRegistry.

Parameters

Behavior

  • Safe: Calling unfreeze(id) for an agent that isn’t frozen completes without error
  • Immediate: Takes effect for the very next request

Example


FrozenAgentError

Raised when a request is attempted on a frozen agent:

Supported Providers

DeepSeek / xAI Example


Complete Example


Context Manager (Python-Specific)

The Python SDK supports a context manager pattern for session scoping: