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

# Install and sign in to the CostGraph CLI

> Install the costgraph command, sign in through your browser, and choose the tenant your session uses

Install the `costgraph` command, sign in through your browser, and confirm which tenant your commands use. The CLI runs on macOS and Linux.

## Install

Choose one installation method. Homebrew and the install script both install the latest release.

> [tab] Homebrew
>
> ```shell theme={null}
> brew install baselinehq/tap/costgraph
> ```
>
> To update later, run `brew upgrade costgraph`.

> [tab] Script
>
> ```shell theme={null}
> curl -fsSL https://costgraph.ai/cli | sh
> ```
>
> The script downloads the latest release for your platform, checks its checksum, and installs `costgraph` to `/usr/local/bin`. If it can't write to that directory, it installs to `~/.local/bin`. Run the script again to update.

> [tab] Manual
>
> Find the latest version at [setup.costgraph.ai/costgraph-cli/latest](https://setup.costgraph.ai/costgraph-cli/latest). Download the archive for your platform from `https://setup.costgraph.ai/costgraph-cli/<version>/`.
>
> | Platform | Archive |
> | - | - |
> | macOS on Apple silicon and Intel | `costgraph-cli_darwin_all.tar.gz` |
> | Linux x86\_64 | `costgraph-cli_linux_amd64.tar.gz` |
> | Linux arm64 | `costgraph-cli_linux_arm64.tar.gz` |
>
> Check the archive against `checksums.txt` in the same folder. Extract it and put the `costgraph` binary on your `PATH`.

Check the installed version.

```shell theme={null}
costgraph version
```

The output names the version, the commit it was built from, and the build time.

```text theme={null}
costgraph 0.11.0 (commit: ba0bd9b471b2f8ff83700966b1ab440c18d6ee74, built: 2026-11-27T11:24:32Z)
```

If the version is older than the release you installed, another `costgraph` binary comes earlier on your `PATH`. Run `which -a costgraph` to list every copy. Remove the old copy or put the new one first.

## Sign in

Signing in creates a saved session for one tenant. The CLI stores it in `~/.config/costgraph/credentials.toml` and uses it for later commands.

The browser must run on the same machine as the CLI. CostGraph returns to a local callback address, `http://localhost:9093/callback` by default. On a machine without a browser, such as a CI runner, use an [API key](https://docs.costgraph.ai/costgraph/cli/api-keys.md) instead.

**1. Start the sign-in**

```shell theme={null}
costgraph auth login
```

The CLI opens CostGraph in your browser and prints the same address. If the browser doesn't open, copy the address into a browser on the same machine.

**2. Approve the CLI**

Sign in with your usual method, including single sign-on or Google. Choose the tenant for this session and approve the CLI.

To preselect a tenant, add `--tenant` with its name or ID, such as `costgraph auth login --tenant Production`. Without it, CostGraph preselects the tenant that is active in your dashboard.

**3. Confirm the result**

The terminal reports your account, organization, role, and tenant, followed by the session file.

```text theme={null}
Logged in as you@example.com (Example Org, role: admin)
Tenant: Production (2c1f0f7e-5d0a-4a8e-9a43-7b1f3d0c9e21)
Session stored in /Users/you/.config/costgraph/credentials.toml
```

If you passed `--tenant` and chose a different tenant in the browser, the CLI warns that you signed in to another tenant.

If port 9093 is in use, pass another port with `--callback-port`. You can also set `api.callback_port` in the [CLI configuration](https://docs.costgraph.ai/costgraph/cli/configuration.md#supported-settings).

### Check the saved session

The following command reports the saved session.

```shell theme={null}
costgraph auth status
```

The output shows the sign-in method, your account, the API address, the tenant ID, and when the access token expires. `costgraph auth status` reads the saved session file. It doesn't contact CostGraph, so it doesn't prove that the session still works or list the permissions of a credential.

## Choose a tenant

A tenant holds one set of cost data in your organization. Each saved session is bound to one tenant, and every command you run uses that tenant.

List the tenants your account can use.

```shell theme={null}
costgraph tenant list
```

The table marks the session's tenant with `*` and shows each tenant's name and ID.

```text theme={null}
    NAME         ID
 ─────────────────────────────────────────────────────
 *  Production   2c1f0f7e-5d0a-4a8e-9a43-7b1f3d0c9e21
    Staging      8d4b6a10-3e2f-47c5-b0d9-61a7e2f4c835
```

### Switch tenants

Switch the session to another tenant by name or ID. Names match without regard to case.

```shell theme={null}
costgraph tenant use Staging
```

Switching signs you in again with that tenant preselected. If you already approved the CLI for that tenant, the browser returns immediately. Run `costgraph tenant use` without a name to pick from a list in your terminal. Scripts and `-o json` runs must pass the name or ID.

### Use a tenant in Terraform

Use the tenant's name with the `costgraph_tenant` data source. Provider `0.3.0` and later resolves the ID for your resources.

```hcl theme={null}
data "costgraph_tenant" "production" {
  name = "Production"
}
```

Reference `data.costgraph_tenant.production.id` wherever a resource needs `tenant_id`. Names match exactly, including capitalization.

## Sign out

Signing out deletes the saved session file on this machine. It doesn't revoke the session in CostGraph.

```shell theme={null}
costgraph auth logout
```

The CLI prefers a saved session over an API key. Sign out before you run commands with an API key on the same machine. Refer to [Credentials](https://docs.costgraph.ai/costgraph/cli/overview.md#credentials) for how the CLI chooses one.

## Use the CLI in CI

A CI job can't complete the browser sign-in. Give the job an API key that you created and approved earlier, and expose it as `COSTGRAPH_API_KEY`. Refer to [Use the key in a script or CI](https://docs.costgraph.ai/costgraph/cli/api-keys.md#use-the-key-in-a-script-or-ci).

In GitHub Actions, the [CostGraph actions](https://docs.costgraph.ai/costgraph/integrations/github.md#show-ci-cost-on-pull-requests) install the CLI for you.

## CLI integration guides

The following guides run the CLI in pull request checks:

* [CI cost on pull requests](https://docs.costgraph.ai/costgraph/integrations/github.md#show-ci-cost-on-pull-requests)
* [Terraform cost on pull requests](https://docs.costgraph.ai/costgraph/integrations/infracost.md)

## Command reference

Commands are shown without the `costgraph` prefix. Add `--help` for the complete flag list.

### Authentication commands

Run each command with the `costgraph` prefix.

**auth login** `command`

Opens browser sign-in and saves a session for one tenant.

**auth status** `command`

Reports the configured credential without contacting CostGraph. It does not verify scopes or access.

**auth logout** `command`

Deletes the saved session file. It does not revoke the session in CostGraph.

### Tenant commands

Choose which tenant your saved session uses.

**tenant list** `command`

Lists accessible tenant names and UUIDs. Accepts a session or an API key. Alias `tenant ls`.

**tenant use \[name-or-id]** `command`

Signs in again with that tenant preselected. Without an argument, opens a terminal picker.

### Sign-in flags

Pass these flags to `costgraph auth login`.

**--tenant** `string`

Preselects a tenant by name or UUID.

**--callback-port** `integer`

Sets the local browser callback port. Pass a nonzero port to override the default.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.