---
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
bun add -g ai-cli
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

#### `Bun`

Type: `1.0+` | Required

ai-cli runs with Bun. Install from bun.sh.

#### `API key`

Type: `string` | Required

A Vercel AI Gateway key or provider-specific key.
