constitutional-aiops (Python)
Official Python client for the Constitutional AIOps REST API. Two layers ship
together: a hand-written ergonomic client (AIOpsClient, standard library only)
and an optional generated typed core (constitutional_aiops_client, full type
safety over every endpoint) that rides on httpx + attrs. See the
SDK overview
for the full status.
Install
pip install constitutional-aiops # ergonomic client only, zero dependencies
pip install "constitutional-aiops[typed]" # also install the generated typed core
Or from a source checkout (development):
pip install -e sdk/python
pip install -e "sdk/python[typed]"
Use — ergonomic client
from constitutional_aiops import AIOpsClient, ConstitutionalRefusal
client = AIOpsClient("https://your-instance.example.com", token="aiops_pat_...")
# List every critical incident (pagination handled for you).
for incident in client.paginate("/incidents/", severity="critical"):
print(incident["id"], incident["title"])
# Read one incident and its root-cause analysis.
inc = client.get_incident("INC-2026-0007")
print(inc.get("rca", {}).get("root_cause"))
# Approve a pending action. This still passes the constitutional gate.
try:
client.approve_action("act-123", approved=True, approved_by="me")
except ConstitutionalRefusal as refusal:
print("gate held the action:", refusal.error_code)
# Stream a chat turn.
result = client.stream_chat("why is nextcloud slow?", on_delta=lambda t: print(t, end=""))
print("\n", result.get("message", {}).get("content"))
What you can call (ergonomic client, 0.2.0)
Every method returns plain decoded JSON. Constructor:
AIOpsClient(base_url, token=None, timeout=90.0, max_retries=0, backoff=0.5);
with AIOpsClient(...) as client: is supported.
- Incidents:
list_incidents,paginate("/incidents/"),get_incident,incident_stats,create_incident,update_incident,similar_incidents - Actions (each still passes the constitutional gate):
list_actions,get_action,pending_actions,create_action,approve_action,execute_action,cancel_action,action_stats,confidence_formula - Agents:
fast_agent_stats,fast_agent_activity,reasoning_agent_stats,reasoning_agent_activity - Episodic graph:
graph_stats,topology,services,episodes,get_episode,similar_episodes - Audit:
audit_events,audit_event_types - Tokens (self-service PAT):
list_tokens,create_token,revoke_token - Notifications:
notifications,unread_count,mark_read,clear_notifications - Benchmark:
evaluate_endpoint,benchmark_status,benchmark_results - Metrics:
metrics,metrics_history,metrics_latency - Chat:
chat,stream_chat,analyze,list_conversations,get_conversation
Anything not wrapped here is reachable through the typed core (below) or the
generic escape hatch client.request(method, path, params=..., body=...).
Opt-in retries. AIOpsClient(url, max_retries=2) retries a 429 on any method
and 5xx or network failures on GET only, with exponential backoff that honors a
Retry-After header. The default (max_retries=0) never retries.
Use — typed core
With the typed extra installed, every path, parameter, request body and response
is typed from the API's OpenAPI schema.
from constitutional_aiops_client import AuthenticatedClient
from constitutional_aiops_client.api.incidents import incidents_get_incident
client = AuthenticatedClient(
base_url="https://your-instance.example.com", token="aiops_pat_..."
)
incident = incidents_get_incident.sync(incident_id="INC-2026-0007", client=client)
print(incident.id, incident.severity)
Regenerating the typed core
constitutional_aiops_client/ is generated from the committed API snapshot
(openapi/openapi.json) by
openapi-python-client.
It is committed so the package installs offline; regenerate it whenever the
snapshot changes:
pip install "openapi-python-client==0.29.1"
bash sdk/python/scripts/generate.sh
Auth
Create a personal access token in the app (Settings, or POST /api/v1/auth/tokens)
and pass it as token=; it is sent as Authorization: Bearer aiops_pat_... and
resolves to your user even when AUTH_REQUIRED is off, so calls are attributed and
cost-fenced. Against a single-user instance with AUTH_REQUIRED unset the token is
optional.
License
AGPL-3.0-or-later, matching the app.
Metadata
Release files for constitutional-aiops 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| constitutional_aiops-0.2.0.tar.gz | 119.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| constitutional_aiops-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 525.4 kB
Release files / constitutional_aiops-0.2.0.tar.gz
| Download URL | constitutional_aiops-0.2.0.tar.gz |
|---|---|
| Size | 119.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a7311cf458d84a42ffc3b42ce868a26d19aff2561fa4d7dc6f08f7da804fabe
|
|
BLAKE2b-256 checksum How to use checksums |
79f46c76ccd520a6070804fc3727da93b79a5cc3f163beb1cbfba8cdebcad336
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.
Transparency logRelease files / constitutional_aiops-0.2.0-py3-none-any.whl
| Download URL | constitutional_aiops-0.2.0-py3-none-any.whl |
|---|---|
| Size | 406.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0988104b93f8e7e891ccb8ebfd47645d647965d6682ab42400427e3ca98b3f1f
|
|
BLAKE2b-256 checksum How to use checksums |
e10b8d84cf35927fe3a219926817d6cceb38994831d6f927e857f3109f55546b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.
Transparency log