> For the complete documentation index, see [llms.txt](https://docs.nesa.ai/nesa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nesa.ai/nesa/using-nesa/via-sdk.md).

# Via SDK

Nesa provides a developer-friendly SDK for executing inference requests in both browser and node environments.

{% hint style="info" %}
**Official SDK URL:** [**https://www.npmjs.com/package/@nesaorg/ai-sdk**](https://www.npmjs.com/package/@nesaorg/ai-sdk)
{% endhint %}

***

## Overview

In this section, we cover high-level SDK usage information; on the other hand, a more detailed, code-level set of documentation can be found [**`here`**](https://github.com/nesaorg/ai-sdk-ts/blob/main/README.md).&#x20;

***

### 1. AIClientRpc: Connect to Nesa Chain

Interactions with Nesa Chain take place via an **`AIClientRpc`** instance. To create one, pass your desired **`AIClientRpcConfiguration`** to your client's **`initialize`** method. You may find an example [**`here`**](https://github.com/nesaorg/ai-sdk-ts?tab=readme-ov-file#creating-an-aiclient-instance).

***

### 2. AISession: Create a Session

Establishing a session allows you to place a one-time deposit, or lock, for your upcoming inference requests via an on-chain transaction. To create a session, pass your desired **`AIClientRpcSessionInitParams`** to your **`AIClientRpc`**  instance's **`createSession`** method. You may find an example [**`here`**](https://github.com/nesaorg/ai-sdk-ts?tab=readme-ov-file#creating-an-aisession).

{% hint style="info" %}
`modelName` specifies the lowercased name of an available model.
{% endhint %}

{% hint style="info" %}
`lockAmount` specifies the maximum amount of unes (0.000001 NES) to pay during the inference process. This amount is deducted immediately, with any unused portion refunded upon the session closing.
{% endhint %}

***

### 3. AIRequests: Inference Execution

This process takes place over a websocket connection for speedy, streaming interaction.

Construct and send an **`AIRequest`** in order to communicate with your session's designated model. Each model and/or task type may have a unique set of **`modelParams`** to be included with your request and necessary for proper execution. Inspect or use the **`getModelParameterDefaults`** function for insight regarding any required and optional parameters. You may find an example [**`here`**](https://github.com/nesaorg/ai-sdk-ts?tab=readme-ov-file#sending-an-airequest).

***

### Additional Resources

* **Getting Started**: If you’re new to Nesa, check out the [**Getting Started**](https://docs.nesa.ai/nesa/using-nesa/getting-started) guide.
* **Via Web**: Utilize Nesa Chain AI Models using the Web. [**Learn more**](/nesa/using-nesa/via-web.md).
* **Via IBC**: Connect with other blockchains using the Inter-Blockchain Communication protocol. [**Learn more**](https://docs.nesa.ai/nesa/using-nesa/via-ibc).

***

We’re excited to have you explore Nesa via SDK. Enjoy a seamless and intuitive experience as you interact with the network!
