Skip to main content

Python SDK for the agent-identity credential routing sidecar — by Datacules LLC

Project description

Agent Identity — by Datacules LLC

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


Download files

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

Source Distribution

datacules_agent_identity-0.11.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

datacules_agent_identity-0.11.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file datacules_agent_identity-0.11.1.tar.gz.

File metadata

File hashes

Hashes for datacules_agent_identity-0.11.1.tar.gz
Algorithm Hash digest
SHA256 6c7ae74dcbbe117020713508e2b39c53ba2b2a3272d89a97574250a5c35a1e29
MD5 1d551366d5e87876f66df5e6e9ae2622
BLAKE2b-256 59ebb14d5dac717278bcc95030c2c7517ba64bded6e811fa5f354cac5a800672

See more details on using hashes here.

File details

Details for the file datacules_agent_identity-0.11.1-py3-none-any.whl.

File metadata

File hashes

Hashes for datacules_agent_identity-0.11.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f89037bfd0c6999add278bec186cbc490d3a9775fe6f08f02956fff8d9adaec1
MD5 19c12eb82a5d3f5e4928ad5f32dc37e4
BLAKE2b-256 454447a520575f5dadecf4cdfd91eba78318acbbcde103f9aa932ac72cb828c0

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