Skip to content

TypeScript SDK

The official TypeScript SDK for integrating with the LMIF API.

Terminal window
npm install @lookmaimfamous/lmif
import { LMIFClient } from '@lookmaimfamous/lmif';
const lmif = new LMIFClient({
apiKey: process.env.LMIF_API_KEY,
});
// Check if an identity is protected
const result = await lmif.identity.check({
name: 'Taylor Swift',
imageUrl: 'https://example.com/avatar.jpg',
});
if (result.isBoxed) {
console.log('Identity is protected:', result.policy);
}
const lmif = new LMIFClient({
// Required: Your API key
apiKey: 'lmif_live_xxx',
// Optional: Override environment detection
environment: 'production', // or 'sandbox'
// Optional: Custom timeout (default: 30000ms)
timeout: 60000,
// Optional: Custom retry configuration
retry: {
maxRetries: 3,
retryDelay: 1000,
},
});

The core method for checking if an identity is protected.

const result = await lmif.identity.check({
name: 'Celebrity Name',
imageUrl: 'https://example.com/avatar.jpg',
description: 'AI companion avatar', // Optional
context: 'avatar_creation', // Optional
});
// Result type
interface IdentityCheckResult {
isBoxed: boolean;
isClaimed: boolean;
confidence: number;
matchedIdentity?: {
claimId: string;
boxId: string;
name: string;
entityType: EntityType;
verificationTier: VerificationTier;
};
policy?: PolicyType;
policyDetails?: PolicyDetails;
action: RecommendedAction;
}
const results = await lmif.identity.checkBatch([
{ id: 'avatar_1', name: 'Celebrity A', imageUrl: 'https://...' },
{ id: 'avatar_2', name: 'Celebrity B', imageUrl: 'https://...' },
{ id: 'avatar_3', name: 'Celebrity C', imageUrl: 'https://...' },
]);
// Returns array of results with your IDs
results.forEach((result) => {
console.log(`${result.id}: ${result.action}`);
});

Manage identity claims.

// List claims
const claims = await lmif.claims.list({
status: 'verified',
limit: 20,
});
// Get a claim
const claim = await lmif.claims.get('claim_xyz789');
// Create a claim
const newClaim = await lmif.claims.create({
name: 'John Smith',
variations: ['J. Smith'],
entityType: 'INDIVIDUAL',
referenceImages: [
{ url: 'https://example.com/photo.jpg', isPrimary: true },
],
});
// Update a claim
await lmif.claims.update('claim_xyz789', {
variations: ['J. Smith', 'Johnny Smith'],
});
// Delete a claim
await lmif.claims.delete('claim_xyz789');

Manage protection boxes.

// List boxes
const boxes = await lmif.boxes.list({
policy: 'MONETIZE',
});
// Get a box
const box = await lmif.boxes.get('box_abc123');
// Create a box
const newBox = await lmif.boxes.create({
claimId: 'claim_xyz789',
policy: 'MONETIZE',
enforcement: 'MODERATE',
policyConfig: {
royaltyRate: 0.10,
revenueTypes: ['subscription', 'per_message', 'tips'],
},
});
// Update a box
await lmif.boxes.update('box_abc123', {
policy: 'BLOCK_ALL',
});
// Delete a box
await lmif.boxes.delete('box_abc123');
// Get statistics
const stats = await lmif.boxes.getStats('box_abc123');

Manage licenses for protected identities.

// List licenses
const licenses = await lmif.licenses.list({
status: 'active',
});
// Request a license
const request = await lmif.licenses.request({
boxId: 'box_abc123',
tier: 'commercial',
useCase: 'AI companion platform',
estimatedUsers: 10000,
acceptGuidelines: true,
});
// Check request status
const status = await lmif.licenses.getRequestStatus(request.id);
// Get a license
const license = await lmif.licenses.get('lic_xyz789');
// Renew a license
await lmif.licenses.renew('lic_xyz789', {
term: 12,
});
// Cancel a license
await lmif.licenses.cancel('lic_xyz789', {
reason: 'no_longer_needed',
});
// Report usage
await lmif.licenses.reportUsage('lic_xyz789', {
period: '2024-01',
metrics: {
subscribers: 5000,
messages: 250000,
},
revenue: {
subscriptions: 25000,
messages: 5000,
},
});

Track and manage violations.

// List violations
const violations = await lmif.violations.list({
status: 'pending',
});
// Get a violation
const violation = await lmif.violations.get('viol_abc123');
// Resolve a violation
await lmif.violations.resolve('viol_abc123', {
resolution: 'removed',
avatarId: 'avatar_123',
});
// Appeal a violation
await lmif.violations.appeal('viol_abc123', {
reason: 'parody',
explanation: 'This is clearly satirical content',
});

Manage compliance windows.

// List active grace periods
const gracePeriods = await lmif.gracePeriods.list({
status: 'active',
expiringWithin: 7, // Days
});
// Get a grace period
const gp = await lmif.gracePeriods.get('gp_abc123');
// Resolve a grace period
await lmif.gracePeriods.resolve('gp_abc123', {
resolution: 'licensed',
licenseId: 'lic_xyz789',
avatarId: 'avatar_123',
});

Manage webhook endpoints.

// List webhooks
const webhooks = await lmif.webhooks.list();
// Create a webhook
const webhook = await lmif.webhooks.create({
url: 'https://yoursite.com/webhooks/lmif',
events: ['box.created', 'grace_period.started'],
});
// Verify a webhook signature
const isValid = lmif.webhooks.verify(
rawPayload, // Buffer or string
signature, // From X-LMIF-Signature header
secret // Your webhook secret
);
// Send a test event
await lmif.webhooks.test({
eventType: 'box.created',
endpoint: 'https://yoursite.com/webhooks/lmif',
});
// Rotate secret
const newSecret = await lmif.webhooks.rotateSecret('wh_xyz789');
// Delete webhook
await lmif.webhooks.delete('wh_xyz789');
import { LMIFClient, LMIFError } from '@lookmaimfamous/lmif';
try {
const result = await lmif.identity.check({ name, imageUrl });
} catch (error) {
if (error instanceof LMIFError) {
console.error('LMIF Error:', error.code, error.message);
switch (error.code) {
case 'RATE_LIMITED':
// Wait and retry
await sleep(error.retryAfter * 1000);
break;
case 'UNAUTHORIZED':
// Check API key
break;
case 'VALIDATION_ERROR':
// Check request parameters
console.error('Validation errors:', error.details);
break;
}
}
}

The SDK exports all types for use in your application:

import type {
// Enums
EntityType,
PolicyType,
EnforcementLevel,
VerificationTier,
RecommendedAction,
// Request types
IdentityCheckRequest,
ClaimCreateRequest,
BoxCreateRequest,
LicenseRequestRequest,
// Response types
IdentityCheckResult,
Claim,
Box,
License,
Violation,
GracePeriod,
// Webhook types
WebhookEvent,
BoxCreatedEvent,
GracePeriodStartedEvent,
} from '@lookmaimfamous/lmif';
import { LMIFClient } from '@lookmaimfamous/lmif';
const lmif = new LMIFClient({ apiKey: process.env.LMIF_API_KEY });
// Middleware to check identity before avatar creation
export async function checkIdentityMiddleware(req, res, next) {
const { name, imageUrl } = req.body;
try {
const result = await lmif.identity.check({ name, imageUrl });
if (result.action === 'BLOCK') {
return res.status(403).json({
error: 'Identity is protected',
policy: result.policy,
});
}
// Attach result to request for downstream use
req.identityCheck = result;
next();
} catch (error) {
next(error);
}
}
// Usage
app.post('/avatars', checkIdentityMiddleware, createAvatarHandler);

The SDK automatically handles rate limits:

const lmif = new LMIFClient({
apiKey: process.env.LMIF_API_KEY,
retry: {
maxRetries: 3,
retryDelay: 1000, // Base delay in ms
},
});
// The SDK will automatically retry rate-limited requests
// with exponential backoff