Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.egisai.co/llms.txt

Use this file to discover all available pages before exploring further.

egisai.init(
    *,
    api_key: str | None = None,
    app: str = "default",
    env: str = "production",
    base_url: str | None = None,
    on_block: str = "raise",
    refresh_interval_seconds: float = 10.0,
    enable_sse: bool = True,
    enable_http_fallback: bool = True,
    quiet: bool = False,
) -> None
Activate egisai for the current Python process. After this call returns:
  • Supported provider SDKs (openai, anthropic, google-generativeai) are patched in place.
  • Optionally, httpx and requests are wrapped for HTTP-level audit visibility.
  • Background workers are started for live updates and audit delivery.
  • egisai.shutdown() is registered with atexit to flush events on exit.
init() is idempotent. Calling it twice in the same process is a no-op after the first call.

Parameters

api_key
str | None
default:"None"
Your platform API key (the one starting with egis_live_ that you created on the dashboard’s API Keys page).If not provided, falls back to the EGISAI_API_KEY environment variable.Required — init() raises RuntimeError if neither source provides a key.
app
str
default:"\"default\""
Logical agent name. The platform auto-creates an Agent matching this name in your org if one doesn’t exist; subsequent calls from this SDK instance are attributed to it for auditing.Set this to a stable, machine-friendly identifier (e.g. "customer-support-bot") so it reads well on the dashboard.
env
str
default:"\"production\""
Free-form environment label ("dev", "staging", "prod", …). Used for segmentation on the dashboard. Has no effect on policy evaluation itself.
base_url
str | None
default:"None"
Override the platform URL. Defaults to EGISAI_BASE_URL if set, otherwise the hosted control plane.Only set this if directed to do so by EgisAI (for example for a regional deployment or an enterprise install).
on_block
"raise" | "stub"
default:"\"raise\""
How blocked calls are surfaced to your code:
  • "raise" — raise PermissionError.
  • "stub" — return a framework-shaped refusal object so the application keeps running.
See Blocking behavior for guidance.
refresh_interval_seconds
float
default:"10.0"
How often to poll for policy changes if the live update channel is unavailable. Lower values mean faster picks-up of dashboard changes at the cost of more polling traffic.
enable_sse
bool
default:"True"
Subscribe to live policy and configuration updates when supported. Falls back to polling on connection failure. Disable if your environment blocks long-lived HTTP connections.
enable_http_fallback
bool
default:"True"
Patch httpx and requests for HTTP-level audit visibility. Useful when your application calls model endpoints directly rather than through one of the official provider SDKs. See HTTP clients.
quiet
bool
default:"False"
Suppress the one-line ✓ [egisai] active … startup banner on stderr.

Returns

None. Side effects (patching, background workers) happen in place.

Raises

  • RuntimeError — when neither api_key= nor EGISAI_API_KEY provides a key.
  • ValueError — when on_block is not "raise" or "stub".

Example

import os
import egisai

egisai.init(
    api_key=os.environ["EGISAI_API_KEY"],
    app="customer-support-bot",
    env=os.environ.get("APP_ENV", "production"),
    on_block="raise",
)

Idempotence

egisai.init(api_key="…", app="bot")
egisai.init(api_key="…", app="bot")   # no-op; logged at debug level
If you need to re-activate with different parameters, call egisai.shutdown() first.

What’s next

set_context

Attach per-call metadata after init.

Configuration guide

Walks each option in plain English.