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

# 获取当前订阅

> 获取当前认证用户的订阅状态与详情。

## 概述

返回用户当前订阅信息，包含套餐、账期与续费日期等。需要基于会话的 JWT 访问令牌。

<Note>
  \*\*第三方集成：\*\*请改用 `GET /subscriptions/current/api` 并以 API Key 鉴权。
</Note>

## 认证

<ParamField header="Authorization" type="string" required>
  JWT 访问令牌。格式：`Bearer YOUR_ACCESS_TOKEN`
</ParamField>

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

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/current', {
    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/subscriptions/current',
      headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'}
  )
  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json Active Subscription theme={null}
  {
    "hasSubscription": true,
    "subscription": {
      "plan": "professional",
      "status": "active",
      "billingCycle": "monthly",
      "currentPeriodStart": "2024-01-15T00:00:00Z",
      "currentPeriodEnd": "2024-02-15T00:00:00Z",
      "cancelAtPeriodEnd": false
    },
    "planDetails": {
      "id": "professional",
      "name": "Professional",
      "monthlyCredits": 3000,
      "price": 12.99,
      "features": [
        "3,000 credits/month",
        "Priority support",
        "Advanced analytics"
      ]
    }
  }
  ```

  ```json No Subscription theme={null}
  {
    "hasSubscription": false,
    "subscription": null,
    "planDetails": null
  }
  ```

  ```json Canceled (Still Active) theme={null}
  {
    "hasSubscription": true,
    "subscription": {
      "plan": "professional",
      "status": "active",
      "billingCycle": "monthly",
      "currentPeriodStart": "2024-01-15T00:00:00Z",
      "currentPeriodEnd": "2024-02-15T00:00:00Z",
      "cancelAtPeriodEnd": true
    },
    "planDetails": {
      "id": "professional",
      "name": "Professional",
      "monthlyCredits": 3000,
      "price": 12.99,
      "features": [...]
    }
  }
  ```
</ResponseExample>

## 响应字段

<ResponseField name="hasSubscription" type="boolean">
  用户是否拥有有效订阅。
</ResponseField>

<ResponseField name="subscription" type="object">
  订阅详情（无订阅时为 null）。

  <Expandable title="字段">
    <ResponseField name="plan" type="string">
      套餐标识（starter、professional、business、agency）。
    </ResponseField>

    <ResponseField name="status" type="string">
      当前状态：`active`、`canceled`、`past_due` 或 `trialing`。
    </ResponseField>

    <ResponseField name="billingCycle" type="string">
      计费周期：`monthly` 或 `yearly`。
    </ResponseField>

    <ResponseField name="currentPeriodStart" type="string">
      当前账期开始日（ISO 8601）。
    </ResponseField>

    <ResponseField name="currentPeriodEnd" type="string">
      当前账期结束日（ISO 8601）。
    </ResponseField>

    <ResponseField name="cancelAtPeriodEnd" type="boolean">
      若为 true，订阅将在 `currentPeriodEnd` 到期结束。
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="planDetails" type="object">
  完整套餐信息（无订阅时为 null）。
</ResponseField>

## 订阅状态

| 状态         | 说明          |
| ---------- | ----------- |
| `active`   | 订阅有效且账务正常   |
| `trialing` | 处于试用期内      |
| `past_due` | 扣款失败，可能即将暂停 |
| `canceled` | 订阅已完全取消     |

## 错误响应

<ResponseField name="401" type="error">
  未授权——令牌无效或缺失。
</ResponseField>

***

## GET /subscriptions/current/api

使用 API Key 返回当前订阅信息，适合第三方集成。

### 认证

需要 API Key，在 `Authorization` 请求头中携带：

```
Authorization: Bearer llmgen_your_api_key_here
```

### 响应

与 `/subscriptions/current` 相同。

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

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/current/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/subscriptions/current/api',
      headers={'Authorization': 'Bearer llmgen_your_api_key_here'}
  )
  data = response.json()
  ```
</RequestExample>
