The Python SDK wrapsDocumentation Index
Fetch the complete documentation index at: https://docs.aethis.ai/llms.txt
Use this file to discover all available pages before exploring further.
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
httpx and pydantic. Source: github.com/Aethis-ai/aethis-sdk-python.
0.3.2 or later required for the snippets below. The
inputs_hash, decision_id, decision_time, and engine_version fields on DecideResponse ship in 0.3.2 — earlier releases silently dropped them. Pin >=0.3.2 if your code reads any of those fields directly off the typed response.The SDK requires an API key for every call. Even decision endpoints that are anonymous over raw HTTP require a key when called via the SDK — the client is intended for authenticated, server-side use. For unauthenticated decision evaluation, use curl or the CLI. Request access →
Quickstart — sync
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.
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
| Argument | Required | Default | Notes |
|---|---|---|---|
api_key | yes | — | Provisioned via aethis.ai/developer-access. |
base_url | no | https://api.aethis.ai | HTTP only permitted for localhost / 127.0.0.1 or with a test transport. |
timeout | no | 5.0 (seconds) | Per-request, applies to all HTTP methods. |
iam_token | no | — | Cloud Run service-to-service bearer token. Most users won’t need this. |
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
| Import | Purpose |
|---|---|
Aethis, AsyncAethis | HTTP clients for /decide, /rulesets/{id}/schema, /me, /explain, /source |
SyncDecisionSession, DecisionSession | Stateful adapters over the stateless /decide endpoint |
DecideResponse, SchemaResponse, SchemaField, NextQuestion, SectionResult | Pydantic response models |
Decision, SectionStatus, SessionStatus | Enum-like result types |
AethisError, AethisAPIError, AethisUnavailable, AethisTimeout | Exception hierarchy |
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
- 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