Skip to main content

Aegis Python SDK

Audience: developers integrating an application with an Aegis gateway. Scope: installation, gateway configuration, provider clients, and inclusion-proof verification. Boundary: the SDK talks to a gateway and verifies proofs. It establishes nothing about the gateway's trustworthiness — see § Proof verification, which is the section that matters most.


Install

From this source tree — the supported path while registry versions lag:

pip install -e ./sdk/python

Registry caution. PyPI carries aegis-latent-sdk at 4.0.0; this source tree is 4.1.1. Installing from PyPI gets you different code from what this document describes. See Release Status.

Requires Python 3.11 or newer.

Configure a gateway

from aegis_sdk import build_headers, normalize_gateway_url

base_url = normalize_gateway_url("http://127.0.0.1:8080")
headers = build_headers(api_key="your-proxy-key", session_id="session-1")

normalize_gateway_url rejects malformed and unsafe URL forms rather than passing them through. build_headers assembles the session and authorization headers the gateway expects.

Provider clients

Drop-in wrappers that route through the gateway:

from aegis_sdk import OpenAI

client = OpenAI(
    aegis_base_url="http://127.0.0.1:8080",
    aegis_api_key="your-proxy-key",
    session_id="session-1",
)

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello, Aegis."}],
)

AsyncOpenAI, Anthropic and AsyncAnthropic follow the same shape.

Compatibility is bounded by the SDK's tests. It covers the provider surfaces and dependency ranges those tests exercise, not every provider version or endpoint.

Proof verification

This is the part that is easy to get wrong, and getting it wrong makes the verification meaningless.

from aegis_sdk import verify_proof_headers, require_trusted_root

# The root MUST come from a channel independent of the gateway that
# served the response. A root read from the same response proves nothing.
trusted_root = require_trusted_root(load_root_from_your_own_anchor())

ok = verify_proof_headers(response.headers, trusted_root=trusted_root)

A proof verified against a root supplied by the gateway that produced it establishes internal consistency and nothing more. The system would be attesting to itself. require_trusted_root exists to make the input explicit; it cannot tell whether the root you passed is genuinely independent, because a root is a root.

Lower-level entry points, when you hold the proof rather than the headers:

Function Use
decode_proof_header Parse the X-Aegis-MMR-Proof header
canonical_proof_json Canonical form for hashing or storage
verify_inclusion Verify a parsed InclusionProof
verify_inclusion_hash Verify from a leaf hash

Schema and semantics: MMR Proof v1.

Streaming

A stream reports evidence as pending-terminal until its terminal summary commits, and no inclusion proof exists before then.

Check for the terminal marker. A client that treats connection close as success will silently accept a stream whose terminal commit failed — the gateway withholds the marker precisely so you can tell, and it cannot make you look.

Errors

Exception Raised when
AegisProofError A proof is malformed, fails schema validation, or does not verify against the supplied root
ValueError A gateway URL or header input is rejected as malformed

AegisProofError on a well-formed proof means the proof did not verify. Treat that as a security event, not a retryable failure.

Secure defaults

  • Never hard-code an API key. Read it from your environment or secret manager.
  • Never log a key, a raw proof payload, or governed content.
  • Verify proofs against an independently obtained root, always.
  • Pin the SDK to an exact commit or version.
  • Use HTTPS for any gateway that is not on localhost.

Develop

cd sdk/python
pip install -e ".[dev]"
ruff check src tests
mypy --config-file pyproject.toml
pytest -q

Related: Integrations Guide · MMR Proof v1 · Audit Endpoints · Boundaries

Release files for aegis-latent-sdk 4.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aegis-latent-sdk 4.1.1
File Size Uploaded
aegis_latent_sdk-4.1.1.tar.gz 13.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aegis-latent-sdk 4.1.1
File Interpreter ABI Platform
aegis_latent_sdk-4.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 29.1 kB

Release files / aegis_latent_sdk-4.1.1.tar.gz

Download URL aegis_latent_sdk-4.1.1.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6cd849477399515775615cbdb7cd0b5a2be7e456053737330d4a14e8a2df0b6a
BLAKE2b-256 checksum
How to use checksums
356b70d0ed6fe69989d6f8c256729a176937605b8cdfa5eaafc5405cffb75aca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

Release files / aegis_latent_sdk-4.1.1-py3-none-any.whl

Download URL aegis_latent_sdk-4.1.1-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47705f88a190b91e8a63a84ae4fa4bee22a662d3312d2f59a86dc625bcc257f9
BLAKE2b-256 checksum
How to use checksums
87b704a6dd908605c5cc2a6ad15dd201f8882d621592a185a02ae86f1be52020
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

Release history Release notifications | RSS feed

5.0.1

2 release files

5.0.0

2 release files

4.1.2

2 release files

This release

4.1.1 This release

2 release files

4.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page