Skip to main content
The Python SDK wraps api.aethis.ai with sync and async clients, typed Pydantic response models, and a stateful DecisionSession adapter for wizard / chatbot intake flows. Use this when you’re shipping a Python service that calls Aethis from a server context — FastAPI, Django, a worker, a notebook. For ad-hoc evaluation from a terminal, prefer the CLI or raw curl.

Install

Python 3.11+. Pulls in httpx and pydantic. Source: github.com/Aethis-ai/aethis-sdk-python.
0.5.0 or later required for the rulebook surface. Aethis.decide_rulebook() / AsyncAethis.decide_rulebook() and the rulebook_id field on DecideResponse ship in 0.5.0. The audit fields (inputs_hash, decision_id, decision_time, engine_version) on DecideResponse have been present since 0.3.2.
API key is optional for decision endpoints. Aethis() without a key works for anonymous decides on public rulesets (client.decide(ruleset_id="aethis/uk-fsm/child-eligibility", ...)). A key is required for: composed rulebook decides via decide_rulebook(), private rulesets, and any authoring endpoint. Request access →

Quickstart — sync (anonymous on public rulesets)

Composed rulebook (requires API key)

To evaluate a multi-ruleset rulebook (e.g. aethis/uk-fsm’s A AND (B OR C)), use decide_rulebook() and supply an API key:
Rulebook decide is always scope-gated — anonymous callers get HTTP 401, regardless of rulebook visibility. response is a typed DecideResponse — see the decision envelope reference for the full shape. The four audit fields above are the determinism proof: same inputs_hash always produces the same outcome from the same engine_version, and the decision_id lets you pin a specific decision to a log line. Aethis must be used as a context manager — the underlying httpx client is created in __enter__ and closed in __exit__, so calling methods on a non-entered client raises RuntimeError.

Quickstart — async

The async surface mirrors the sync one method-for-method. Use it inside FastAPI handlers, async workers, or any code path already on the asyncio event loop.

With trace

Discover fields

Stateful decision session

For interactive flows — chatbot, wizard, multi-step form — SyncDecisionSession accumulates answers locally and only hits /decide when the input set has actually changed. The session does not own the client; keep the Aethis context open for the session’s lifetime.
The async equivalent is DecisionSession — same surface with await on the I/O methods.

FastAPI integration

A typical server-side wiring: one client per process, an async dependency, decision endpoints that return the envelope verbatim.

Django integration

The simplest pattern is per-request: instantiate inside the view’s with block. New connections each call (no pooling across requests), but no lifecycle wiring required.
For high-traffic services that want connection pooling across requests, lift the with block into a Django AppConfig.ready() (call client.__enter__() at startup, register atexit(client.close) for shutdown) and stash the client in apps.get_app_config(...). For async views, swap to AsyncAethis with async with and await the call.

Configuration

Errors

The SDK exposes a small exception hierarchy. Catch the base class for blanket handling, or the specific subclasses for tailored retry / fallback logic.
See the error reference for response shapes and codes.

Public API surface

Status

Pre-1.0. The decision surface (/decide, /schema, /explain, /source, /me) is stable. Authoring endpoints (projects, rulesets, publishing) are not yet exposed in the SDK — use the CLI or MCP server for those.

See also

Help improve this pageIf something here is unclear or missing an example, use the feedback button at the bottom of the page.Found a bug? Open a GitHub issue. Evaluating Aethis for a regulated workflow? Contact us directly.