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

# TypeScript SDK Installation

> How to install and set up the AI Stats TypeScript SDK

<Note type="warning">
  **SDKs are in very early alpha**: We're working as hard as we can to get them into a stable state. Please bear with us as we iterate rapidly.
</Note>

## Installation

Install the SDK using your preferred package manager:

<CodeGroup>
  ```bash title="npm" theme={null}
  npm install @ai-stats/sdk
  ```

  ```bash title="pnpm" theme={null}
  pnpm add @ai-stats/sdk
  ```

  ```bash title="yarn" theme={null}
  yarn add @ai-stats/sdk
  ```
</CodeGroup>

## Requirements

* Node.js 18+
* TypeScript 4.5+ (for type definitions)

## Setup

### API Key

You'll need an AI Stats API key to use the SDK. Get one from [Gateway Keys](https://ai-stats.phaseo.app/gateway/keys).

### Environment Variables

Set your API key as an environment variable:

```bash theme={null}
export AI_STATS_API_KEY="aistats_v1_sk_<kid>_<secret>"
```

### Basic Usage

```typescript theme={null}
import AIStats from "@ai-stats/sdk";

// Initialize the client
const client = new AIStats({
	apiKey: process.env.AI_STATS_API_KEY!,
});

// Make your first request
const response = await client.generateText({
	model: "openai/gpt-4o-mini",
	messages: [{ role: "user", content: "Hello!" }],
});

console.log(response.choices[0].message.content);
```

## Next Steps

* Check out the [Usage Guide](./usage.mdx) for detailed examples
* View the [API Reference](../../api-reference/introduction.mdx) for endpoint documentation
