Skip to main content

Node.js SDK

Official IAIndex SDK for Node.js applications.

Installation

npm install @iaindex/sdk
# or
yarn add @iaindex/sdk

Quick Start

const { IAIndexPublisher, IAIndexClient } = require('@iaindex/sdk');

// As a publisher
const publisher = new IAIndexPublisher({
domain: 'yourdomain.com',
privateKey: process.env.IAINDEX_PRIVATE_KEY,
name: 'Your Publication',
contact: 'contact@yourdomain.com'
});

await publisher.addEntry({
url: 'https://yourdomain.com/article',
title: 'Article Title',
author: 'Author Name',
publishedDate: new Date().toISOString(),
license: { type: 'CC-BY-4.0' }
});

// As an AI client
const client = new IAIndexClient({
clientId: 'your-client-id',
privateKey: process.env.CLIENT_PRIVATE_KEY
});

const content = await client.accessContent('https://example.com/article');
await client.sendReceipt(content, {
purpose: 'training',
context: 'language-model-pretraining'
});

API Reference

IAIndexPublisher

Constructor

new IAIndexPublisher(options)

Options:

  • domain (string): Your verified domain
  • privateKey (string): Private key for signing
  • name (string): Publisher name
  • contact (string): Contact email

Methods

addEntry(entry)

await publisher.addEntry({
url: string,
title: string,
author: string,
publishedDate: string,
license: object
});

generateIndex()

const index = await publisher.generateIndex();

verifyReceipt(receipt)

const isValid = await publisher.verifyReceipt(receipt);

IAIndexClient

Constructor

new IAIndexClient(options)

Options:

  • clientId (string): Unique client identifier
  • privateKey (string): Private key for signing
  • name (string): Client/model name
  • organization (string): Organization name

Methods

accessContent(url)

const content = await client.accessContent(url);

sendReceipt(content, usage)

await client.sendReceipt(content, {
purpose: 'training' | 'inference' | 'research',
context: string,
datasetId?: string,
modelId?: string
});

Examples

See GitHub Examples