> ## 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.

# CostGraph CLI

> Install the costgraph command line tool and sign in

The `costgraph` command line tool queries your costs and runs the CI and Terraform cost comments from a terminal or any CI system. It runs on macOS and Linux.

## Install

<Tabs>
  <Tab title="Homebrew">
    ```shell theme={null}
    brew install baselinehq/tap/costgraph
    ```

    To update later, run `brew upgrade costgraph`.
  </Tab>

  <Tab title="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`, or to `~/.local/bin` if it cannot write there. Run it again to update.
  </Tab>

  <Tab title="Manual">
    Download the archive for your platform from `https://setup.costgraph.ai/costgraph-cli/<version>/`, where `<version>` is the latest release listed at [setup.costgraph.ai/costgraph-cli/latest](https://setup.costgraph.ai/costgraph-cli/latest):

    | Platform | Archive |
    | - | - |
    | macOS (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 it against `checksums.txt` in the same folder, extract it, and put the `costgraph` binary on your `PATH`.
  </Tab>
</Tabs>

Check the install with `costgraph version`.

## Sign in

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

Your browser opens CostGraph. Sign in, pick the tenant to work in, and approve the CLI. `costgraph auth status` shows who you are signed in as and which tenant you are using. To switch tenants, run `costgraph tenant use`.

### In CI

Skip the browser sign-in and use an API key. Create one under **Settings > API keys** with the `focus:read` scope, store it as a secret, and expose it to the job:

```shell theme={null}
export COSTGRAPH_API_KEY=<your API key>
```

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

## Where it is used

* [CI cost on pull requests](/costgraph/integrations/github#show-ci-cost-on-pull-requests)
* [Terraform cost on pull requests](/costgraph/integrations/infracost)

Run `costgraph --help`, or `--help` after any command, for every command and flag.


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