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

# Getting Started

> Official Node.js SDK for the Uplift AI API

<Note>
  Requires **Node.js 18+**. Install from [npm](https://www.npmjs.com/package/@upliftai/sdk-js).
</Note>

## Installation

```bash theme={null}
npm install @upliftai/sdk-js
```

## Configuration

```typescript theme={null}
import UpliftAI from '@upliftai/sdk-js';

const client = new UpliftAI({
  apiKey: 'your-api-key',
});
```

Or use an environment variable:

```bash theme={null}
export UPLIFTAI_API_KEY=sk_...
```

```typescript theme={null}
const client = new UpliftAI(); // picks up from env
```

### Client Options

| Option       | Type     | Default                    | Description                    |
| ------------ | -------- | -------------------------- | ------------------------------ |
| `apiKey`     | `string` | `UPLIFTAI_API_KEY` env     | Your API key                   |
| `baseUrl`    | `string` | `https://api.upliftai.org` | API base URL                   |
| `timeout`    | `number` | `30000`                    | Request timeout (ms)           |
| `maxRetries` | `number` | `2`                        | Auto-retries on 429/5xx errors |

## Quick Example

```typescript theme={null}
import UpliftAI from '@upliftai/sdk-js';
import { writeFileSync } from 'fs';

const client = new UpliftAI({
  apiKey: 'your-api-key',
});

const { audio, metadata } = await client.tts.create({
  text: 'السلام علیکم، یہ ایک ٹیسٹ ہے',
  voiceId: 'v_meklc281',
  outputFormat: 'MP3_22050_128',
});

writeFileSync('output.mp3', audio);
console.log(`Audio size: ${audio.length} bytes`);
```

## Available Methods

<CardGroup cols={2}>
  <Card title="Text to Speech" icon="volume-high" href="/sdk/nodejs/text-to-speech">
    Generate complete audio buffers
  </Card>

  <Card title="Stream TTS" icon="wave-pulse" href="/sdk/nodejs/text-to-speech-stream">
    HTTP streaming for low-latency playback
  </Card>

  <Card title="Async TTS" icon="clock" href="/sdk/nodejs/text-to-speech-async">
    Background jobs with pre-signed URLs
  </Card>

  <Card title="WebSocket TTS" icon="plug" href="/sdk/nodejs/websocket-tts">
    Real-time multiplexed streaming
  </Card>

  <Card title="Speech to Text" icon="microphone" href="/sdk/nodejs/speech-to-text">
    Transcribe audio files
  </Card>

  <Card title="Phrase Replacements" icon="language" href="/sdk/nodejs/phrase-replacements">
    Control pronunciation of specific words
  </Card>
</CardGroup>

## Output Formats

| Format | Identifier                                        | Use Case                      |
| ------ | ------------------------------------------------- | ----------------------------- |
| WAV    | `WAV_22050_32` · `WAV_22050_16`                   | Highest quality, larger files |
| MP3    | `MP3_22050_128` · `MP3_22050_64` · `MP3_22050_32` | Compressed, good for web      |
| PCM    | `PCM_22050_16`                                    | Raw audio, WebSocket default  |
| ULAW   | `ULAW_8000_8`                                     | Telephony (Twilio, SIP, PSTN) |
