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

# Credit-Saldo abrufen

> Dieser Endpunkt liefert den aktuellen Credit-Saldo und Nutzungsstatistiken.

## GET /credits/balance

Dieser Endpunkt gibt den aktuellen Credit-Saldo und Nutzungsstatistiken des authentifizierten Nutzers zurück. Erfordert Sitzungsauthentifizierung (JWT-Access-Token).

<Note>
  **Für Drittanbieter-Integrationen:** Verwenden Sie stattdessen `GET /credits/balance/api` mit API-Schlüssel-Authentifizierung.
</Note>

### Antwort

<ResponseField name="balance" type="number">
  Aktuell verfügbarer Credit-Saldo.
</ResponseField>

<ResponseField name="totalPurchased" type="number">
  Summe aller jemals gekauften Credits.
</ResponseField>

<ResponseField name="totalUsed" type="number">
  Summe aller jemals verbrauchten Credits.
</ResponseField>

<ResponseField name="recentTransactions" type="array">
  Array der letzten Credit-Transaktionen.

  <Expandable title="Eigenschaften einer transaction">
    <ResponseField name="id" type="string">
      Transaktionskennung.
    </ResponseField>

    <ResponseField name="type" type="string">
      Transaktionstyp: "purchase", "usage" oder "refund".
    </ResponseField>

    <ResponseField name="amount" type="number">
      Credit-Betrag (positiv bei Käufen, negativ bei Verbrauch).
    </ResponseField>

    <ResponseField name="description" type="string">
      Für Menschen lesbare Beschreibung.
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO-8601-Zeitstempel.
    </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 Erfolg (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 Nicht autorisiert (401) theme={null}
  {
    "message": "Unauthorized"
  }
  ```
</ResponseExample>

***

## GET /credits/balance/api

Dieser Endpunkt liefert den aktuellen Credit-Saldo mit API-Schlüssel-Authentifizierung. Geeignet für Drittanbieter-Integrationen und externe Anwendungen.

### Authentifizierung

API-Schlüssel erforderlich. Übergeben Sie ihn im Header `Authorization`:

```
Authorization: Bearer llmgen_your_api_key_here
```

### Antwort

Wie bei `/credits/balance` oben.

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