A Typescript SDK for the Ainize, a system for running AI services on the AI Network.
node >= 16
npm install @ainize-team/ainize-sdk
yarn install @ainize-team/ainize-sdk
import Ainize from '@ainize-team/ainize-sdk'
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 deploy your AI model to ainize.
const model = await ainize.deploy(<CONFIGURATION>);
CONFIGURATION
- modelName: The name you want to deploying model.
- billingConfig: Billing configuration required for model usage.
- depositAddress: The address for receiving AIN deposits.
- costPerToken: Cost per token for model usage.
- minCost: Minimum cost.
- maxCost: Maximum cost. (optional)
You can stop or run your model container. Model deployer only can use this.
model.stop();
model.run();
You can use a model using ainize.model(<MODEL_NAME>)
.
const model = await ainize.model(<MODEL_NAME>);
You should deposit AIN to credit before using model.
await model.deposit(<AMOUNT>);
const balance = await model.getCreditBalance();
If you have enough credit, you can use the model.
const result = await model.use(<REQUEST_DATA>);