---
title: "Installation"
description: "Install ai-cli and configure API access."
canonical_url: "https://ai-cli.dev/docs/installation"
---
# Installation

## Install

```bash
npm install -g ai-cli
```

Or with other package managers:

```bash
pnpm add -g ai-cli
yarn global add ai-cli
```

## API key

ai-cli requires an API key for model access. Set one of the following environment variables:

#### `AI_GATEWAY_API_KEY`

Type: `string`

Vercel AI Gateway key. Provides access to all supported models through a single key.

#### `OPENAI_API_KEY`

Type: `string`

Provider-specific key. Use if you only need OpenAI models.

Get a gateway key from the [Vercel AI Gateway dashboard](https://vercel.com/docs/ai-gateway).

```bash
export AI_GATEWAY_API_KEY="your-key"
```

Add this to your shell profile (`~/.zshrc`, `~/.bashrc`, etc.) to persist across sessions.

## Verify

```bash
ai text "hello"
```

If you see generated text, you're ready.

## Requirements

#### `Node.js`

Type: `22+` | Required

ai-cli runs on Node.js. Install from nodejs.org.

#### `API key`

Type: `string` | Required

A Vercel AI Gateway key or provider-specific key.

## Developing from source

Repository development uses Node.js 24+ and npm. From the repository root:

```bash
npm ci
npm run typecheck
npm test
npm run build
npm run dev --workspace ai-cli -- --help
```
