api.aethis.ai with sync and async clients, typed Pydantic response models, and a stateful DecisionSession adapter for wizard / chatbot intake flows. It also exposes a narrow authoring-recovery surface for inspecting and explicitly cancelling a generation job; use the CLI or MCP server to create, generate, refine, and publish rulesets.
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
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:
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
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.
DecisionSession — same surface with await on the I/O methods.
In either surface, status.blocked means the API rejected one or more supplied
values, status.is_complete means an unblocked eligible or not_eligible
decision, and every other status is pending. Do not infer completion from an
absent next question.
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’swith block. New connections each call (no pooling across requests), but no lifecycle wiring required.
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.Public API surface
Status
Pre-1.0. The decision surface (/decide, /schema, /explain, /source, /me) is stable. The SDK exposes generation status and explicit cancellation for recovery, but it does not expose the rest of the authoring workflow (project creation, source upload, generation submission, refinement, or publishing). Use the CLI or MCP server for full authoring.
See also
- Which interface? — pick between SDK, CLI, MCP, REST.
- Decision envelope — every field on
DecideResponse. - Error reference — codes and recovery patterns.
- aethis-sdk on PyPI · source on GitHub
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.