---
title: "Set Up the Y2 Command Line"
description: "Install the native harness and run your first Agent Y2 prompt"
canonical: https://y2.dev/docs/sdks/cli/
---

# Set Up the Y2 Command Line

Install the native harness and run your first Agent Y2 prompt

Use Y2 Information Dominance for interactive agent work and single prompts. For direct API requests, use the [curl recipes](https://y2.dev/docs/sdks/curl).

You need macOS or Linux on x86-64 or arm64. Agent Y2 requires an API key with `agent:y2`.

## Install the native harness

The installer verifies the release checksum and installs `y2` in `~/.y2/bin`.

macOS binaries have SHA-256 checksums. They are not Developer ID signed or Apple notarized.

Terminal

```
export PATH="$HOME/.y2/bin:$PATH" && curl -fsSL https://y2.dev/harness/install.sh | sh
```

The command adds `y2` to this terminal and your shell profile. Pass `--no-modify-path` to leave shell profiles unchanged. Check the installed version:

Terminal

```
export PATH="$HOME/.y2/bin:$PATH"
y2 --version
```

Pin an exact release when you need a reproducible install:

Terminal

```
export PATH="$HOME/.y2/bin:$PATH" && curl -fsSL https://y2.dev/harness/install.sh | sh -s -- v0.0.7
```

Upgrade an installed harness on the stable channel:

Terminal

```
y2 upgrade
```

## Save a Y2 API key

[Create a key](https://y2.dev/docs/api/create-key) with `agent:y2`. Run `y2 auth` to open API Keys in your browser and enter the key at the prompt:

Terminal

```
y2 auth
```

The harness saves the key in local credential storage. Use `y2 setup` to enter an existing key without opening the browser. For temporary shells or CI, set `Y2_API_KEY` in the environment:

Terminal

```
export Y2_API_KEY="y2_..."
```

Keep the key out of shell history, logs, prompts, tool arguments, and browser bundles.

## Run Agent Y2

Start an interactive session from the project you want the harness to use as its workspace:

Terminal

```
cd your-project
y2
```

Run one noninteractive prompt with `y2 ask`:

Terminal

```
y2 ask "Summarize the changes in this repository"
```

The assistant returns a summary in your terminal. Local commands and file changes follow the configured permission policy. The CLI reads applicable `AGENTS.md` files. Local tools run on your machine.

Agent Y2 is the default route. Check the configuration and local requirements without printing the key:

Terminal

```
y2 status --json
y2 doctor
```

## Use another endpoint

Set the provider URL, key, and model:

Terminal

```
export OPENAI_BASE_URL="https://your-provider.example/v1"
export OPENAI_API_KEY="your-provider-api-key"
export Y2_MODEL="your-model-id"
y2
```

`OPENAI_BASE_URL` may include `/chat/completions`. Otherwise, y2 appends it. See the [Agent Y2 API guide](https://y2.dev/docs/api/agent-y2) for the default endpoint and streaming contract.

[curl recipes](https://y2.dev/docs/sdks/curl)

[Agent Y2 API](https://y2.dev/docs/api/agent-y2)

[Harness source](https://github.com/y2-intel/harness)
