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

# 크레딧 잔액 조회

> 사용자의 현재 크레딧 잔액과 사용 통계를 반환하는 엔드포인트입니다.

## GET /credits/balance

인증된 사용자의 현재 크레딧 잔액과 사용 통계를 반환합니다. 세션 기반 인증(JWT 액세스 토큰)이 필요합니다.

<Note>
  **서드파티 연동:** API 키 인증을 사용할 때는 대신 `GET /credits/balance/api`를 사용하세요.
</Note>

### 응답

<ResponseField name="balance" type="number">
  현재 사용 가능한 크레딧 잔액입니다.
</ResponseField>

<ResponseField name="totalPurchased" type="number">
  계정 전체 기간 동안 구매한 크레딧 합계입니다.
</ResponseField>

<ResponseField name="totalUsed" type="number">
  계정 전체 기간 동안 사용한 크레딧 합계입니다.
</ResponseField>

<ResponseField name="recentTransactions" type="array">
  최근 크레딧 거래 목록입니다.

  <Expandable title="거래 속성">
    <ResponseField name="id" type="string">
      거래 식별자입니다.
    </ResponseField>

    <ResponseField name="type" type="string">
      거래 유형: `purchase`, `usage`, 또는 `refund`입니다.
    </ResponseField>

    <ResponseField name="amount" type="number">
      크레딧 금액(구매는 양수, 사용은 음수)입니다.
    </ResponseField>

    <ResponseField name="description" type="string">
      사람이 읽을 수 있는 설명입니다.
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      거래 시각(ISO 8601)입니다.
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET https://api.llmgenerator.com/api/v1/credits/balance \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.llmgenerator.com/api/v1/credits/balance', {
    headers: {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
    }
  });

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://api.llmgenerator.com/api/v1/credits/balance',
      headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'}
  )

  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json Success (200) theme={null}
  {
    "balance": 450,
    "totalPurchased": 1000,
    "totalUsed": 550,
    "recentTransactions": [
      {
        "id": "txn_abc123",
        "type": "purchase",
        "amount": 500,
        "description": "Purchased Pro Pack",
        "createdAt": "2026-01-15T10:00:00Z"
      },
      {
        "id": "txn_def456",
        "type": "usage",
        "amount": -50,
        "description": "API LLMs.txt generation (enhanced) for example.com (25 URLs)",
        "createdAt": "2026-01-20T14:30:00Z"
      }
    ]
  }
  ```

  ```json Unauthorized (401) theme={null}
  {
    "message": "Unauthorized"
  }
  ```
</ResponseExample>

***

## GET /credits/balance/api

API 키 인증으로 사용자의 현재 크레딧 잔액을 반환합니다. 외부 애플리케이션 연동에 적합합니다.

### 인증

API 키 인증이 필요합니다. `Authorization` 헤더에 API 키를 넣습니다:

```
Authorization: Bearer llmgen_your_api_key_here
```

### 응답

`/credits/balance`와 동일합니다.

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET https://api.llmgenerator.com/api/v1/credits/balance/api \
    -H "Authorization: Bearer llmgen_your_api_key_here"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.llmgenerator.com/api/v1/credits/balance/api', {
    headers: {
      'Authorization': 'Bearer llmgen_your_api_key_here'
    }
  });

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://api.llmgenerator.com/api/v1/credits/balance/api',
      headers={'Authorization': 'Bearer llmgen_your_api_key_here'}
  )

  data = response.json()
  ```
</RequestExample>
