Skip to main content

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

Project description

agent-identity Python SDK

Pure-Python client for the agent-identity sidecar. No Node.js required.

Install

pip install 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

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)

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.4.0.tar.gz (5.9 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.4.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: datacules_agent_identity-0.4.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for datacules_agent_identity-0.4.0.tar.gz
Algorithm Hash digest
SHA256 adf7e50763c61fd8c8f690c0ac4a2e016f5642e97901270bb4a3904b349f0841
MD5 14d6c8d810fb5435f63ad78b34e0bbff
BLAKE2b-256 2e4841cfcddea3677a720a6e2842412a73dbd215066adbb9d10b7825a8805812

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for datacules_agent_identity-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6bf8e6bb0d75fc6f2874b53c49ea7b147f2452ace8ce4a1befa32009e3c9b41
MD5 b5b1df285385b2d50806b0df866639c3
BLAKE2b-256 f3f67db45890221d342415c41c0a6aad7461ea59b2e6903bf2d82a60117a4dfc

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