> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tensorone.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript SDK

> Learn how to set up and use the Tensor One JavaScript SDK to interact with serverless endpoints.

***

# How to Use the Tensor One JavaScript SDK

The **Tensor One JavaScript SDK** allows you to build web applications, automate backend processes, and interact with the **Tensor One API** using Node.js or browser-based environments.

***

## Set Up the SDK

Ensure you have **Node.js** and **npm** or **Yarn** installed.

Install the SDK:

```bash
npm install --save tensorone-sdk
# or
yarn add tensorone-sdk
```

This will add `tensorone-sdk` to your `package.json` dependencies.

***

## Add Your API Key

Import the SDK and initialize it using your **API key** and **endpoint ID**.

**Warning:** Use **environment variables** to store sensitive credentials securely.

### Example (Node.js / ESM)

```js
import tensoroneSdk from 'tensorone-sdk'

const { TENSORONE_API_KEY, ENDPOINT_ID } = process.env

const tensorone = tensoroneSdk(TENSORONE_API_KEY)
const endpoint = tensorone.endpoint(ENDPOINT_ID)
```

This code:

* Imports the SDK
* Initializes the client using your API key
* Prepares a reference to your endpoint

**Note:** The Tensor One SDK is based on **ES Modules** and supports **asynchronous** functions.

***

## Secure Your API Key

Never hardcode your API key in code.

### Best Practice: Use a `.env` file

```dotenv
TENSORONE_API_KEY=your-api-key
ENDPOINT_ID=your-endpoint-id
```

Then load it with [dotenv](https://www.npmjs.com/package/dotenv):

```js
import 'dotenv/config'
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.