Official JavaScript/TypeScript SDK for ActorHub.ai - Verify AI-generated content against protected identities
npm install @actorhubai/sdkOfficial JavaScript/TypeScript SDK for ActorHub.ai - Verify AI-generated content against protected identities.
``bash`
npm install @actorhub/sdkor
yarn add @actorhub/sdkor
pnpm add @actorhub/sdk
`typescript
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}));`
}
}
- 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
`typescript
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});Faces detected: ${result.facesDetected}
console.log();`
`typescript
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});License available: ${face.license.available}
console.log();`
}
}
`typescript
// 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});`
}
`typescript
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});`
`typescript
const licenses = await client.getMyLicenses({ status: 'active' });
for (const license of licenses) {
console.log(${license.identityName} - ${license.licenseType} - Expires: ${license.expiresAt});`
}
`typescript
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);Validation error: ${error.message}
} else if (error instanceof ValidationError) {
console.error();`
} else if (error instanceof NotFoundError) {
console.error('Resource not found');
}
}
`typescript`
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
});
| 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 |
The SDK works in browsers with native fetch:
`html``
- Node.js 16+ (for Node.js usage)
- Modern browser with ES2020 support
MIT License - see LICENSE for details.