Using Authenta
Overview
This guide explains how to use Authenta's detection services through various integration methods.
Integration Methods
1. RabbitMQ Direct Integration
Connect and send tasks to RabbitMQ:
import * as amqp from 'amqplib';
const RABBITMQ_URL = 'amqp://user:pass@rabbitmq:5672/';
async function sendDetectionTask(inputPath, model = 'ac-1') {
// Connect to RabbitMQ
const conn = await amqp.connect(RABBITMQ_URL);
const ch = await conn.createChannel();
// Ensure queues exist
await ch.assertQueue('task_queue', { durable: true });
await ch.assertQueue('task_response', { durable: true });
// Build the job message
const jobMsg = {
id: `job-${Math.floor(Math.random() * 10000)}`,
version: 1,
op: {
name: inputPath.endsWith('.mp4') ? 'df-1' : 'ac-1',
version: '1.0.0',
},
input: {
mimeType: 'application/octet-stream',
provider: 'local_dir',
path: inputPath,
},
outputs: [
{
kind: 'result',
mimeType: 'application/json',
provider: 'local_dir',
path: '/opt/authenta/data/result.json',
},
],
callback: {
mode: 'rabbitmq',
replyTo: 'task_response',
},
};
return jobMsg.id;
}2. Demo Application API
Authenta includes a demo web application bundled inside the Docker deployment. Once your containers are running, the demo interface is available at:
The demo application allows you to:
- Upload test media
- Publish detection tasks to RabbitMQ
- View inference results returned by Authenta
3. Direct File Processing
Process files through shared volume:
- Place input file in
/opt/authenta/data/input/ - Create JSON task file in
/opt/authenta/data/tasks/ - Monitor
/opt/authenta/data/results/for output
Task Types
Deepfake Detection (DF-1)
For video input files:
{
"id": "job-1234",
"version": 1,
"op": {
"name": "df-1",
"version": "1.0.0"
},
"input": {
"mimeType": "application/octet-stream",
"provider": "local_dir",
"path": "/opt/authenta/data/video.mp4"
},
"outputs": [
{
"kind": "result",
"mimeType": "application/json",
"provider": "local_dir",
"path": "/opt/authenta/data/result.json"
}
],
"callback": {
"mode": "rabbitmq",
"replyTo": "task_response"
}
}AI Content Detection (AC-1)
For image input files:
{
"id": "job-5678",
"version": 1,
"op": {
"name": "ac-1",
"version": "1.0.0"
},
"input": {
"mimeType": "application/octet-stream",
"provider": "local_dir",
"path": "/opt/authenta/data/image.jpg"
},
"outputs": [
{
"kind": "result",
"mimeType": "application/json",
"provider": "local_dir",
"path": "/opt/authenta/data/result.json"
},
{
"kind": "heatmaps",
"mimeType": "image/png",
"provider": "local_dir",
"path": "/opt/authenta/data/heatmaps-results",
"filename": "processed-image{ext}"
}
],
"callback": {
"mode": "rabbitmq",
"replyTo": "task_response"
}
}Video Forgery Detection (VF-1)
For video input files:
{
"id": "job-9012",
"version": 1,
"op": {
"name": "vf-1",
"version": "1.0.0"
},
"input": {
"mimeType": "application/octet-stream",
"provider": "local_dir",
"path": "/opt/authenta/data/video.mp4",
},
"outputs": [
{
"kind": "result",
"mimeType": "application/json",
"provider": "local_dir",
"path": "/opt/authenta/data/result.json",
},
],
"callback": {
"mode": "rabbitmq",
"replyTo": "task_response",
},
}Processing Options
| Option | Description | Type |
|---|---|---|
heatmaps | Generate visual heatmaps for detection regions | Optional output |
local_dir | Process files from shared directory | Default provider |
rabbitmq | Use RabbitMQ for task responses | Default callback mode |
Best Practices
-
Task Management
- Generate unique task IDs
- Include callback URLs for async processing
- Set appropriate timeouts
-
Resource Optimization
- Batch similar tasks together
- Monitor queue length
- Scale workers based on load
-
Error Handling
- Implement retry logic
- Monitor task status
- Log failed tasks
Code Examples
Node.js Integration
Complete example showing the full workflow:
import * as amqp from 'amqplib';
const RABBITMQ_URL = 'amqp://user:pass@rabbitmq:5672/';
const SHARED_DIR = '/opt/authenta/data/';
// Process a detection task
async function processDetectionTask(inputPath, outputType = 'result') {
// Connect to RabbitMQ
const conn = await amqp.connect(RABBITMQ_URL);
const ch = await conn.createChannel();
await ch.assertQueue('task_queue', { durable: true });
await ch.assertQueue('task_response', { durable: true });
// Build the job message
const jobMsg = buildJobMsg({
op: inputPath.endsWith('.mp4') ? 'df-1' : 'ac-1',
inputPath: inputPath,
outputType: outputType,
});
// Send task and wait for response
console.log('Publishing task to task_queue...');
ch.sendToQueue('task_queue', Buffer.from(JSON.stringify(jobMsg)), { persistent: true });
// Wait for response
console.log('Waiting for response...');
const result = await new Promise((resolve) => {
ch.consume('task_response', (msg) => {
if (msg !== null) {
const response = JSON.parse(msg.content.toString());
if (response.id === jobMsg.id) {
ch.ack(msg);
resolve(response);
} else {
ch.ack(msg);
}
}
});
});
// Cleanup
await ch.close();
await conn.close();
return result;
}
// Helper to build job message
function buildJobMsg(params) {
const outputs = [
{
kind: 'result',
mimeType: 'application/json',
provider: 'local_dir',
path: '/opt/authenta/data/result.json',
},
];
if (params.outputType === 'result + heatmaps') {
outputs.push({
kind: 'heatmaps',
mimeType: params.op === 'df-1' ? 'video/mp4' : 'image/png',
provider: 'local_dir',
path: '/opt/authenta/data/heatmaps-results',
filename: params.op === 'df-1' ? 'video-heatmap-{faceid}{ext}' : 'processed-image{ext}',
});
}
return {
id: `job-${Math.floor(Math.random() * 10000)}`,
version: 1,
op: { name: params.op, version: '1.0.0' },
input: {
mimeType: 'application/octet-stream',
provider: 'local_dir',
path: params.inputPath,
},
outputs,
callback: { mode: 'rabbitmq', replyTo: 'task_response' },
};
}
// Example usage
try {
const result = await processDetectionTask('/opt/authenta/data/video.mp4', 'result + heatmaps');
console.log('Detection result:', result);
} catch (err) {
console.error('Error:', err);
}Monitoring & Troubleshooting
Queue Monitoring
-
RabbitMQ Queues
task_queue: For submitting detection jobstask_response: For receiving results
-
Dashboard Access
- URL:
http://localhost:15672 - Default credentials:
user/pass
- URL:
Error Handling
The system implements automatic reconnection with exponential backoff:+
async function runWithReconnect() {
while (true) {
try {
await main();
break;
} catch (err) {
console.error('RabbitMQ error, retrying in 5s:', err);
await new Promise(res => setTimeout(res, 5000));
}
}
}Common Issues
-
Connection Issues
# Check RabbitMQ status docker compose ps rabbitmq # View RabbitMQ logs docker compose logs -f rabbitmq -
File Access
# Verify shared directory ls -la /opt/authenta/data # Check permissions sudo chown -R your-user:docker /opt/authenta/data -
Task Processing
- Verify input file exists in shared directory
- Check task runner logs for errors
- Ensure GPU is available (for GPU profile)
Next Steps
- Review maintenance procedures
- Learn about security best practices
- Get support
