Skip to main content

Restack AI libraries

This is the Python Restack AI libraries.

Installation

You can install the Restack AI libraries using pip:

Using pip

pip install restack_ai

Using Poetry

poetry add restack_ai

Using uv

uv add restack_ai

Prerequisites

  • Python 3.8 or higher
  • Poetry (for dependency management)

Usage

To use the libraries in your project, you can import it like this:

from restack_ai import Restack

Initialize the Restack client

client = Restack()

Hide sensitive fields from the workflow UI

Wrap any value with Sensitive to opt it into selective field encryption. Only the marked fields are encrypted on the wire, so the engine UI keeps showing useful debug context (email, ids, timestamps) while sensitive values render as opaque ciphertext.

Engine-managed key (recommended)

When the engine is configured with RESTACK_ENGINE_PAYLOAD_KEY and RESTACK_API_BEARER_TOKEN (see the engine readme), the SDK auto-fetches the key during connect() and wires up the codec for you. Consumer services don't need any new env:

from pydantic import BaseModel
from restack_ai import Restack, Sensitive


class SignupInput(BaseModel):
    email: str
    password: Sensitive[str]


client = Restack()  # engine config from RESTACK_ENGINE_* envs

# Caller side:
await client.schedule_workflow(
    workflow_name="UserSignupWorkflow",
    workflow_id=workflow_id,
    workflow_input=SignupInput(
        email=email,
        password=Sensitive(value=password),
    ).model_dump(),
)


# Workflow side: receive the typed input, unwrap when you need plaintext.
@workflow.defn
class UserSignupWorkflow:
    @workflow.run
    async def run(self, payload: SignupInput) -> None:
        raw_password = payload.password.unwrap()
        ...

The SDK passes its api_key as the bearer token when fetching the key. Engines that don't expose the key endpoint (older versions, or with the env unset) cause the SDK to silently fall back to no encryption — no deployment breakage.

In the engine UI the password field renders as {"__restack_encrypted__": "v1", "alg": "AES-256-GCM", "iv": "...", "ct": "..."} instead of plaintext.

create_aes_gcm_encryption (used internally) requires the optional cryptography package — install it on every service that runs as a Restack worker so it can decrypt: pip install cryptography.

Consumer-managed key (advanced)

To keep the key entirely out of the engine — e.g. each consumer service manages its own key in a KMS — pass a codec explicitly. This overrides the engine auto-wire:

import os
from restack_ai import (
    Restack,
    SensitiveFieldsCodec,
    create_aes_gcm_encryption,
)
from restack_ai.restack import CloudConnectionOptions

key = os.urandom(32)  # load from your secrets store in real code
codec = SensitiveFieldsCodec(create_aes_gcm_encryption(key))

client = Restack(
    CloudConnectionOptions(
        engine_id=..., api_key=...,
        payload_codecs=[codec],
    ),
)

For non-AES backends (KMS, HSM, envelope encryption) provide your own implementation of SensitiveEncryption and pass it to SensitiveFieldsCodec.

Documentation

For detailed usage instructions, please visit our examples repository at https://github.com/restackio/examples-python.

Development

If you want to contribute to the libraries development:

Clone the repository and navigate to the engine/libraries/python directory.

Install Poetry/uv if you haven't already: https://python-poetry.org/docs/#installation or use pip

Activate the virtual environment:

If using uv:

uv venv && source .venv/bin/activate

If using poetry:

poetry env use 3.12 && poetry shell

If using pip:

python -m venv .venv && source .venv/bin/activate

Install the project dependencies:

If using uv:

uv sync

If using Poetry:

poetry install

If using pip:

pip install -e .

Release files for restack_ai 0.0.121

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

Source distribution (sdist)

Source distribution for restack_ai 0.0.121
File Size Uploaded
restack_ai-0.0.121.tar.gz 31.1 kB Details

Built distribution (wheel)

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

Total release size: 68.7 kB

Release files / restack_ai-0.0.121.tar.gz

Download URL restack_ai-0.0.121.tar.gz
Size 31.1 kB
Tags Source
SHA-256 checksum
How to use checksums
00b61d7c3b2a720d98b7c1875edf582f1e3a8a652f311f1a4a6c96022efb1725
BLAKE2b-256 checksum
How to use checksums
ac6953c7309f82fbb6db7b9e65b7846df8a824bd6ec15f135a81a185544b2761
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / restack_ai-0.0.121-py3-none-any.whl

Download URL restack_ai-0.0.121-py3-none-any.whl
Size 37.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
924a281e565ae666917a89ef27d9c9b12daf738a242d26587dcfe708642cc990
BLAKE2b-256 checksum
How to use checksums
d7dcad38ca171e23a1fb48eaf3ebd3fe9527098f3464382a1106d3497303b599
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.0.121 This release

2 release files

0.0.99

2 release files

0.0.98

2 release files

0.0.95

2 release files

0.0.94

2 release files

0.0.93

2 release files

0.0.92

2 release files

0.0.91

2 release files

0.0.90

2 release files

0.0.89

2 release files

0.0.88

2 release files

0.0.86

2 release files

0.0.85

2 release files

0.0.84

2 release files

0.0.83

2 release files

0.0.82

2 release files

0.0.75

2 release files

0.0.74

2 release files

0.0.73

2 release files

0.0.72

2 release files

0.0.71

2 release files

0.0.70

2 release files

0.0.69

2 release files

0.0.68

2 release files

0.0.67

2 release files

0.0.66

2 release files

0.0.65

2 release files

0.0.64

2 release files

0.0.63

2 release files

0.0.56

2 release files

0.0.55

2 release files

0.0.54

2 release files

0.0.53

2 release files

0.0.51

2 release files

0.0.50

2 release files

0.0.49

2 release files

0.0.48

2 release files

0.0.40

2 release files

0.0.39

2 release files

0.0.38

2 release files

0.0.37

2 release files

0.0.36

2 release files

0.0.35

2 release files

0.0.34

2 release files

0.0.33

2 release files

0.0.32

2 release files

0.0.31

2 release files

0.0.30

2 release files

0.0.29

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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