Skip to main content
The Private Connect SDK provides a TypeScript/JavaScript client for programmatic access to your Private Connect infrastructure. Use it to connect to services, orchestrate agents, and build distributed systems.

Installation

npm install @privateconnect/sdk

Quick Start

import { PrivateConnect } from '@privateconnect/sdk';

const pc = new PrivateConnect({ apiKey: 'your-api-key' });

// Connect to a service
const db = await pc.connect('postgres-prod');
console.log(db.connectionString); // postgres://localhost:5432/...

// List all agents
const agents = await pc.agents.list();

// Send message to another agent
await pc.agents.sendMessage(targetAgentId, { action: 'deploy' });

Core Concepts

Services

Connect to databases, APIs, and other network services exposed through your Private Connect infrastructure. The SDK automatically provides connection strings and ports.

Agents

Discover and communicate with agents in your workspace. Agents can register capabilities, send messages, and coordinate distributed workflows.

Sessions

Create ephemeral orchestration sessions for coordinating multi-agent workflows with automatic cleanup and TTL.

API Structure

The SDK is organized into three main API namespaces:

Agents API

Discovery, messaging, and orchestration

Services API

Service discovery and connection details

Sessions API

Ephemeral orchestration sessions

Configuration

apiKey
string
required
Your Private Connect API key. Get this from your workspace settings.
hubUrl
string
default:"https://api.privateconnect.co"
Hub URL for Private Connect API. Override for self-hosted deployments.
agentId
string
Agent ID for this client. Auto-detected from local config if not provided.
disableTracking
boolean
default:false
Disable anonymous usage tracking.

Environment Variables

You can configure the SDK using environment variables:
export PRIVATECONNECT_API_KEY="your-api-key"
Then use the convenience function:
import { connect } from '@privateconnect/sdk';

const db = await connect('postgres-prod');

TypeScript Support

The SDK is written in TypeScript and provides full type definitions for all methods, parameters, and return types.
import { 
  PrivateConnect, 
  Agent, 
  Service, 
  Connection,
  Message,
  Session 
} from '@privateconnect/sdk';
See TypeScript Setup for detailed type information.

Error Handling

The SDK throws errors for failed requests:
try {
  const db = await pc.connect('my-database');
} catch (error) {
  console.error('Failed to connect:', error.message);
}
All API methods return promises and should be used with async/await or .then()/.catch().

Next Steps

TypeScript Setup

Configure TypeScript and explore type definitions

Agents API

Build distributed agent systems

Services API

Connect to your infrastructure

Sessions API

Coordinate multi-agent workflows

Build docs developers (and LLMs) love