Skip to main content

Official Python SDK for the Aethis developer API — eligibility decisions and ruleset schemas

Project description

Aethis SDK for Python

PyPI Python License: MIT

Official Python SDK for the Aethis developer API — eligibility decisions, ruleset schemas, and stateful decision sessions.

Documentation: docs.aethis.ai · OpenAPI spec · agents via MCP: claude mcp add aethis -- npx -y aethis-mcp

Install

pip install aethis-sdk

Python 3.11+. Requires httpx and pydantic.

Quickstart

Examples below target aethis/uk-fsm/child-eligibility — a live public ruleset (UK Free School Meals, child-eligibility section). Browse all live rulesets with curl https://api.aethis.ai/api/v1/public/rulesets.

Evaluation endpoints are anonymous during the developer beta — Aethis() works with no key. Pass api_key="ak_live_..." only if you're calling authoring endpoints (publishing rulesets, etc.).

One-shot decision (sync)

from aethis_sdk import Aethis

with Aethis() as client:
    response = client.decide(
        ruleset_id="aethis/uk-fsm/child-eligibility",
        field_values={
            "child.age": 10,
            "child.school_type": "state_funded",
        },
    )
    print(response.decision)        # "eligible" | "not_eligible" | "undetermined"
    print(response.inputs_hash)     # canonical SHA-256 fingerprint of the input set
    print(response.decision_id)     # per-call audit identifier
    print(response.engine_version)  # e.g. "aethis-core@0.10.0"

The four audit fields above (inputs_hash, decision_id, decision_time, engine_version) ship in 0.3.2+. Same inputs_hash always produces the same outcome from the same engine_version — store these alongside the decision for a defensible audit trail.

One-shot decision (async)

import asyncio
from aethis_sdk import AsyncAethis

async def main():
    async with AsyncAethis() as client:
        response = await client.decide(
            ruleset_id="aethis/uk-fsm/child-eligibility",
            field_values={"child.age": 10, "child.school_type": "state_funded"},
        )
        print(response.decision)

asyncio.run(main())

Stateful decision session

Accumulate answers locally and query the API only when needed. Cached until an answer changes. The session does not manage the client — the caller keeps the Aethis context open for the session's lifetime.

from aethis_sdk import Aethis, SyncDecisionSession

RULESET_ID = "aethis/uk-fsm/child-eligibility"

with Aethis() as client:
    schema = client.get_schema(RULESET_ID)
    session = SyncDecisionSession(RULESET_ID, client, schema)
    session.answer("child.school_type", "state_funded")
    while (nq := session.next_question()) is not None:
        answer = input(f"{nq.question} ")
        session.answer(nq.field_id, answer)
    print("Eligible:", session.is_eligible())

Note: input() returns a string. For non-string fields (int / bool / enum) coerce the answer before calling session.answer() — the API expects the typed value.

Authoring (requires a key)

with Aethis(api_key="ak_live_...") as client:
    # ruleset publishing endpoints — see the Aethis CLI for the
    # full authoring workflow:
    # https://github.com/Aethis-ai/aethis-cli
    ...

The async equivalent is DecisionSession — same surface, await on the HTTP methods (decide, is_eligible, next_question, status).

What's included

Import Purpose
Aethis, AsyncAethis HTTP clients for /decide, /rulesets/{id}/schema, /me, /rulesets/{id}/explain, /rulesets/{id}/source
SyncDecisionSession, DecisionSession Stateful adapters over the stateless /decide endpoint
DecideResponse, SchemaResponse, SchemaField, NextQuestion, SectionResult Pydantic response models
AethisError, AethisAPIError, AethisUnavailable, AethisTimeout Exception hierarchy

Configuration

  • api_key — optional during the developer beta for evaluation endpoints (/decide, /schema, /explain, /source). Required for authoring endpoints (publishing rulesets, etc.). Provisioned via aethis.ai.
  • base_url — defaults to https://api.aethis.ai. HTTP is only permitted for localhost / 127.0.0.1 or when passing a test transport.
  • timeout — per-request, seconds. Defaults to 5.
  • iam_token — optional bearer token for Cloud Run service-to-service auth.

Status

Pre-1.0. The decision surface (/decide, /schema) is stable; authoring endpoints (projects, rulesets, publishing) are not yet exposed here — use the Aethis CLI for those.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aethis_sdk-0.4.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aethis_sdk-0.4.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file aethis_sdk-0.4.0.tar.gz.

File metadata

  • Download URL: aethis_sdk-0.4.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aethis_sdk-0.4.0.tar.gz
Algorithm Hash digest
SHA256 fbd2a8930677a5f082028c7db5d2f2a2cad6f84c29061230f1e4136e6831de8e
MD5 b83a82af0eb8bbf15aba90a73e696c76
BLAKE2b-256 5a86d859b9ddb2a81a4acfb626ab438a7b592ff1c689d3f7088e64ca4a6e518c

See more details on using hashes here.

Provenance

The following attestation bundles were made for aethis_sdk-0.4.0.tar.gz:

Publisher: publish.yml on Aethis-ai/aethis-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aethis_sdk-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: aethis_sdk-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aethis_sdk-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ffba16c429c0f4d40401bedb374c795aae63173128f80a920a18c53f6d032e20
MD5 3505b82bc67078c9d9edd1e5a225ec18
BLAKE2b-256 ce43dcfc684773161bd1955102631e45f046850b43ea743f968577c054325a98

See more details on using hashes here.

Provenance

The following attestation bundles were made for aethis_sdk-0.4.0-py3-none-any.whl:

Publisher: publish.yml on Aethis-ai/aethis-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page