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

> Find CLI guides for authentication, API keys, costs, virtual tags, recommendations, and CI.

Run CostGraph tasks from your terminal or a CI job with the `costgraph` command. Choose a guide to get started.

## Start with a task

Each guide includes examples and a command reference.

> [card] [Install and sign in](https://docs.costgraph.ai/costgraph/cli/install.md)
>
> Install the CLI, sign in, and choose a tenant.

> [card] [API keys](https://docs.costgraph.ai/costgraph/cli/api-keys.md)
>
> Create one key with the scopes your workflow needs.

> [card] [Query costs](https://docs.costgraph.ai/costgraph/cli/query-costs.md)
>
> Compare spend by provider, service, or tag.

> [card] [Virtual tags](https://docs.costgraph.ai/costgraph/cli/virtual-tags.md)
>
> Inspect rules and preview their matches.

> [card] [Recommendations](https://docs.costgraph.ai/costgraph/cli/recommendations.md)
>
> List rightsizing recommendations and total their savings.

> [card] [Terraform and CI estimates](https://docs.costgraph.ai/costgraph/cli/terraform-and-ci.md)
>
> Price plans and post pull request cost comments.

> [card] [Configuration and output](https://docs.costgraph.ai/costgraph/cli/configuration.md)
>
> Choose your deployment, output format, and shell completion.

> [card] [Command reference](https://docs.costgraph.ai/costgraph/cli/reference.md)
>
> Find commands grouped by task.

## Credentials

Choose a saved browser session for terminal use or a scoped API key for scripts.

> [tab] Browser session
>
> Run `costgraph auth login` to save a session for one tenant. Commands act with your role in that tenant. The CLI refreshes the session automatically.
>
> Follow [Install and sign in](https://docs.costgraph.ai/costgraph/cli/install.md) to create a session or switch tenants.

> [tab] API key
>
> An API key belongs to you and one tenant. Its scopes are the permissions you approve for a workflow.
>
> Create one with `costgraph api-keys create` and pass it through `COSTGRAPH_API_KEY`. Key creation needs browser approval and does not change your saved session.
>
> Follow [API keys](https://docs.costgraph.ai/costgraph/cli/api-keys.md) to choose scopes and use the key in CI.

### Saved session precedence

When a saved session exists, the CLI uses it and ignores `COSTGRAPH_API_KEY`. Run `costgraph auth logout` before testing an API key on that machine.

If the session expires and refresh fails, the command asks you to sign in again. It does not fall back to the API key. A CI runner normally has no saved session.

### Commands that require a browser session

These command groups reject API keys in CLI 0.11.0.

| Task | Commands |
| - | - |
| Cost summaries | `cost`, `cost overview`, `cost providers` |
| Recommendations | `recommendations list`, `recommendations summary` |
| Virtual tags | All `tags` commands |

Use `costgraph cost get` for cost queries with an API key. Each task guide lists its credential requirements.

## Tenants

A tenant holds one set of cost data in your organization. Cost queries and virtual tag commands use the tenant attached to your credential.

The `organization:manage` scope permits supported organization management operations across tenants. It does not extend access to their cost data.

Follow [Choose a tenant](https://docs.costgraph.ai/costgraph/cli/install.md#choose-a-tenant) to list tenants and switch your session.

## Configuration and environment

Settings live in `~/.config/costgraph/config.toml` and `COSTGRAPH_*` environment variables. Set `COSTGRAPH_API_URL` for a self-hosted deployment.

See [Configuration and output](https://docs.costgraph.ai/costgraph/cli/configuration.md) for settings and precedence.

## Output formats

Data-query commands print tables by default. Add `-o json` for scripts. See [Choose an output format](https://docs.costgraph.ai/costgraph/cli/configuration.md#choose-an-output-format) for commands with other formats.

Scripts, pipes, and JSON output disable interactive views and prompts. Supply the required arguments and flags.

For `costgraph tags create`, keep `--dry-run` to preview a rule. Without it, noninteractive calls send a write request without confirmation. See [Virtual tags](https://docs.costgraph.ai/costgraph/cli/virtual-tags.md) for the restriction on saving rules.

## Find commands and flags

Each task page ends with a command reference. The [full reference](https://docs.costgraph.ai/costgraph/cli/reference.md) groups every command by task.

Add `--help` to any command for the complete flag list. Help reflects your installed release.

## Command reference

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

### Discovery commands

Run these commands from any directory.

**version** `command`

Prints the installed version, commit, and build time.

**help \[command]** `command`

Prints help for a command. You can also append `--help` to any command.

### Global flags

These flags apply across command groups.

**-o, --output** `string`

Selects `table` or `json` for data commands. Some commands use their own output formats.

**--config** `path`

Selects a configuration file for this command.

**-v, --verbose** `boolean`

Enables debug logging.


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