Skip to main content

FHEnom for AI™ — Python SDK and CLI

Python 3.8+ License: MIT

fhenomai is the official client for FHEnom for AI™ by DataKrypto. It lets you encrypt AI models, serve them from a Trusted Execution Environment (TEE), and run inference on them, from the command line or from Python.

Requirements

  • Python 3.8 or newer
  • Access to a FHEnom for AI node: TEE 1.9.3+ and FHEnom AI Server 1.5.3+ (these are minimums; newer nodes work). fhenomai health live checks your node.

Installation

pip install fhenomai
fhenomai --version

Configuration

Run the setup wizard and answer the prompts (node address, admin token, SFTP credentials, inference server):

fhenomai config init

This writes ~/.fhenomai/config.yaml. Keep that file private: it holds your admin token. Then check the settings and the connection:

fhenomai config show
fhenomai test connection
Example config.yaml
admin:
  host: "tee.example.com"
  port: 9099
  auth_token: "your-admin-token"

user:                     # inference endpoint
  host: "tee.example.com"
  port: 9999

sftp:
  host: "tee.example.com"
  port: 22
  username: "your-sftp-user"
  key_path: "~/.ssh/fhenom_sftp"   # or: password: "..."

You can also set any value through an environment variable, for example FHENOM_ADMIN_HOST, FHENOM_AUTH_TOKEN or FHENOM_SFTP_PASSWORD.

Quick start

To encrypt and serve a Hugging Face model (in .safetensors format):

# 1. Upload the plaintext model to the node
fhenomai sftp upload ./my-model my-model --recursive

# 2. Encrypt it inside the TEE
fhenomai model encrypt my-model --wait

# 3. Serve the encrypted model (starts vLLM and registers it with the TEE)
fhenomai model serve my-model-encrypted

# 4. Send it a prompt
fhenomai test chat "What is the capital of France?"

To stop serving the model, run fhenomai model stop my-model-encrypted.

If you run vLLM yourself, register it with the TEE directly:

fhenomai serve start my-model-encrypted \
  --server-url http://GPU_HOST:8000 \
  --display-model-name my-model-encrypted

Encryption options

Option What it does
--encryption-impl Selects the encryption profile for the model's architecture. Omit it and the node picks the profile from the model's config.json; pass it alone and the matching preprocessing and inference mode follow. fhenomai model encrypt --help lists the values.
--lora-adapter Encrypts a LoRA adapter on top of its base model: pass the adapter folder in upload/, plus the base model's --encryption-impl.
--optimize-accuracy Keeps the encrypted model accurate if you quantize it later. Encryption takes a little longer.
--secure-channel Encrypts the token channel used during inference. You choose this when you encrypt the model.

Inference

The node exposes an OpenAI-compatible API, so any OpenAI client works:

from openai import OpenAI

client = OpenAI(base_url="http://tee.example.com:9999/v1", api_key="unused")

response = client.chat.completions.create(
    model="my-model-encrypted",
    messages=[{"role": "user", "content": "Explain confidential computing."}],
    max_tokens=200,
)
print(response.choices[0].message.content)

Python SDK

from fhenomai import FHEnomClient, FHEnomConfig

client = FHEnomClient(FHEnomConfig.from_file())   # reads ~/.fhenomai/config.yaml

# Upload, encrypt, wait
client.upload_model("./my-model", "my-model")
job_id = client.admin.encrypt_model("my-model", "my-model-encrypted")
job = client.admin.wait_for_job(job_id, timeout=3600)
model_id = job["result"]["encrypted_model_id"]

# Serve through your vLLM server
client.admin.start_serving(
    encrypted_model_id=model_id,
    server_url="http://GPU_HOST:8000",
    display_model_name="my-model-encrypted",
)

FHEnomConfig.from_env() builds the configuration from environment variables instead of a file.

Verify the endpoint

Before you send it a prompt, check that the inference endpoint is running in a genuine TEE. This check needs no admin token:

fhenomai attest        # exits 0 only if verification succeeds
from fhenomai.inference_attestation import verify_endpoint

result = verify_endpoint("tee.example.com", 9999)
if not result.verified:
    raise SystemExit(result.error)

Node operators can also generate and verify a full attestation report with fhenomai admin attestation and fhenomai admin verify-attestation.

Optional features

Encrypted prompts and responses (thick client)

By default, prompts and responses travel in plaintext. In thick-client mode, each client has its own key, and the node refuses any prompt that is not encrypted with it.

fhenomai model serve my-model-encrypted --thick-client
fhenomai thick-client add my-model-encrypted --label my-app --save my-app.json
fhenomai test chat "Hello" --thick-key-file my-app.json

The node shows each key only once, so store it when you create it. A thick-client model refuses every request until you have added at least one client. In Python, use ThickClientSession.

Sovereign split inference

Split inference keeps part of the model inside the TEE and runs the rest on your own GPU server, in the datakrypto-vllm image. The TEE connects to that server's inference port (50052).

fhenomai model split my-model --first-layers 2 --last-layers 2
fhenomai model serve my-model --sovereign-host GPU_SERVER_ADDRESS_SEEN_FROM_THE_TEE

The TEE and the sovereign server must use the same dtype and the same max_model_len. model serve starts both with the same values: --dtype (default: the model's own dtype, float16 on a GPU without bfloat16 support) and --max-model-len (default 4096). If you run the sovereign server yourself, pass the same explicit values it was started with:

fhenomai serve start my-model --sovereign-server-host HOST \
  --sovereign-max-model-len 4096 --sovereign-dtype float16

fhenomai serve list shows the values the TEE uses. Thick-client mode (--thick-client) works with sovereign serving too.

Administration

Command Purpose
fhenomai provision Activate a new node with the licence details supplied by DataKrypto
fhenomai admin license Show licence state and remaining budget
fhenomai admin usage --from … --to … Signed inference usage for a period
fhenomai admin token create/list/revoke Manage scoped admin tokens
fhenomai whoami Show what the configured token is allowed to do
fhenomai health check Check every service the CLI talks to

For security, always provision with --admin-token and --rotation-token. Without them provision asks for confirmation, and fhenomai health check warns about the node.

Command reference

Group Commands
config init, show, get, validate
model list, info, upload, download, encrypt, encrypt-dataset, serve, stop, split, delete, delete-encrypted, chat-template
serve start, stop, list
sftp upload, download, list, clear
job list, status, wait, cancel
thick-client add, list, remove
health check, live, ready, status, admin, sftp, server
test connection, admin, sftp, chat
admin license, usage, token, attestation, verify-attestation, logs, ssl, sync, ita, reload, deprovision
top level provision, attest, whoami

Add --help to any command to see its options.

If a command fails, the CLI exits with a non-zero status, so you can safely chain commands in scripts (fhenomai … && next-step).

Support

License

MIT License. Copyright (c) 2024-2026 DataKrypto. See the LICENSE file for details.

Metadata

Release files for fhenomai 1.5.0

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

Source distribution (sdist)

Source distribution for fhenomai 1.5.0
File Size Uploaded Provenance
fhenomai-1.5.0.tar.gz 230.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fhenomai 1.5.0
File Interpreter ABI Platform
fhenomai-1.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 460.5 kB

Release files / fhenomai-1.5.0.tar.gz

Download URL fhenomai-1.5.0.tar.gz
Size 230.0 kB
Tags Source
SHA-256 checksum
How to use checksums
811b712c5838b3b602672cbd25964ae74a1708c92c687930b34dec61c4c84446
BLAKE2b-256 checksum
How to use checksums
bd24ed41bce9e9d8d4215c4bf8ecd00798e568abb0cce4028edc5f5f3a40b19c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Release files / fhenomai-1.5.0-py3-none-any.whl

Download URL fhenomai-1.5.0-py3-none-any.whl
Size 230.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d714af0bbc24f6d090b51bdc8ad751520b26c1f7603ddd00832b74d7c4bde01f
BLAKE2b-256 checksum
How to use checksums
1acfe16eb9b3b0c28118a13fb2d57edb27868efbb873bebce1771d578ffe6ed2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Security for fhenomai 1.5.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.

Release history Release notifications | RSS feed

This release

1.5.0 This release

2 release files No provenance

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