Skip to main content

SwiftAPI Python SDK

A prerequisite before a protected action. Local Swift Brake verifies explicit permission, executes its registered capability once, and creates signed receipts. Codex or Claude Code remains the coding agent. No second model is involved.

pip install swiftapi-python
swiftapi doctor
swiftapi brake test
swiftapi brake install --dry-run
swiftapi brake install

Python 3.9+, macOS and Linux. The local test needs no account, API key, model, or cloud service. Restart the coding agent after installing the MCP integration.

Try the brake

swiftapi brake propose hello.txt "Hello from Swift Brake"
# Copy the returned request_id into the following commands.
swiftapi brake execute REQUEST_ID
# GATE_BLOCK: no marker is written.
swiftapi brake authorize REQUEST_ID
swiftapi brake execute REQUEST_ID
# AUTHORIZED_EXECUTION: exact marker bytes are written once.
swiftapi brake execute REQUEST_ID
# GATE_BLOCK: the authorization cannot execute again.
swiftapi status
swiftapi receipts
swiftapi verify RECEIPT_PATH --public-key PUBLIC_KEY_PATH

status prints the sandbox and public-key path. execute returns the receipt path. The operator authorizes in a separate terminal; authorization is deliberately absent from the MCP tool surface. A signature requires an independently trusted verification key, never a key blindly accepted from the receipt itself.

swiftapi brake presents swiftapi> and delegates ordinary input to the existing Codex CLI. swiftapi brake --agent claude uses Claude Code. These host calls use your existing account; the local test itself makes no model calls.

Python

The old imports remain available: from swiftapi import SwiftAPI, Enforcement. The new local API does not require a remote account:

from pathlib import Path
from tempfile import mkdtemp
from swiftapi import ActionEnvelope, BindingCondition, LocalAuthority, LocalGuard

action = ActionEnvelope("example.append", {"value": "verified"}, "Append one value")
state = {"operator_approved": True}  # Supplied by trusted application code.
condition = BindingCondition(action.action_hash, state)
guard = LocalGuard(LocalAuthority(), Path(mkdtemp()) / "ledger")
values = []
guard.run(
    lambda: values.append("verified"),
    action=action.capability, params=action.params, intent=action.intent,
    condition=condition, state=state,
)
assert values == ["verified"]

A callback's code must actually implement its supplied action description. For an untrusted agent, use a registered broker operation that constructs and executes the same canonical parameters. The bundled MCP operation creates a new small UTF-8 marker in its own sandbox; it cannot run a shell or overwrite files.

What is enforced

An authorization binds an action hash, capability, condition hash, state hash, nonce, issue time, and expiry. Ed25519 verification and a durable SQLite replay claim happen before execution. Execution is never retried. Missing, malformed, forged, expired, replayed, or mismatched authorization fails closed.

This guarantee applies to mediated capabilities. Arbitrary host tools are outside the broker. Local same-user key storage supports development and CI; a malicious process able to read the signer, change the gate, or mutate the ledger can bypass that trust boundary. Production credentials and signing authority require process or account isolation from untrusted agent code. Instructions and hooks are not a universal security boundary.

Research is measured separately

GATE_BLOCK is deterministic enforcement, not native EOS. Successful empty provider output is classified as a black-box PROVIDER_VOID with V0/V1/V2/VU subtypes. Only exposed native token evidence can qualify as NATIVE_VOID. The package does not download or retrain research models. The frozen PCCG-2 release and research library preserve the empirical, causal, theoretical, and protocol boundaries.

Documentation

Start with Quickstart. See concepts, local brake, Codex, Claude Code, Python SDK, conditions, action envelopes, receipts, verification, remote authority, BYOK, security, threat model, native noncontinuation, benchmarking, and provenance.

Migration from 1.2.2 documents security corrections and termination-metadata changes. Historical 1.2.2 bytes remain immutable on PyPI.

MIT license. Research and software by Rayan Pal / SwiftAPI Labs.

Metadata

Release files for swiftapi-python 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swiftapi-python 1.3.0
File Size Uploaded
swiftapi_python-1.3.0.tar.gz 66.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swiftapi-python 1.3.0
File Interpreter ABI Platform
swiftapi_python-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 109.4 kB

Release files / swiftapi_python-1.3.0.tar.gz

Download URL swiftapi_python-1.3.0.tar.gz
Size 66.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0020c12b3153ebe30a3f563037bbd6093383cd30c588193e0fde90753d250d0e
BLAKE2b-256 checksum
How to use checksums
a6abbff7d632b1a0616f6465c62a3e56c01515d37d4188e1a6c5b00578d96cd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / swiftapi_python-1.3.0-py3-none-any.whl

Download URL swiftapi_python-1.3.0-py3-none-any.whl
Size 43.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ec0a08cc0f3dbb72f30cb98f07b3b9616fd6e81fcca7a60cc08d9b1051abf28
BLAKE2b-256 checksum
How to use checksums
ae3ed91917ee4bbf2bc2ce0d5df0a03c534f27085814bc06512092bbcc09bcce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release history Release notifications | RSS feed

1.3.1

2 release files

This release

1.3.0 This release

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page