sdk documentation

@neuranet/sdk - typescript/javascript sdk for neuranet

installation

npm install @neuranet/sdk
# or
pnpm add @neuranet/sdk
# or
yarn add @neuranet/sdk

quick start

import { NeuraNETClient } from '@neuranet/sdk';

const client = new NeuraNETClient({
  baseUrl: 'https://api.neuranet.network',
  timeout: 30000,
});

// authenticate with wallet
const { nonce, message } = await client.getNonce(walletAddress);
const signature = await wallet.signMessage(message);
await client.authenticate(walletAddress, signature, nonce);

// deploy a workload
const { deployment } = await client.createDeployment({
  nodeId: 'node_abc123',
  name: 'my-ollama-server',
  templateId: 'ollama',
});

console.log(deployment.endpoints);

sdk modules

error handling

import { NeuraNETClient, NeuraNETError } from '@neuranet/sdk';

try {
  const deployment = await client.getDeployment('invalid-id');
} catch (error) {
  if (error instanceof NeuraNETError) {
    console.error(`Error ${error.statusCode}: ${error.message}`);
    
    if (error.statusCode === 401) {
      await client.refreshAuth();
    }
  }
}

typescript support

the sdk is fully typed and exports all types from @neuranet/shared-types:

import {
  NeuraNETClient,
  NeuraNETError,
  // Types
  User,
  Node,
  Deployment,
  DeploymentStatus,
  Template,
  CreditBalance,
  CreditTransaction,
} from '@neuranet/sdk';