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

# Configuration

> Configure the CometAPI CLI: config file location, available settings, credential management, environment variables, and security practices.

The CometAPI CLI reads settings from a TOML config file, environment variables, and command-line flags. When the same setting is available from multiple sources, the priority order is:

**CLI flags > config file > environment variables > defaults**

## Config file

Location: `~/.config/cometapi/config.toml`

Run the setup wizard to create the config file interactively:

```bash theme={null}
cometapi init
```

Or manage individual settings with the `config` subcommand:

```bash theme={null}
# View current configuration
cometapi config show

# Set a value
cometapi config set api_key "$COMETAPI_KEY"

# Remove a value
cometapi config unset api_key

# Show the config file path
cometapi config path
```

## Available settings

| Config key | Environment variable | Description |
| - | - | - |
| `api_key` | `COMETAPI_KEY` | API key (required for all commands) |
| `access_token` | `COMETAPI_ACCESS_TOKEN` | Access token for account-level commands |
| `base_url` | `COMETAPI_BASE_URL` | API base URL (default: `https://api.cometapi.com/v1`) |
| `default_model` | `COMETAPI_DEFAULT_MODEL` | Default model for `chat` and `run` (fallback: `gpt-5.4`) |
| `output_format` | — | Default output format: `table`, `json`, `yaml`, `csv`, or `markdown` |

## Credentials

The CLI uses two types of credentials:

### API key

Required for all commands. The API key authenticates requests to the CometAPI model endpoints.

Create an API key at [CometAPI Console → API Keys](https://www.cometapi.com/console/token).

Set it in one of these ways:

```bash Environment variable theme={null}
read -rsp "CometAPI API key: " COMETAPI_KEY
printf '\n'
export COMETAPI_KEY
```

```bash Config file theme={null}
cometapi config set api_key "$COMETAPI_KEY"
```

```bash Setup wizard theme={null}
cometapi init
```

### Access token

Optional. The access token is required for account-level commands: `account`, `stats`, `tokens`, `logs`, and `tasks`.

Generate an access token at [CometAPI Console → Personal Settings](https://www.cometapi.com/console/personal).

Set it in one of these ways:

```bash Environment variable theme={null}
export COMETAPI_ACCESS_TOKEN="your-access-token"
```

```bash Config file theme={null}
cometapi config set access_token your-access-token
```

```bash Setup wizard theme={null}
cometapi init
```

## Security

The CLI applies the following security practices:

* API keys and access tokens are never logged or displayed in full. Only the last 4 characters are shown in diagnostics output.
* The config file is created with restrictive permissions (`0600`) — readable only by the file owner.
* Credentials should never be committed to version control. Add the config file path to your `.gitignore` if applicable.

> [!WARNING]
>
> You are responsible for all usage and charges incurred with your API keys. Keep your keys secure and rotate them if you suspect unauthorized access.

## Troubleshooting

| Error | Solution |
| - | - |
| `API key not configured` | Run `cometapi init` or set the `COMETAPI_KEY` environment variable |
| `Connection failed` | Run `cometapi doctor` to diagnose connectivity |
| `Access token not configured` | Only needed for `account`/`stats`/`tokens`/`logs`/`tasks`. Run `cometapi init` to add one |


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