Library-first authentication and authorization SDK for AI agents
Project description
agentauthlayer
Python SDK for integrating agent runtimes with the Agent Auth control plane.
agentauthlayer helps you:
- 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 is the reusable SDK layer. It is intended for developers integrating Python agents, tools, and workflows with an Agent Auth deployment.
Install
pip install agentauthlayer
Quickstart
1. First-time developer setup
For a fresh self-hosted deployment, complete the control plane setup before using agentauth login.
- Start your Agent Auth deployment.
- Open the UI in your browser.
- Create the first super admin password.
- Create your first project.
- 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.
2. 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=[],
)
3. 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 loginfor local human developer workflows - use
AGENT_AUTH_TOKENfor 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():
- explicit constructor arguments
- environment variables
- 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) - CLI helpers for login, sync, and agent cleanup
- registry-based tool and agent sync
- permission evaluation helpers
It does not package the full control plane server or admin dashboard.
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 import path remains:
from agent_auth import ...
while the published package name is:
pip install agentauthlayer
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentauthlayer-0.1.3.tar.gz.
File metadata
- Download URL: agentauthlayer-0.1.3.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad28650a5fde8f2471ec1d0310383ec1af492f4f75974007663ce38e89b00996
|
|
| MD5 |
6716af67c6770de89d0c528f45376abc
|
|
| BLAKE2b-256 |
e5f57d251615a364e295571b82bfb577c18f8dafc624cbcb1bed1500126d335e
|
File details
Details for the file agentauthlayer-0.1.3-py3-none-any.whl.
File metadata
- Download URL: agentauthlayer-0.1.3-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f7af5f2a569ce5fcd488068ffaafface0643adbb3401648cd277b7464bb5c6e
|
|
| MD5 |
81f48c9d0b278e0d3354037b11690a04
|
|
| BLAKE2b-256 |
17e7fbd7055ace10e37541779af4fc8e12f75671a737c525b1b12c9d04e9367a
|