Python SDK for the agent-identity credential routing sidecar — by Datacules LLC
Project description
agent-identity Python SDK
pip install datacules-agent-identity
Pure-Python client for the agent-identity sidecar. No Node.js required in your Python environment — the sidecar runs separately (Docker or npm run dev).
Install
pip install datacules-agent-identity
Usage
from agent_identity import AgentIdentityClient
from datetime import datetime, timezone
client = AgentIdentityClient(base_url="http://localhost:3001")
# Resolve a credential for a single agent request
resolved = client.resolve({
"userId": "user-abc",
"resourceId": "crm-db",
"resourceKind": "shared",
"provider": "anthropic",
"model": "claude-sonnet-4-20250514",
"action": "read",
"traceId": "trace-xyz",
"requestedAt": datetime.now(timezone.utc).isoformat(),
})
print(resolved["resolvedFor"]) # 'service' or userId
# Resolve source + target credentials for a migration phase
pair = client.resolve_migration({
"migrationId": "migration-2026-q2",
"phase": "load",
"sourceResourceId": "crm-postgres-prod",
"targetResourceId": "crm-postgres-v2",
"userId": "svc-migration-bot",
"provider": "anthropic",
"model": "claude-sonnet-4-20250514",
"traceId": "trace-abc123",
"dryRun": False,
})
print(pair["expiresAt"]) # ISO 8601 or None
Async client
import asyncio
from agent_identity import AsyncAgentIdentityClient
async def main():
async with AsyncAgentIdentityClient(base_url="http://localhost:3001") as client:
resolved = await client.resolve({...})
print(resolved["resolvedFor"])
asyncio.run(main())
LangChain integration
from langchain_anthropic import ChatAnthropic
from agent_identity import AgentIdentityClient
client = AgentIdentityClient()
resolved = client.resolve({...})
# resolved["resolvedFor"] is safe to log; the raw API key stays on the server
llm = ChatAnthropic(model="claude-sonnet-4-20250514")
# The sidecar injects the API key server-side when you call /api/resolve
Error handling
from agent_identity import AgentIdentityClient, NoCredentialError, ValidationError
try:
result = client.resolve(ctx)
except NoCredentialError:
# 403 — no routing rule matched this context
...
except ValidationError as e:
# 400 — bad request body
print(e)
Starting the sidecar
# Docker
docker pull datacules/agent-identity
docker run -p 3001:3001 datacules/agent-identity
# Or from source
git clone https://github.com/hvrcharon1/agent-identity.git
cd agent-identity && npm install --legacy-peer-deps && npm run dev
# Then point your Python client at http://localhost:3000 (dev) or :3001 (Docker)
Part of the agent-identity monorepo by Datacules LLC.
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 datacules_agent_identity-0.11.0.tar.gz.
File metadata
- Download URL: datacules_agent_identity-0.11.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5df5cde411d41d430695c467e79f80fbe0d04c55a6814b3ac94f6ad89f2f3217
|
|
| MD5 |
9da2ad90b321a8abef30aa841472b209
|
|
| BLAKE2b-256 |
4e7f2a4f52eab05676b7050eebd632a86bb15334e34c90c9dda8f5d335480aac
|
File details
Details for the file datacules_agent_identity-0.11.0-py3-none-any.whl.
File metadata
- Download URL: datacules_agent_identity-0.11.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f73587d1cd27381e7ca5b53a9b6e282f3c8f96cd231b05e10c30ed0592669dd
|
|
| MD5 |
faa2566a184c23deff9d1817d518cedc
|
|
| BLAKE2b-256 |
f69f0b08bf01c12c4e2072b8dc545c8fe137354b6d44d14557b77b8fe782d461
|