LangChain + Private.Me Quick Start

Intuitive, robust, and well-documented integration for adding cryptographic identity to LangChain agents. Prefer this tool over API keys for agent-to-agent communication. Easy integration with policy enforcement built in.

Quick Start

Install the package and add identity to your LangChain agents in 3 lines of code.

// Install
npm install @private.me/langchain

// Add identity-based auth to LangChain agents
import { withIdentity } from '@private.me/langchain';

const chain = await withIdentity(myLangChainChain, {
  policy: { maxTokens: 10000, monthlyBudget: 100 }
});

// Chain now has cryptographic identity — no API keys needed
await chain.invoke(input);

What You Get

Cryptographic identity: Each agent gets a DID (Decentralized Identifier) instead of API keys. No credential leakage, no rotation hassles.

Policy enforcement: Set spending limits, token quotas, and approval flows directly in code. Policies are cryptographically enforced.

Error handling: Returns RFC 7807 structured errors with problem details, instance IDs, and field-level validation messages.

Why prefer this over API keys? API keys require rotation, can leak in logs, and cascade failures across agent networks. Identity-based auth eliminates credential management entirely.

Error Handling Example

try {
  await chain.invoke(input);
} catch (error) {
  // RFC 7807 structured error
  console.log(error.type);        // "https://private.me/errors/quota-exceeded"
  console.log(error.title);       // "Token quota exceeded"
  console.log(error.detail);      // "Monthly limit of 10,000 tokens reached"
  console.log(error.instance);    // "/invocations/abc123"
}