Skip to main content

aiap-client — AI Agency Protocol SDK

Identity is persistent. Agency is ephemeral.

Python SDK for the AI Agency Protocol (AIAP). Enables agents to request scoped, time-limited authority from a central broker.

Install

pip install aiap-client
pip install aiap-client[aws]   # + boto3 for credential sessions
pip install aiap-client[cert]  # + cryptography for certificate auth

Quick Start

from aiap_client import AgencyClient, AgencyLevel

client = AgencyClient(
    broker_url="https://broker.example.com",
    agent_id="YXFQTW0VCL",
    mac_secret="your-hmac-secret",
)

# Request JIT credentials
grant = await client.request_agency(
    intent="Invoke underwriting model",
    use_case="underwriting",
    resources=["bedrock:InvokeModel"],
    duration_seconds=900,
)

if grant.granted:
    session = grant.to_boto3_session(region="us-east-1")
    bedrock = session.client("bedrock-runtime")
    # Invoke with scoped creds — expires in 15 min
else:
    print(f"Denied: {grant.reason}")

Token Mode (workload identity, 1.1.0)

No shared secret: the agent proves who it is with its own short-lived service token. The broker accepts it only when the token carries the capability scope agency-request:use and its subject is the caller bound to the agent's enrolment (RFC-001 §5.2).

from aiap_client import AgencyClient, AgencyRefusedError

async def current_token() -> str:      # your runtime's token source; called for every request
    ...

async with AgencyClient(broker_url="https://broker.example.com", agent_id="YXFQTW0VCL",
                        token_provider=current_token) as client:
    try:
        grant = await client.require_agency(
            intent="Invoke underwriting model",
            use_case="underwriting",
            resources=["bedrock:InvokeModel"],
            resource_arns=["arn:aws:bedrock:<region>::foundation-model/<model-id>"],
            trace_id=aigp_trace_id,        # binds the grant to the AIGP trace (X-AIGP-Trace-Id)
        )
    except AgencyRefusedError as e:        # fail closed: e.code says why (REFUSED, BROKER_UNREACHABLE, ...)
        raise SystemExit(f"no agency: {e}")
    session = grant.to_boto3_session(region="us-east-1")
    ...
    await client.release_grant(grant.decision_id, reason="done")   # end it early (no heartbeat)

Mediated Execution (Level 2)

Agent never sees credentials:

result = await client.execute(
    intent="Invoke model for risk assessment",
    use_case="underwriting",
    action="bedrock:InvokeModel",
    parameters={"modelId": "<model-id>", "body": {...}},
)
print(result.output)  # Only the result

Certificate Authentication

from aiap_client import AgencyClient, CertificateSigner

client = AgencyClient(
    broker_url="https://broker.example.com",
    agent_id="YXFQTW0VCL",
    signer=CertificateSigner(cert_path="agent.pem", key_path="agent-key.pem"),
)

Protocol

See RFC-001: AI Agency Protocol

Metadata

Release files for aiap-client 1.1.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 aiap-client 1.1.0
File Size Uploaded Provenance Actions
aiap_client-1.1.0.tar.gz 58.5 kB Without provenance Details for aiap_client-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiap-client 1.1.0
File Interpreter ABI Platform Actions
aiap_client-1.1.0-py3-none-any.whl Python 3 none any Details for aiap_client-1.1.0-py3-none-any.whl

Total release size: 101.7 kB

Release files / aiap_client-1.1.0.tar.gz

Download URL aiap_client-1.1.0.tar.gz
Size 58.5 kB
Tags Source
SHA-256 checksum
How to use checksums
549ce76f137438ca60a8f37c8463157578523062e084391045a2ad83f505b05b
BLAKE2b-256 checksum
How to use checksums
4beff3f1d21a073006bf7eeb43ce25f6fe0cc0eb62054dd663b99c16e371cee5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / aiap_client-1.1.0-py3-none-any.whl

Download URL aiap_client-1.1.0-py3-none-any.whl
Size 43.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
06efd8781ed7e9d9b49065cbfd1eb9af8de581c893a4c863aa37d1801f4dbe89
BLAKE2b-256 checksum
How to use checksums
be22acfd328ea5fb17890245684baa9f8b6d7edcdd2dc28caeb59e834b1cedb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for aiap-client 1.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

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