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

# Pi Coding Agent

> Methods for Using the GLM Coding Plan in Pi Coding Agent

Pi Coding Agent is a minimalist terminal coding harness with a small core that can be extended via TypeScript extensions, Skills, prompt templates, themes, and Pi Packages. It handles code generation, debugging, project analysis, file operations, and more directly from the command line.

<Tip>
  To use the latest GLM models, run `/model` in Pi Coding Agent and select the corresponding model code.
</Tip>

## Step 1: Installing Pi Coding Agent

The easiest way to install Pi Coding Agent is with the official install script:

```bash theme={null}
curl -fsSL https://pi.dev/install.sh | sh
```

You can also install it with npm:

```bash theme={null}
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
```

`--ignore-scripts` disables lifecycle scripts during dependency installation. Pi Coding Agent's normal npm installation does not require install scripts.

## Step 2: Connect to GLM Coding Plan

### 1. Obtain Your Z.AI API Key

Visit Z.AI to get your [API Key](https://z.ai/manage-apikey/apikey-list).

### 2. Launch and Configure Pi Coding Agent

Navigate to your project directory, launch Pi Coding Agent, and run `/login zai`:

```bash theme={null}
$ cd /path/to/your/project
$ pi
```

In the Pi Coding Agent interactive interface, run:

```
/login zai
```

Enter the API key you obtained from Z.AI in the Pi Coding Agent interactive interface:

```
Login to Z.AI

Enter Z.AI API key
>
 (escape/ctrl+c to cancel, enter to submit)
```

After a successful login, your credentials are saved in `~/.pi/agent/auth.json`.

Use the `/model` command in the Pi Coding Agent interactive interface to select the GLM model you want to use.

### 3. Alternative Configuration

> If you prefer not to log in interactively via `/login`, you can also connect using an environment variable or a custom model configuration file.

Set the environment variable before launching Pi Coding Agent:

```bash theme={null}
export ZAI_API_KEY=your_api_key_here
pi
```

## Resources

* **Pi Coding Agent Documentation**: [pi.dev/docs/latest](https://pi.dev/docs/latest)
* **Pi Coding Agent GitHub**: [earendil-works/pi](https://github.com/earendil-works/pi/tree/main/packages/coding-agent)
* **Custom Model Configuration**: [pi.dev/docs/latest/models](https://pi.dev/docs/latest/models)
* **Provider Configuration**: [pi.dev/docs/latest/providers](https://pi.dev/docs/latest/providers)
