# Pi

A task-oriented walkthrough for working with Pi in beams.



**Install the client tools and sign in**

Beams is a [Teleport](https://goteleport.com) project and uses [official Teleport client tools](https://goteleport.com/download/client-tools/).

The client tools include `tsh` to sign in and run commands, and `tctl` to administer your cluster if you have permission.



Cluster: `example.beams.run`. Edit this example to use your cluster name.

Install version **18.11.10** of the client:

**macOS**

Download and open the macOS installer, then follow its instructions.

```sh
curl -O https://cdn.teleport.dev/teleport-tools-18.11.10.pkg
open teleport-tools-18.11.10.pkg
```

**Linux**

For Linux x86-64, download and install the client tools:

```sh
curl -O https://cdn.teleport.dev/teleport-v18.11.10-linux-amd64-bin.tar.gz
tar -xzf teleport-v18.11.10-linux-amd64-bin.tar.gz
sudo ./teleport/install
```

**Windows**

For Windows x86-64, run these commands in PowerShell. Add the extraction directory (`$env:LOCALAPPDATA\Teleport`) to your user PATH to use `tsh` in future terminals; the last command adds it to this terminal's PATH.

```powershell
Invoke-WebRequest -Uri https://cdn.teleport.dev/teleport-v18.11.10-windows-amd64-bin.zip -OutFile teleport.zip
Expand-Archive -Path teleport.zip -DestinationPath "$env:LOCALAPPDATA\Teleport" -Force
$env:Path += ";$env:LOCALAPPDATA\Teleport"
```

Follow the official client [tools install guide](https://goteleport.com/download/client-tools/) for other versions and architectures.

Check that you’re running v18.11.10 of the client with `tsh version`.

```sh
tsh version
```

**Passwordless**

I sign in without a password (e.g. a passkey).

```sh
tsh login --proxy='example.beams.run' --auth=passwordless
```

**Password \& MFA**

I have a password & MFA set up for my account:

Replace `you@example.com` with your Teleport username.

```sh
tsh login --proxy='example.beams.run' --user=you@example.com
```

**SSO**

I sign in with SSO (e.g. Okta, GitHub, SAML).

```sh
tsh login --proxy='example.beams.run'
```


Start a beam - a micro-VM. This beam starts with a pre-packaged and auto-updating Pi connected to an LLM inference endpoint:

**Local terminal**

```sh
tsh beams add
```

Start Pi in a managed session:

**Inside the beam**

```sh
# start pi in a background, and attach to it:
beamctl start --pty -- pi
# to detach, press Ctrl-Z, to reattach back use beamctl list and beamctl attach
```

**Why not just run pi directly?**

You can do this too, but the command above started pi in background, allocated terminal and attached to it.
You can detach by typing `Ctrl-Z`, or close the tab, and reattach later:

**Local terminal**

```sh
tsh beams ssh <beam-name>
```

Find the Pi service ID, then reattach to it:

**Inside the beam**

```sh
beamctl list
beamctl attach <service-id>
```

You may need to recover your terminal if you got disconnected, some coding harnesses break it:

**Inside the beam**

```sh
stty sane
reset
```

### Choosing a model

Teleport Beams offers several built-in models, once in pi harness, try this:

**Pi session**

```text
/models
```

## Connect Pi to GitHub

Your agent uses GitHub through Teleport, so you never put a personal access token or SSH key in the beam. Teleport authorizes each `git` and `tsh gh` call and logs it in the audit log.

### 1. Connect your GitHub organization

Skip this step if `tsh git ls` already lists your organization. Otherwise, a Teleport admin with the `editor` role runs the following on a workstation with a browser, while signed in to GitHub as an owner of the organization. Replace `my-org` with your organization:

**Admin terminal**

```sh
tctl integrations github add --org=my-org --dry-run
tctl integrations github add --org=my-org
```

The dry run prints the plan without making changes. The second command creates the Teleport integration, opens your browser to create a GitHub App, and saves the app's credentials in Teleport. Install the app on **Only select repositories**, and choose the repositories your agent may work on. The agent can't reach any other repository. If the app name, which defaults to your cluster name, is taken on GitHub, add `--app-name=my-org-teleport`.

The command doesn't grant anyone access. Save this role as `github-my-org.yaml`:

```yaml
kind: role
version: v8
metadata:
  name: github-my-org
spec:
  allow:
    github_permissions:
      - orgs: [my-org]
```

Create the role, and assign it to the people who run agents in beams through your usual role mapping:

**Admin terminal**

```sh
tctl create -f github-my-org.yaml
```

### 2. Authorize GitHub and start the beam

Sign in to GitHub through Teleport once from your workstation. This links your GitHub account to your Teleport user:

**Local terminal**

```sh
tsh git ls
tsh git login --github-org=my-org
```

`tsh beams add` shares this connected account with new beams by default. The agent then acts as your GitHub user, limited by both your GitHub permissions and the repositories you installed the app on. If you pass `--roles`, include `github-my-org`, or the beam can't see the organization:

**Local terminal**

```sh
tsh beams add --roles=beam-user,github-my-org
```

Don't pass `--no-share-connected-accounts`: that flag starts the beam without your GitHub authorization.

### 3. Check access from the beam

Inside the beam, confirm that the organization is listed and which GitHub account Teleport uses:

**Inside the beam**

```sh
tsh git ls
tsh gh --github-org=my-org -- api /user --jq .login
```

If `tsh gh` prints an authorization URL, open it on your workstation, finish signing in, and retry.

### Ask Pi to work on a repository

You don't need to configure Pi. Each beam has `~/AGENTS.md`, which tells agents to clone with `tsh git clone` and to use `tsh gh --` in place of `gh`. Pi loads it when you start Pi in your home directory or below. Start Pi and give it a task:

**Pi session**

```text
Clone https://github.com/my-org/my-repo, fix the typo in README.md on a new
branch, push it, and open a pull request.
```

The agent works with ordinary Git commands and `tsh gh`. Beams don't set a Git author, so ask the agent to set `git config user.name` and `user.email` in the checkout first, or include them in your prompt. A typical run looks like this:

**Inside the beam**

```sh
tsh git clone https://github.com/my-org/my-repo.git
cd my-repo
git switch -c fix-readme-typo
git commit -am 'Fix README typo'
git push -u origin HEAD
tsh gh --github-org=my-org -- pr create -R my-org/my-repo --fill
```

`tsh git clone` sets the remote to a `teleport://` URL, so plain `git fetch` and `git push` keep going through Teleport. For a checkout that already exists in the beam, tell the agent to run `tsh git config update` in it first. The agent can't bypass branch protection or repository rules, so you still review and merge its pull requests.

See [GitHub](/docs/connectivity/github/) for SSH-only organizations, troubleshooting and audit events.

## What's next?

Further reading: [Snapshots](/docs/phases/snapshots/) and [Forks](/docs/phases/forks/).

