API Reference

Overview

Athena NodeJS SDK provides real-time image classification for CSAM detection using gRPC. It supports session-based deployments, multi-affiliate collaboration, and a wide range of image formats and error handling features.

Main Classes

  • ClassifierSdk: Main entry point for interacting with the Athena service. Handles authentication, deployment management, and image classification.

  • ClassifierServiceClient: Low-level gRPC client for direct service calls.

  • ClassifierSdkOptions: Configuration options for initializing the SDK.

Usage Example

import { ClassifierSdk } from '@crispthinking/athena-classifier-sdk';

const sdk = new ClassifierSdk({
  deploymentId: 'your-deployment-id', // Chosen by you
  affiliate: 'your-affiliate', // Provided by Resolver
  authentication: {
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret',
  }
});

await sdk.open();
const deployments = await sdk.listDeployments();
// Send image for classification
await sdk.sendClassifyRequest({
  data: fs.createReadStream('image.jpg'),
  format: ImageFormat.IMAGE_FORMAT_JPEG,
});

sdk.on('data', (response) => {
  console.log('Classification result:', response);
});

sdk.on('error', (err) => {
  console.error('Error:', err);
});

sdk.on('close', () => {
  console.log('Connection closed');
});

API Classes

class ClassifierSdk  [source]

SDK for interacting with the Athena classification service via gRPC. Emits events for data, error, open, and close.

Fires: ClassifierSdk#data

Constructor({     grpcAddress = defaultGrpcAddress,     keepAliveInterval,     deploymentId,     affiliate,     authentication,   }: ClassifierSdkOptions)

Constructs a new ClassifierSdk instance.

Parameters

{     grpcAddress = defaultGrpcAddress,     keepAliveInterval,     deploymentId,     affiliate,     authentication,   }: ClassifierSdkOptions

grpcAddress: string
client: ClassifierServiceClient
classifierGrpcCall: grpc.ClientDuplexStream< ClassifyRequest, ClassifyResponse > | null = null
options: ClassifierSdkOptions
auth: AuthenticationManager
keepAlive: NodeJS.Timeout
metadata: grpc.Metadata
listDeployments(): Promise<Deployment[]>

Lists available deployments from the Athena service.

Returns

Promise<Deployment[]> - Promise resolving to an array of deployments.

open(): Promise<void>

Opens a gRPC stream to the Athena classification service. Emits ‘open’ when ready, and sets up keep-alive and event listeners.

Returns

Promise<void> - Promise that resolves when the stream is open.

sendClassifyRequest(request: ClassifyImageInput | ClassifyImageInput[]): Promise<void>

Sends one or more classify requests for images to the Athena service.

Parameters

request: ClassifyImageInput | ClassifyImageInput[]

Single input or array of image classification request options.

Returns

Promise<void> - Promise that resolves when the request is sent.

classifySingle(request: ClassifyImageInput): Promise<ClassificationOutput>

Parameters

request: ClassifyImageInput

Returns

Promise<ClassificationOutput>

close(): void

Closes the gRPC stream and cleans up resources. Emits ‘close’ event.

Returns

void

on(event: U, listener: ClassifierEvents[U]): this

Parameters

event: U

listener: ClassifierEvents[U]

Returns

this

once(event: U, listener: ClassifierEvents[U]): this

Parameters

event: U

listener: ClassifierEvents[U]

Returns

this

off(event: U, listener: ClassifierEvents[U]): this

Parameters

event: U

listener: ClassifierEvents[U]

Returns

this

interface ClassifierSdkOptions  [source]

Options for initializing the ClassifierSdk.

Property: authentication Authentication options for the SDK.

keepAliveInterval: number | undefined
grpcAddress: string
deploymentId: string
affiliate: string
authentication: AuthenticationOptions