Skip to main content
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.

Install and sign in

Install the CLI, sign in, and choose a tenant.

API keys

Create one key with the scopes your workflow needs.

Query costs

Compare spend by provider, service, or tag.

Virtual tags

Inspect rules and preview their matches.

Recommendations

List rightsizing recommendations and total their savings.

Terraform and CI estimates

Price plans and post pull request cost comments.

Configuration and output

Choose your deployment, output format, and shell completion.

Command reference

Find commands grouped by task.

Credentials

Choose a saved browser session for terminal use or a scoped API key for scripts.
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 to create a session or switch tenants.

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. 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 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 for settings and precedence.

Output formats

Data-query commands print tables by default. Add -o json for scripts. See 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 for the restriction on saving rules.

Find commands and flags

Each task page ends with a command reference. The full reference 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.
command
Prints the installed version, commit, and build time.
command
Prints help for a command. You can also append --help to any command.

Global flags

These flags apply across command groups.
string
Selects table or json for data commands. Some commands use their own output formats.
path
Selects a configuration file for this command.
boolean
Enables debug logging.