Skip to content

ainize-team/ainize-js

Repository files navigation

ainize-js

A Typescript JS for the Ainize, a system for running AI services on the AI Network.

Requirements

node >= 16

usage

Install

npm install @ainize-team/ainize-js

yarn install @ainize-team/ainize-js

Import

import Ainize from '@ainize-team/ainize-js'
const ainize = new Ainize(<CHAIN_ID>);

CHAIN_ID

  • 0: AI Network test net
  • 1: AI Network main net

Login

You should login to ainize with AI Network account before deploy the container.

ainize.login(<YOUR_PRIVATE_KEY>);

You can also login using AIN Wallet on the web.

ainize.loginWithSigner();

This feature is supported from AIN Wallet version 2.0.5 or later.

Deploy

You can deploy your AI service to ainize.

const service = await ainize.deploy(<CONFIGURATION>);

CONFIGURATION

  • serviceName: The name you want to deploying service.
  • billingConfig: Billing configuration required for service usage.
    • depositAddress: The address for receiving AIN deposits.
    • costPerToken: Cost per token for service usage.
    • minCost: Minimum cost.
    • maxCost: Maximum cost. (optional)

You can stop or run your service container. Only service deployer can use this.

service.stop();
service.run();

Using Service

You can use a service using ainize.getService(<SERVICE_NAME>).

const service = await ainize.getService(<SERVICE_NAME>);

You should deposit AIN to credit before using service.

await service.chargeCredit(<AMOUNT>);
const balance = await service.getCreditBalance();

If you have enough credit, you can use the service.

const result = await service.request(<REQUEST_DATA>);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •