diff --git a/examples/charge.ts b/examples/charge.ts new file mode 100644 index 0000000..8b183e7 --- /dev/null +++ b/examples/charge.ts @@ -0,0 +1,18 @@ +import { Ainize } from '@ainize-team/ainize-js'; +const ainPrivateKey = ''; // Insert your private key here +const main = async () => { + try { + const ainize = new Ainize(0); // 0 for testnet, 1 for mainnet. You can earn testnet AIN at https://faucet.ainetwork.ai/. + await ainize.login(ainPrivateKey); + console.log('balance: ',await ainize.getAinBalance()); + const model = await ainize.getModel('ainize_free_inference'); + console.log(model.modelName); + console.log("before charge: ",await model.getCreditBalance()); + await model.chargeCredit(10); + console.log("after charge: ",await model.getCreditBalance()); + ainize.logout(); + }catch(e) { + console.log(e); + } +} +main(); diff --git a/examples/deploy.ts b/examples/deploy.ts new file mode 100644 index 0000000..425fb4b --- /dev/null +++ b/examples/deploy.ts @@ -0,0 +1,20 @@ +import { Ainize } from '@ainize-team/ainize-js'; +const ainPrivateKey = ''; // Insert your private key here + +const main = async () => { + try { + const ainize = new Ainize(0); // 0 for testnet, 1 for mainnet. You can earn testnet AIN at https://faucet.ainetwork.ai/. + await ainize.login(ainPrivateKey); + console.log('balance: ',await ainize.getAinBalance()); + const deployConfig = { + modelName: 'YOUR_MODEL_NAME', + modelUrl: 'YOUR_MODEL_INFERENCE_URL' // e.g. https://ainize-free-inference.ainetwork.xyz + } + const model = await ainize.deploy(deployConfig); + console.log(model.modelName); + ainize.logout(); + }catch(e) { + console.log(e); + } +} +main(); diff --git a/examples/request.ts b/examples/request.ts new file mode 100644 index 0000000..7151cb9 --- /dev/null +++ b/examples/request.ts @@ -0,0 +1,24 @@ +import { Ainize } from '@ainize-team/ainize-js'; +const ainPrivateKey = ''; // Insert your private key here + +const main = async () => { + try { + const ainize = new Ainize(0); // 0 for testnet, 1 for mainnet. You can earn testnet AIN at https://faucet.ainetwork.ai/. + await ainize.login(ainPrivateKey); + console.log('balance: ',await ainize.getAinBalance()); + const inferenceModel = await ainize.getModel('ainize_free_inference'); + console.log(inferenceModel.modelName); + console.log(await inferenceModel.getCreditBalance()); + const request = { + "prompt": "hi" + }; + const cost = await inferenceModel.calculateCost(request.prompt); + console.log(cost); + const response = await inferenceModel.request(request); + console.log(response); + ainize.logout(); + }catch(e) { + console.log(e); + } +} +main();