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

# 구성

> CometAPI CLI를 구성합니다: config 파일 위치, 사용 가능한 설정, 자격 증명 관리, 환경 변수, 보안 관행.

CometAPI CLI는 TOML config 파일, 환경 변수, 명령줄 플래그에서 설정을 읽습니다. 동일한 설정을 여러 소스에서 사용할 수 있는 경우 우선순위는 다음과 같습니다:

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

## Config 파일

위치: `~/.config/cometapi/config.toml`

대화형으로 config 파일을 생성하려면 설정 마법사를 실행하세요:

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

또는 `config` 하위 명령으로 개별 설정을 관리할 수 있습니다:

```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
```

## 사용 가능한 설정

| Config key      | Environment variable     | Description                                             |
| --------------- | ------------------------ | ------------------------------------------------------- |
| `api_key`       | `COMETAPI_KEY`           | API 키(모든 명령에 필요)                                        |
| `access_token`  | `COMETAPI_ACCESS_TOKEN`  | 계정 수준 명령용 액세스 토큰                                        |
| `base_url`      | `COMETAPI_BASE_URL`      | API 기본 URL(기본값: `https://api.cometapi.com/v1`)          |
| `default_model` | `COMETAPI_DEFAULT_MODEL` | `chat` 및 `run`의 기본 model(대체값: `gpt-5.4`)                |
| `output_format` | —                        | 기본 출력 형식: `table`, `json`, `yaml`, `csv`, 또는 `markdown` |

## 자격 증명

CLI는 두 가지 유형의 자격 증명을 사용합니다:

### API 키

모든 명령에 필요합니다. API 키는 CometAPI model 엔드포인트로 보내는 요청을 인증합니다.

[CometAPI Console → API Keys](https://www.cometapi.com/console/token)에서 API 키를 생성하세요.

다음 방법 중 하나로 설정합니다:

<CodeGroup>
  ```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
  ```
</CodeGroup>

### 액세스 토큰

선택 사항입니다. 액세스 토큰은 계정 수준 명령인 `account`, `stats`, `tokens`, `logs`, `tasks`에 필요합니다.

[CometAPI Console → Personal Settings](https://www.cometapi.com/console/personal)에서 액세스 토큰을 생성하세요.

다음 방법 중 하나로 설정합니다:

<CodeGroup>
  ```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
  ```
</CodeGroup>

## 보안

CLI는 다음 보안 관행을 적용합니다:

* API 키와 액세스 토큰은 전체가 로그에 기록되거나 표시되지 않습니다. 진단 출력에는 마지막 4자만 표시됩니다.
* config 파일은 제한적인 권한(`0600`)으로 생성되며, 파일 소유자만 읽을 수 있습니다.
* 자격 증명은 버전 관리에 커밋하면 안 됩니다. 해당되는 경우 config 파일 경로를 `.gitignore`에 추가하세요.

<Warning>
  API 키로 인해 발생하는 모든 사용량과 요금에 대한 책임은 사용자에게 있습니다. 키를 안전하게 보관하고, 무단 접근이 의심되면 교체하세요.
</Warning>

## 문제 해결

| Error                         | Solution                                                                        |
| ----------------------------- | ------------------------------------------------------------------------------- |
| `API key not configured`      | `cometapi init`를 실행하거나 `COMETAPI_KEY` 환경 변수를 설정하세요                              |
| `Connection failed`           | 연결 문제를 진단하려면 `cometapi doctor`를 실행하세요                                           |
| `Access token not configured` | `account`/`stats`/`tokens`/`logs`/`tasks`에만 필요합니다. 추가하려면 `cometapi init`를 실행하세요 |
