chutes-e2ee
End-to-end encrypted transport for Chutes AI, designed as a drop-in httpx transport for the OpenAI Python SDK.
Requests are encrypted client-side using ML-KEM-768 + HKDF-SHA256 + ChaCha20-Poly1305 so that neither the API relay nor any intermediary can read the payload — only the GPU instance running your model sees the plaintext.
Installation
pip install chutes-e2ee
Quick Start
Synchronous (OpenAI)
import httpx
from openai import OpenAI
from chutes_e2ee import ChutesE2EETransport
API_KEY = "cpk_..."
client = OpenAI(
api_key=API_KEY,
base_url="https://llm.chutes.ai/v1",
http_client=httpx.Client(
transport=ChutesE2EETransport(api_key=API_KEY, api_base="https://llm.chutes.ai"),
),
)
response = client.chat.completions.create(
model="zai-org/GLM-4.7-TEE",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
Async (AsyncOpenAI)
import httpx
from openai import AsyncOpenAI
from chutes_e2ee import AsyncChutesE2EETransport
API_KEY = "cpk_..."
client = AsyncOpenAI(
api_key=API_KEY,
base_url="https://llm.chutes.ai/v1",
http_client=httpx.AsyncClient(
transport=AsyncChutesE2EETransport(api_key=API_KEY, api_base="https://llm.chutes.ai"),
),
)
response = await client.chat.completions.create(
model="zai-org/GLM-4.7-TEE",
messages=[{"role": "user", "content": "Hello!"}],
)
Streaming
Streaming works transparently — the transport decrypts chunks on-the-fly:
stream = client.chat.completions.create(
model="zai-org/GLM-4.7-TEE",
messages=[{"role": "user", "content": "Count to 10"}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
How It Works
The transport intercepts requests at the httpx layer — completely invisible to the OpenAI SDK:
-
Outbound: Parses the JSON body, discovers E2EE-capable instances (caching pubkeys + nonces), performs ML-KEM encapsulation + HKDF key derivation + ChaCha20-Poly1305 encryption, and rewrites the request to
POST /e2e/invokewith a binary body and E2EE headers. -
Inbound (non-streaming): Decrypts the response blob (ML-KEM decapsulation + HKDF + ChaCha20) and returns a normal JSON
httpx.Response. -
Inbound (streaming): Decrypts the
e2e_initkey-exchange event, then decrypts eache2echunk, yielding standarddata: {...}SSE lines that the OpenAI SDK parses normally.
Nonce Management
The transport automatically:
- Prefetches nonces from
/e2e/instances/{chute_id}(10 per instance, up to 5 instances) - Caches them locally with expiry tracking (60s client TTL)
- Refreshes when nonces are exhausted or expired
- Consumes one nonce per request (single-use, replay-proof)
Model Resolution
You can use model names (e.g. zai-org/GLM-4.7-TEE) or chute IDs directly. The transport resolves model names to chute IDs via the /v1/models endpoint (cached for 5 minutes).
Configuration
| Parameter | Default | Description |
|---|---|---|
api_key |
required | Your Chutes API key |
api_base |
https://api.chutes.ai |
API base URL |
inner |
httpx.HTTPTransport() |
Underlying transport for actual HTTP calls |
Dependencies
httpx>= 0.25cryptography>= 42.0pqcrypto>= 0.1.0 (ML-KEM-768 implementation)
License
MIT
Metadata
Release files for chutes-e2ee 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chutes_e2ee-0.1.0.tar.gz | 9.3 kB | Without provenance | Details for chutes_e2ee-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chutes_e2ee-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for chutes_e2ee-0.1.0-py3-none-any.whl |
Total release size: 20.2 kB
Release files / chutes_e2ee-0.1.0.tar.gz
| Download URL | chutes_e2ee-0.1.0.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ec18513f5b34573134a7f298bca3cd51a524d1263594819c31a010342004790
|
|
BLAKE2b-256 checksum How to use checksums |
62fad470e57acc0ef97e0cdd25faba8f13027bc6ec025aa5ca09fbe43f149d9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.17
|
Release files / chutes_e2ee-0.1.0-py3-none-any.whl
| Download URL | chutes_e2ee-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6916d3f28e4ec25f64ff03db566a55ab9eaaabcd1ed04235c592065c054a0ee
|
|
BLAKE2b-256 checksum How to use checksums |
01d2182aff404bb8850c47a7ed764abeaca20d97c0a5375a9876d1216f8d959e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.17
|
Security for chutes-e2ee 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.