Skip to content

Sequrity Client

The SequrityClient is the main synchronous client for interacting with Sequrity's API.

SequrityClient

SequrityClient(
    api_key: str,
    *,
    base_url: str | None = None,
    timeout: int = 300,
    control: ControlConfig | None = None,
)

Synchronous client for the Sequrity API.

Thin orchestrator that owns the HTTP connection pool and delegates to product-specific namespaces.

Example
from sequrity import SequrityClient
from sequrity.control import ControlConfig, FeaturesHeader, SecurityPolicyHeader

client = SequrityClient(
    api_key="sq-xxx",
    control=ControlConfig(
        llm_api_key="sk-xxx",
        provider="openrouter",
        features=FeaturesHeader.dual_llm(),
        security_policy=SecurityPolicyHeader.dual_llm(),
    ),
)

response = client.control.chat.create(
    messages=[{"role": "user", "content": "Hello!"}],
    model="gpt-5-mini",
)

Parameters:

  • api_key

    (str) –

    Your Sequrity API key for authentication.

  • base_url

    (str | None, default: None ) –

    Sequrity API base URL. Defaults to the SEQURITY_BASE_URL environment variable, or https://api.sequrity.ai.

  • timeout

    (int, default: 300 ) –

    Default request timeout in seconds. Defaults to 300.

  • control

    (ControlConfig | None, default: None ) –

    Configuration for the Sequrity Control product. When omitted, an empty ControlConfig is used (all defaults are None, configure per-request instead).

Methods:

  • close

    Close the underlying HTTP client.

Attributes:

  • control

    Sequrity Control product namespace.

Source code in src/sequrity/_client.py
def __init__(
    self,
    api_key: str,
    *,
    base_url: str | None = None,
    timeout: int = 300,
    control: ControlConfig | None = None,
):
    """Initialize the Sequrity client.

    Args:
        api_key: Your Sequrity API key for authentication.
        base_url: Sequrity API base URL. Defaults to the ``SEQURITY_BASE_URL``
            environment variable, or ``https://api.sequrity.ai``.
        timeout: Default request timeout in seconds. Defaults to 300.
        control: Configuration for the Sequrity Control product. When omitted,
            an empty ``ControlConfig`` is used (all defaults are None, configure
            per-request instead).
    """
    self._api_key = api_key
    self._base_url = base_url or os.environ.get("SEQURITY_BASE_URL") or SEQURITY_BASE_URL
    self._http_client = httpx.Client(timeout=timeout)

    self.control = ControlClient(
        self._http_client,
        self._api_key,
        self._base_url,
        config=control,
    )
    """Sequrity Control product namespace."""

control instance-attribute

control = ControlClient(_http_client, _api_key, _base_url, config=control)

Sequrity Control product namespace.

close

close() -> None

Close the underlying HTTP client.

Source code in src/sequrity/_client.py
def close(self) -> None:
    """Close the underlying HTTP client."""
    self._http_client.close()