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

# npm SDK Installation

> Install and configure the Artos npm SDK (@artosai/sdk) for JavaScript and TypeScript applications.

# npm SDK Installation

The Artos npm SDK (`@artosai/sdk`) provides a lightweight JavaScript/TypeScript client for integrating Artos functionality into your application.

## Prerequisites

Before you begin, ensure you have:

* **Node.js** version 16.0.0 or higher
* **npm** or **yarn** package manager
* An **Artos API access token** (provided by your Artos account manager)
* A **GitHub Packages access token** (provided by Artos for SDK installation)

## Step 1: Configure npm to use GitHub Packages

Create or update your project's `.npmrc` file in the root of your project:

```bash theme={null}
touch .npmrc
```

Add the following lines to `.npmrc`:

```
@artosai:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PACKAGES_TOKEN
```

<Note>Replace `YOUR_GITHUB_PACKAGES_TOKEN` with the token provided by Artos.</Note>

**Using environment variables (recommended for CI/CD and security):**

```
@artosai:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_TOKEN}
```

Then set the environment variable before installing:

```bash theme={null}
export GITHUB_PACKAGES_TOKEN=your_token_here
```

<Warning>Do not use `npm login` with GitHub Packages - it is not supported. Always use the `.npmrc` file method.</Warning>

## Step 2: Install the SDK

```bash theme={null}
npm install @artosai/sdk
```

Or with yarn:

```bash theme={null}
yarn add @artosai/sdk
```

## Verify Installation

```javascript theme={null}
import { getTemplateUrl } from '@artosai/sdk'
console.log('Artos SDK installed successfully!')
```

## Quick Start

Here's a minimal example to get you started:

```javascript theme={null}
import { getTemplateUrl } from '@artosai/sdk'

async function main() {
    const result = await getTemplateUrl({
        documentId: 'your-document-id',
        accessToken: process.env.ARTOS_ACCESS_TOKEN,
        baseUrl: 'https://api.artosai.com'
    })

    console.log('Template URL:', result.templateUrl)
    console.log('Template ID:', result.templateId)
    console.log('Document Name:', result.documentName)
}

main().catch(console.error)
```

## Troubleshooting

### "Cannot find module '@artosai/sdk'"

**Cause:** The package is not installed or npm is not configured correctly.

**Solution:**

1. Verify your `.npmrc` file is in the project root
2. Check that the GitHub Packages token is correct
3. Run `npm install @artosai/sdk` again

### Network Timeouts

**Cause:** Network connectivity issues or server unavailability.

**Solution:**

1. Check your internet connection
2. Verify the API base URL is correct (must include `https://`)
3. Implement retry logic for transient failures (see [Error Handling](/sdk-reference/npm-error-handling))
