Aribot Python SDK
The official Python client for Aribot by Ayurak: threat modeling, security gates for pull requests, code review against the threat model, pipeline security, compliance and AI agent governance, from your own scripts, services and CI jobs.
pip install aribotpip install aribotPython 3.9 or later. The only dependency is requests. Install aribot[keyring] to use the sign-in stored by aribot login.
What you can do with it
- Security gates: ask the server for the pass or block decision on a code change, get per-file feedback and fix steps.
- Agent decision API: an AI agent asks whether it may call a tool before it acts, and gets the company's policy decision.
- Code review: upload code or link a repository, verify every threat in the diagram against the code, read the traceability matrix.
- Pipeline security: projects, scans, findings, SBOMs and gate results for CI/CD.
- Threat modeling: upload a diagram, list its components and threats, run the AI analysis, export a report.
- Compliance and remediation: scan a diagram against a standard, read framework reports, generate and track remediation plans.
- Connector API: the same operations the hosted Aribot connector offers, for your own tools.
Sign in
Create an API key in Aribot under Company Admin > Developer & API. The SDK looks for a credential in this order:
- The
api_keyyou pass toAribot(...). - The
ARIBOT_API_KEYenvironment variable (use this in CI). - The OS keychain entry written by
aribot loginfrom the aribot-cli package. This needspip install "aribot[keyring]". - The
ARIBOT_TOKENenvironment variable (a JWT access token).
export ARIBOT_API_KEY=... # from Company Admin > Developer & APIfrom aribot import Aribot
client = Aribot() # finds the credential as above
print(client.credential) # kind and source only; the value is never shown
print(client.me())Other settings: ARIBOT_API sets the server (default https://aribot.ayurak.com) and ARIBOT_CA_BUNDLE adds a private CA certificate.
Example: a gate decision for a pull request
from aribot import Aribot
client = Aribot()
decision = client.gates.decide(
gate_config_id=12,
gate="pull_request",
head_sha="3f2c1e9",
files=[{"path": "api/payments.py", "changed_lines": [[40, 72]]}],
)
print(decision)Only file paths and changed line ranges leave your machine. File contents are never sent.
Example: the agent decision API
An agent asks before each tool call. This call uses the agent's own key (agk_..., created for the agent in Aribot), passed as agent_key= or set in ARIBOT_AGENT_KEY.
from aribot import Aribot, AribotError
client = Aribot()
def may_call(tool: str, resource: str, args: dict) -> bool:
try:
answer = client.gateway.decide(tool, resource=resource, args=args)
except AribotError:
return False # fail closed: no decision means no action
return bool(answer.get("allowed"))
if may_call("crm.read_contact", "contact:4711", {"fields": ["email"]}):
...The server hashes args; keep them small. A decision request is sent once and never retried.
More examples
# Code review against the threat model
scan = client.code_review.create_scan(repository_id="...", diagram_id=42)
client.code_review.start_scan(scan["id"])
matrix = client.code_review.traceability(scan["id"])
# Pipeline scan of a pull request
run = client.pipeline.scan(project_id=7, pull_request_id=128)
gates = client.pipeline.get_gate_results(run["id"])
# Threat model from a diagram file
result = client.threat_modeling.analyze_diagram("architecture.png")
threats = client.threat_modeling.get_threats(result["id"]) # once analysis finishes
# A platform scan through the connector API, safe to retry with an idempotency key
job = client.connector.create_scan(account_id=3, idempotency_key="nightly-3-2026-11-23")Errors
Every error is an AribotError with status, code (the server's error code, when sent) and payload (the response body).
| Exception | When |
|---|---|
ValidationError | 400 or 422 |
AuthenticationError | 401: the credential is missing, expired or revoked |
LicenseRequiredError | 402: the company has no licence for this feature; payload has the details |
PermissionDeniedError | 403: the user or key may not do this |
NotFoundError | 404 |
ConflictError | 409 |
RateLimitError | 429 after the retries; retry_after holds the server's wait in seconds |
ServerError | 5xx |
ConfigError | bad base URL, no credential, or an invalid argument |
from aribot import Aribot, LicenseRequiredError, RateLimitError
try:
client.code_review.start_scan(scan_id)
except LicenseRequiredError as e:
print("Ask your company admin to enable:", e.payload)
except RateLimitError as e:
print("Try again in", e.retry_after, "seconds")Security notes
- HTTPS only. Plain http works for
localhostalone, for local development. - TLS certificates are always verified. Add a private CA with
ARIBOT_CA_BUNDLE. - Redirects are never followed, so the credential cannot travel to another host. A redirect raises an error.
- API keys go in the
X-API-Keyheader, JWT access tokens and agent keys inAuthorization: Bearer. - The credential never appears in exception messages or in
repr()of the client or the credential. - Only GET and HEAD requests are retried, on 429, 502, 503 and 504, at most 3 attempts, waiting as long as
Retry-Afterasks, up to 30 seconds. Writes are sent once. Passidempotency_key=to make a write retryable; it is sent asIdempotency-Key. Use it with endpoints that honour that header, such asconnector.create_scan. - Ids are encoded as single path segments, so an id cannot change which endpoint is called.
- For tests and custom networking, pass your own
session=(arequests.Sessionor a compatible object) andsleep=.
Upgrading from 2.x
Version 3.0.0 drops the methods whose endpoints no longer exist and moves others to their current routes. See CHANGELOG.md for every removed and renamed method.
Documentation
Full reference: https://aribot.ayurak.com/developers/sdk/python/
Licence: proprietary. Use of the Aribot service is subject to your agreement with Ayurak.