@actorhubai/sdk
v0.1.0
Published
Official JavaScript/TypeScript SDK for ActorHub.ai - Verify AI-generated content against protected identities
Maintainers
Readme
ActorHub JavaScript/TypeScript SDK
Official JavaScript/TypeScript SDK for ActorHub.ai - Verify AI-generated content against protected identities.
Installation
npm install @actorhub/sdk
# or
yarn add @actorhub/sdk
# or
pnpm add @actorhub/sdkQuick Start
import { ActorHub } from '@actorhub/sdk';
// Initialize the client
const client = new ActorHub({ apiKey: 'your-api-key' });
// Verify if an image contains protected identities
const result = await client.verify({
imageUrl: 'https://example.com/image.jpg'
});
if (result.protected) {
console.log('Protected identity detected!');
for (const identity of result.identities) {
console.log(` - ${identity.displayName} (similarity: ${identity.similarityScore})`);
}
}Features
- TypeScript First: Full type definitions included
- Universal: Works in Node.js and browsers
- Identity Verification: Check if images contain protected identities
- Consent Checking: Verify consent before AI generation
- Marketplace Access: Browse and license identities
- Automatic Retries: Built-in retry logic with exponential backoff
- Error Handling: Typed error classes for easy handling
Usage Examples
Verify Image
import { ActorHub } from '@actorhub/sdk';
const client = new ActorHub({ apiKey: 'your-api-key' });
// From URL
const result = await client.verify({
imageUrl: 'https://example.com/image.jpg'
});
// From base64
const result = await client.verify({
imageBase64: 'base64-encoded-data...'
});
console.log(`Protected: ${result.protected}`);
console.log(`Faces detected: ${result.facesDetected}`);Check Consent (for AI Platforms)
const result = await client.checkConsent({
imageUrl: 'https://example.com/face.jpg',
platform: 'runway',
intendedUse: 'video',
region: 'US'
});
if (result.protected) {
for (const face of result.faces) {
console.log(`Consent for video: ${face.consent.videoGeneration}`);
console.log(`License available: ${face.license.available}`);
}
}Browse Marketplace
// Search listings
const listings = await client.listMarketplace({
query: 'actor',
category: 'ACTOR',
sortBy: 'popular',
limit: 10
});
for (const listing of listings) {
console.log(`${listing.title} - $${listing.basePriceUsd}`);
}Purchase License
import { LicenseType, UsageType } from '@actorhub/sdk';
const purchase = await client.purchaseLicense({
identityId: 'uuid-here',
licenseType: LicenseType.STANDARD,
usageType: UsageType.COMMERCIAL,
projectName: 'My AI Project',
projectDescription: 'Creating promotional content',
durationDays: 30,
});
// Redirect user to Stripe checkout
console.log(`Checkout URL: ${purchase.checkoutUrl}`);Get My Licenses
const licenses = await client.getMyLicenses({ status: 'active' });
for (const license of licenses) {
console.log(`${license.identityName} - ${license.licenseType} - Expires: ${license.expiresAt}`);
}Error Handling
import {
ActorHub,
AuthenticationError,
RateLimitError,
ValidationError,
NotFoundError,
} from '@actorhub/sdk';
const client = new ActorHub({ apiKey: 'your-api-key' });
try {
const result = await client.verify({
imageUrl: 'https://example.com/image.jpg'
});
} catch (error) {
if (error instanceof AuthenticationError) {
console.error('Invalid API key');
} else if (error instanceof RateLimitError) {
console.error(`Rate limit exceeded. Retry after: ${error.retryAfter} seconds`);
} else if (error instanceof ValidationError) {
console.error(`Validation error: ${error.message}`);
} else if (error instanceof NotFoundError) {
console.error('Resource not found');
}
}Configuration
const client = new ActorHub({
apiKey: 'your-api-key',
baseUrl: 'https://api.actorhub.ai', // Custom base URL
timeout: 30000, // Request timeout in ms
maxRetries: 3, // Max retry attempts
});API Reference
ActorHub Client
| Method | Description |
|--------|-------------|
| verify() | Verify if image contains protected identities |
| getIdentity() | Get identity details by ID |
| checkConsent() | Check consent status for AI generation |
| listMarketplace() | Search marketplace listings |
| getMyLicenses() | Get user's purchased licenses |
| purchaseLicense() | Purchase a license |
| getActorPack() | Get Actor Pack status |
Browser Usage
The SDK works in browsers with native fetch:
<script type="module">
import { ActorHub } from 'https://esm.sh/@actorhub/sdk';
const client = new ActorHub({ apiKey: 'your-api-key' });
const result = await client.verify({ imageUrl: '...' });
</script>Requirements
- Node.js 16+ (for Node.js usage)
- Modern browser with ES2020 support
License
MIT License - see LICENSE for details.
