Skip to main content

observe() — TypeScript API

The zero-config entry point to TealTiger governance. 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.

Throws

Example


ObserveConfig


ObserveProxy

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

getCost()

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

getBaseline()

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

getAgentId()

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

getSessionId()

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

getBurnRate()

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

getCostByAgent()

Returns cost breakdown by agent ID (useful when multiple agents share a cost store).

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. Subsequent requests for that agent will proceed normally.

Parameters

Behavior

  • Safe: Calling unfreeze(id) for an agent that isn’t frozen completes without error
  • Immediate: Takes effect for the very next request
  • Targeted: unfreeze("agent-01") only unfreezes that specific agent — does not affect the wildcard freeze

Example


FrozenAgentError

Thrown when a request is attempted on a frozen agent:

Supported Providers

DeepSeek / xAI Example


Complete Example