Python SDK

Python SDK

The scute package verifies your users' access tokens, manages users and sessions, checks permissions and runs agents from a Python backend.

scute is the server-side Python SDK. Your frontend signs people in with a Scute frontend SDK and sends the access token to your backend. The Python SDK verifies that token locally, reads and changes users and sessions with the app's secret key, asks Scute's engine what a user may do, and registers and runs AI agents.

What it covers#

AreaEntry point
Token verification (local JWKS, optional remote check)scute.tokens.verify
Users, invitations, support accessscute.users
Sessions: list, revoke, current user, refresh, sign outscute.sessions
Authorization checksscute.authz
Offline decisions from a policy snapshotscute.local.decide_locally
Agents and tasksscute.agents
Guardrails around an agent's tool callsscute.harness.Harness
FastAPI and Flask integrationscute.contrib.fastapi, scute.contrib.flask

The sign-in itself, MFA, policy and role management, filters, the policy snapshot endpoint and access requests have no methods in this SDK. Call the HTTP API for those.

Requirements#

  • Python 3.10 or later.
  • Dependencies installed with the package: httpx>=0.27 and cryptography>=42.
  • Optional: fastapi>=0.110 (extra fastapi) or flask>=3 (extra flask).

Install#

The package is not on PyPI. The scute name on PyPI belongs to an unrelated package, so install from GitHub:

pip install git+https://github.com/scuteai/scute-python

With a framework extra:

pip install "scute[fastapi] @ git+https://github.com/scuteai/scute-python"pip install "scute[flask] @ git+https://github.com/scuteai/scute-python"

Pin a commit by adding @<sha> to the URL, for example git+https://github.com/scuteai/scute-python@<sha>.

Configuration#

Scute() reads its settings from the environment when you do not pass them:

VariableArgumentRequiredDefault
SCUTE_APP_IDapp_idYesnone: ConfigurationError if missing
SCUTE_SECRETsecretFor secret-key callsnone
SCUTE_BASE_URLbase_urlNohttps://api.scute.io

The app id and secret are on the app's page in the dashboard. The secret is a server credential: never send it to a browser or to a model.

import osfrom scute import Scutescute = Scute()  # SCUTE_APP_ID, SCUTE_SECRET, SCUTE_BASE_URLscute = Scute(app_id=os.environ["SCUTE_APP_ID"], secret=os.environ["SCUTE_SECRET"])

Token verification only needs the app id. Users, sessions (list and revoke), authorization and agents need the secret.

Next#

Quickstart
Verify a token in a FastAPI route.
Client
Constructor options, timeouts, client IP.
Verify tokens
How local verification works and how it fails.
Reference
Every public class and function.