A Typescript JS for the Ainize, a system for running AI services on the AI Network.
node >= 16
npm install @ainize-team/ainize-js
yarn install @ainize-team/ainize-js
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
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.
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();
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>);