Skip to main content

Library-first authentication and authorization SDK for AI agents

Project description

agentauthlayer

Unified SDK and local control plane package for Agent Auth.

agentauthlayer helps you:

  • start a local Agent Auth backend and UI with one command
  • authenticate once and reuse local credentials
  • register agents from code
  • sync tool and capability definitions
  • evaluate permissions against the control plane
  • apply permission checks inside runtime functions

This package now ships as a unified developer install containing:

  • the reusable Python SDK layer
  • the local control plane backend runtime
  • the packaged admin UI assets

Install

pip install agentauthlayer

Quickstart

1. Start the local control plane

For a local developer setup, start Agent Auth with one command:

agentauth up

This starts the packaged local control plane on http://127.0.0.1:8002 by default.

If you want a different port:

agentauth up --port 8014

2. First-time developer setup

For a fresh deployment:

  1. Open the UI in your browser.
  2. Create the first super admin password.
  3. Create your first project.
  4. Then log in from the CLI.

Open the UI with:

agentauth ui --base-url http://127.0.0.1:8002

Then log in once:

agentauth login --base-url http://127.0.0.1:8002

This stores local credentials so your code can connect without manually pasting a token every time.

Useful follow-up commands:

agentauth whoami
agentauth logout
agentauth ui

If the deployment has not been initialized yet, agentauth login will tell you to finish setup in the UI first.

3. Define tools and agents in code

from agent_auth import register_tool, register_agent, require_permission

@register_tool(action="math.compute", description="Run approved math jobs")
@require_permission("math.compute", resource="math/basic")
def add(a: int, b: int, agent_id: str | None = None, role: str | None = None, context: dict | None = None):
    return a + b

register_agent(
    agent_id="math-agent",
    name="Math Agent",
    owner="you@company.com",
    role="research_agent",
    project_id="ai-platform",
    scopes=[],
)

4. Sync everything with one command

agentauth sync --module your_module_name

This imports the module, discovers registered tools and agents, syncs capability definitions, and creates agents through the control plane.

SDK client usage

from agent_auth import AuthAPIClient

client = AuthAPIClient()

agent = client.create_agent(
    agent_id="research-bot-01",
    name="Research Bot 01",
    owner="vaibhav@company.com",
    role="research_agent",
    scopes=[],
    project_id="ai-platform",
)

print(agent)

Environment variables

If you prefer non-interactive configuration, the SDK also supports environment variables:

export AGENT_AUTH_URL=http://127.0.0.1:8002
export AGENT_AUTH_TOKEN=YOUR_ADMIN_OR_SERVICE_TOKEN

AGENT_AUTH_TOKEN is typically a bearer token, often represented as a long JWT string.

Recommended usage:

  • use agentauth login for local human developer workflows
  • use AGENT_AUTH_TOKEN for CI, automation, or service-driven execution

If an env token expires, requests will fail until you replace it or log in again. Avoid committing tokens into source control or long-lived shared .env files.

Resolution order used by AuthAPIClient():

  1. explicit constructor arguments
  2. environment variables
  3. stored local credentials from agentauth login

Common tasks

Sync tools manually

client.sync_tools([
    {"action": "tool.search_web", "description": "Search the web"},
    {"action": "docs.read", "description": "Read protected docs"},
])

Evaluate access

decision = client.evaluate(
    principal_id="research-bot-01",
    action="tool.search_web",
    resource="web/*",
    role="research_agent",
)

print(decision)

Fetch or delete an agent

agent = client.get_agent("research-bot-01")
print(agent)

result = client.delete_agent("research-bot-01")
print(result)

CLI equivalent:

agentauth delete-agent research-bot-01

Public package scope

This package provides:

  • the Python SDK (agent_auth)
  • local control plane startup via agentauth up
  • packaged backend runtime (auth_app)
  • packaged admin UI assets
  • CLI helpers for login, sync, and agent cleanup
  • registry-based tool and agent sync
  • permission evaluation helpers

Suitable use cases

  • Python agent runtimes
  • tool-based workflows
  • service-to-control-plane integrations
  • local development with stored credentials
  • CI or automation using environment variables

Requirements

  • Python 3.10+
  • access to a running Agent Auth control plane

Notes

The package naming model is:

  • install name: agentauthlayer
  • CLI: agentauth
  • Python import namespace: agent_auth

The import path remains:

from agent_auth import ...

while the published package name is:

pip install agentauthlayer

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentauthlayer-0.1.9.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentauthlayer-0.1.9-py3-none-any.whl (263.7 kB view details)

Uploaded Python 3

File details

Details for the file agentauthlayer-0.1.9.tar.gz.

File metadata

  • Download URL: agentauthlayer-0.1.9.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for agentauthlayer-0.1.9.tar.gz
Algorithm Hash digest
SHA256 5a6da3101fffc755488f1218186ec689e2b31d3000d41c397338f6237531fda1
MD5 ade8711369779064088a09aed4e063f3
BLAKE2b-256 08a0d4f022e474744476060aef6b70be1cef3980b0c8e8e4f6768fbbb865d864

See more details on using hashes here.

File details

Details for the file agentauthlayer-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: agentauthlayer-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 263.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for agentauthlayer-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 c3e0b64eeaac9d3cdb5d17eea60231f17981fa25cddff64dd88f5e6f363a7bf5
MD5 db361b0850ec87f99dcf1c38af7ea020
BLAKE2b-256 a3ea4d8fd93db8caab6446d7b723e618700b475c937a2416d75b92b9a1a5d21e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page