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

# AIGC文本改写

> 使用AI技术对文本进行智能改写，支持降AI率、降重率等多种改写类型

## 接口说明

AIGC文本改写接口是 Paper Panda 的核心服务，提供基于大语言模型的智能文本改写能力。

### 主要特性

* **多种改写模式：** 支持11种改写类型，满足不同场景需求
* **按字数计费：** 改写成功后自动扣费，失败不收费
* **实时处理：** 同步返回改写结果
* **欠费保护：** 余额不足时创建欠费订单，充值后可查看结果

## 认证方式

<ParamField header="Authorization" type="string" required>
  Bearer Token认证，支持API Key或JWT Token

  ```text theme={null}
  Authorization: Bearer ak_xxxxxxxxxxxxxxxx
  ```
</ParamField>

## 请求参数

<ParamField body="content" type="string" required>
  要改写的文本内容

  * **长度限制：** 50-6,000 字符
  * **编码：** UTF-8
  * **格式：** 纯文本，无需特殊格式

  ```json theme={null}
  "人工智能是研究如何使计算机模拟人类智能的一门科学。它包括机器学习、深度学习等多个领域。"
  ```
</ParamField>

<ParamField body="service_type" type="string" required>
  服务类型，决定改写策略和价格

  | 值                  | 说明      | 适用场景    |
  | ------------------ | ------- | ------- |
  | `ai-reduce-value`  | 降AI-英文版 | 标准降AI服务 |
  | `ai-reduce`        | 降AI-中文版 | 标准降AI服务 |
  | `duplicate-reduce` | 降重      | 专注降低重复率 |
  | `ai-duplicate`     | 降AI+降重  | 双重优化    |
  | `advance`          | 高级咨询    | 定制化改写   |
</ParamField>

<ParamField body="rewrite_type" type="integer" required>
  改写类型ID，决定具体的改写算法

  | ID | 名称         | 说明              |
  | -- | ---------- | --------------- |
  | 1  | 知网降AI      | 适合知网的AI降重/降AI改写 |
  | 2  | 维普降AI      | 适合维普的AI降重/降AI改写 |
  | 3  | 通用降AI      | 通用场景AI降重/降AI改写  |
  | 5  | 通用降重       | 通用场景降重服务        |
  | 6  | 格子达降AI     | 格子达场景降AI改写      |
  | 7  | 双降知网       | 知网场景同时降AI+降重    |
  | 8  | 双降维普       | 维普场景同时降AI+降重    |
  | 9  | 双降通用       | 通用场景同时降AI+降重    |
  | 10 | 双降格子达      | 格子达场景同时降AI+降重   |
  | 11 | 朱雀降AI      | 朱雀平台AI降重/降AI改写  |
  | 12 | 特价降AI      | 特价降AI           |
  | 4  | 降AI-知网-英文版 |                 |
  | 13 | 降AI-维普-英文版 |                 |

  <Tip>
    **推荐选择：** 大多数场景使用 `rewrite_type=1`（标准改写）或 `rewrite_type=3`（通用改写）
  </Tip>
</ParamField>

## 响应参数

<ResponseField name="amount" type="number" required>
  本次消费金额（元）

  ```json theme={null}
  47.58
  ```
</ResponseField>

<ResponseField name="code" type="integer" required>
  响应状态码

  * `200`: 改写成功
  * `500`: 改写失败
</ResponseField>

<ResponseField name="data" type="string" required>
  改写后的文本内容（成功时）或错误提示（失败时）

  ```json theme={null}
  "人工智能技术是专门研究让计算机系统能够模拟和实现人类智慧行为的学科领域。该领域涵盖了机器学习算法、深度神经网络等众多技术分支。"
  ```
</ResponseField>

<ResponseField name="message" type="string" required>
  响应消息

  * 成功: `"改写成功"`
  * 欠费: `"处理完成, 因已欠费, 需充值回正后, 进入右侧「生成记录」页面查看结果!"`
  * 失败: `"处理失败: {错误原因}"`
</ResponseField>

## 请求示例

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://paperpanda.cn/api/v1/aigc/rewrite \
    -H "Authorization: Bearer ak_xxxxxxxxxxxxxxxx" \
    -H "Content-Type: application/json" \
    -d '{
      "content": "人工智能是研究如何使计算机模拟人类智能的一门科学。它包括机器学习、深度学习等多个领域。",
      "service_type": "ai-reduce-value",
      "rewrite_type": 1
    }'
  ```

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

  url = "https://paperpanda.cn/api/v1/aigc/rewrite"
  headers = {
      "Authorization": "Bearer ak_xxxxxxxxxxxxxxxx",
      "Content-Type": "application/json"
  }
  data = {
      "content": "人工智能是研究如何使计算机模拟人类智能的一门科学。它包括机器学习、深度学习等多个领域。",
      "service_type": "ai-reduce-value",
      "rewrite_type": 1
  }

  response = requests.post(url, json=data, headers=headers)
  result = response.json()

  if result["code"] == 200:
      print(f"改写成功！消费: {result['amount']}元")
      print(f"改写结果: {result['data']}")
  else:
      print(f"改写失败: {result['message']}")
  ```

  ```javascript JavaScript theme={null}
  const axios = require('axios');

  const rewriteText = async () => {
    try {
      const response = await axios.post(
        'https://paperpanda.cn/api/v1/aigc/rewrite',
        {
          content: '人工智能是研究如何使计算机模拟人类智能的一门科学。它包括机器学习、深度学习等多个领域。',
          service_type: 'ai-reduce-value',
          rewrite_type: 1
        },
        {
          headers: {
            'Authorization': 'Bearer ak_xxxxxxxxxxxxxxxx',
            'Content-Type': 'application/json'
          }
        }
      );

      const result = response.data;

      if (result.code === 200) {
        console.log(`改写成功！消费: ${result.amount}元`);
        console.log(`改写结果: ${result.data}`);
      } else {
        console.log(`改写失败: ${result.message}`);
      }
    } catch (error) {
      console.error('请求失败:', error.response?.data || error.message);
    }
  };

  rewriteText();
  ```

  ```java Java theme={null}
  import java.net.http.*;
  import java.net.URI;
  import com.google.gson.Gson;

  public class AigcRewrite {
      public static void main(String[] args) throws Exception {
          String apiKey = "ak_xxxxxxxxxxxxxxxx";
          String url = "https://paperpanda.cn/api/v1/aigc/rewrite";

          // 构建请求体
          String requestBody = """
              {
                  "content": "人工智能是研究如何使计算机模拟人类智能的一门科学。",
                  "service_type": "ai-reduce-value",
                  "rewrite_type": 1
              }
          """;

          // 创建HTTP客户端
          HttpClient client = HttpClient.newHttpClient();
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create(url))
              .header("Authorization", "Bearer " + apiKey)
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(requestBody))
              .build();

          // 发送请求
          HttpResponse<String> response = client.send(
              request,
              HttpResponse.BodyHandlers.ofString()
          );

          System.out.println("响应: " + response.body());
      }
  }
  ```
</CodeGroup>

## 响应示例

<ResponseExample>
  ```json 成功响应 theme={null}
  {
    "amount": 47.58,
    "code": 200,
    "data": "人工智能技术是专门研究让计算机系统能够模拟和实现人类智慧行为的学科领域。该领域涵盖了机器学习算法、深度神经网络等众多技术分支。",
    "message": "改写成功"
  }
  ```

  ```json 欠费响应 theme={null}
  {
    "amount": 47.58,
    "code": 200,
    "data": "处理完成, 因已欠费, 需充值回正后, 进入右侧「生成记录」页面查看结果!",
    "message": "处理完成, 因已欠费, 需充值回正后, 进入右侧「生成记录」页面查看结果!"
  }
  ```

  ```json 失败响应 theme={null}
  {
    "amount": 47.58,
    "code": 500,
    "data": "改写失败: AI服务暂时不可用",
    "message": "处理失败: AI服务暂时不可用"
  }
  ```
</ResponseExample>

## 错误码说明

| HTTP状态码 | 说明        | 处理建议             |
| ------- | --------- | ---------------- |
| 400     | 余额不足      | 请先充值             |
| 400     | 参数验证失败    | 检查请求参数           |
| 401     | API Key无效 | 检查密钥是否正确或过期      |
| 429     | 超出QPM限制   | 等待1分钟后重试，或申请提升配额 |
| 500     | AI服务异常    | 稍后重试，或联系技术支持     |

## 计费规则

### 费用计算

改写费用根据以下因素计算：

1. **文本长度：** 按照实际字符数计费（不含换行符）
2. **服务类型：** 不同 `service_type` 价格不同
3. **改写类型：** 不同 `rewrite_type` 可能有差异

### 扣费时机

* ✅ **改写成功：** 自动扣除预估费用
* ❌ **改写失败：** 不扣费，创建失败记录供追溯
* ⚠️ **余额不足：** 创建欠费订单，充值后可查看结果

<Warning>
  **重要提示：** 改写前系统会预估费用并检查余额，确保有足够余额再调用。
</Warning>

## 使用限制

### 并发限制

* 每个用户最多同时处理 **3个** 改写请求
* 超出限制返回 429 错误

### 频率限制

* 默认 QPM（每分钟请求数）：**10次/分钟**
* 可通过"API密钥管理"申请提升配额

### 文本长度

* 最小长度：50 字符
* 最大长度：6,000 字符
* 超出限制返回 422 参数验证错误

## 最佳实践

<AccordionGroup>
  <Accordion title="如何选择合适的改写类型？">
    **场景推荐：**

    * 知网查重：选择 `rewrite_type=1` 或 `rewrite_type=7`
    * 维普查重：选择 `rewrite_type=2` 或 `rewrite_type=8`
    * 通用场景：选择 `rewrite_type=3` 或 `rewrite_type=9`
    * 英文文本：选择 `rewrite_type=4`

    **性价比优先：** 使用 `service_type=ai-reduce-value`
  </Accordion>

  <Accordion title="如何处理大批量改写？">
    **建议方案：**

    1. 将长文本分段（每段不超过5000字符）
    2. 使用队列管理改写任务
    3. 控制并发数（最多3个）
    4. 遵守QPM限制
    5. 实现重试机制（失败后等待重试）
  </Accordion>

  <Accordion title="如何提高改写质量？">
    **优化建议：**

    * 确保原文语句通顺
    * 避免包含大量特殊符号
    * 合理控制文本长度
    * 选择匹配的改写类型
    * 多次改写取最佳结果
  </Accordion>

  <Accordion title="如何避免欠费？">
    **预防措施：**

    1. 调用前先查询余额
    2. 预估费用：`字数/1000 * 单价`
    3. 预留足够余额缓冲
    4. 设置余额预警
    5. 及时充值
  </Accordion>
</AccordionGroup>

## 相关接口

<CardGroup cols={1}>
  <Card title="查询余额" icon="wallet" href="/api-reference/endpoint/balance">
    改写前查询账户余额
  </Card>
</CardGroup>

## 技术支持

遇到问题？我们随时为您提供帮助：

* 📧 邮箱：[support@paperpanda.cn](mailto:support@paperpanda.cn)
* 📚 完整文档：[https://paperpanda.cn/docs](https://paperpanda.cn/docs)
* 💬 在线客服：平台右下角


## OpenAPI

````yaml POST /aigc/rewrite
openapi: 3.1.0
info:
  title: 熊猫论文 API
  description: 熊猫论文·开放API平台 - 提供AIGC文本改写、用户余额查询等核心功能
  version: 1.0.0
  contact:
    name: 熊猫论文·技术支持
    email: support@paperpanda.cn
servers:
  - url: https://paperpanda.cn/api/v1
    description: 生产环境（默认）
security:
  - bearerAuth: []
tags:
  - name: AIGC改写
    description: AI文本智能改写服务，支持降AI率、降重率等多种改写模式
  - name: 用户账户
    description: 用户账户相关接口，包括余额查询、消费记录等
paths:
  /aigc/rewrite:
    post:
      tags:
        - AIGC改写
      summary: AIGC文本改写
      description: 使用AI技术对文本进行智能改写，支持降AI率、降重率等多种改写类型。自动计费，按字数收费。
      operationId: rewriteContent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AIGCRewriteRequest'
            examples:
              standard_rewrite:
                summary: 标准改写示例
                value:
                  content: 人工智能是研究如何使计算机模拟人类智能的一门科学。它包括机器学习、深度学习等多个领域。
                  service_type: ai-reduce-value
                  rewrite_type: 1
              english_rewrite:
                summary: 英文改写示例
                value:
                  content: >-
                    Artificial intelligence is the simulation of human
                    intelligence processes by machines, especially computer
                    systems.
                  service_type: ai-reduce
                  rewrite_type: 4
      responses:
        '200':
          description: 改写成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIGCRewriteResponse'
              examples:
                success:
                  summary: 成功响应
                  value:
                    amount: 47.58
                    code: 200
                    data: >-
                      人工智能技术是专门研究让计算机系统能够模拟和实现人类智慧行为的学科领域。该领域涵盖了机器学习算法、深度神经网络等众多技术分支。
                    message: 改写成功
                unpaid:
                  summary: 欠费响应
                  value:
                    amount: 47.58
                    code: 200
                    data: 处理完成, 因已欠费, 需充值回正后, 进入右侧「生成记录」页面查看结果!
                    message: 处理完成, 因已欠费, 需充值回正后, 进入右侧「生成记录」页面查看结果!
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                detail: '余额不足，当前余额: 10.00元，预估费用: 47.58元'
        '401':
          description: 未授权 - API Key无效或已过期
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                detail: API密钥无效或已过期
        '429':
          description: 请求频率超限
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                detail: 请求过于频繁，已超出QPM限制（10次/分钟）
        '500':
          description: 服务器内部错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIGCRewriteResponse'
              example:
                amount: 47.58
                code: 500
                data: '改写失败: AI服务暂时不可用'
                message: '处理失败: AI服务暂时不可用'
      security:
        - bearerAuth: []
components:
  schemas:
    AIGCRewriteRequest:
      type: object
      required:
        - content
        - service_type
        - rewrite_type
      properties:
        content:
          type: string
          minLength: 1
          maxLength: 20000
          description: 要改写的文本内容，1-20000字符
          example: 人工智能是研究如何使计算机模拟人类智能的一门科学。
        service_type:
          type: string
          enum:
            - ai-reduce-value
            - ai-reduce
            - duplicate-reduce
            - ai-duplicate
            - advance
          description: >-
            服务类型：ai-reduce-value（降AI超值）、ai-reduce（降AI）、duplicate-reduce（降重）、ai-duplicate（降AI+降重）、advance（高级咨询）
          example: ai-reduce-value
        rewrite_type:
          type: integer
          minimum: 1
          maximum: 99
          description: >-
            改写类型ID，1=标准改写，2=维普改写，3=通用改写，4=英文改写，5=通用降重，6=GIZIDA改写，7=双降知网，8=双降维普，9=双降通用，10=双降GIZIDA，11=朱雀改写
          example: 1
    AIGCRewriteResponse:
      type: object
      required:
        - amount
        - code
        - data
        - message
      properties:
        amount:
          type: number
          format: float
          description: 本次消费金额（元）
          example: 47.58
        code:
          type: integer
          description: 响应状态码，200=成功，500=失败
          example: 200
        data:
          type: string
          description: 改写后的文本内容，或错误提示信息
          example: 人工智能技术是专门研究让计算机系统能够模拟和实现人类智慧行为的学科领域。
        message:
          type: string
          description: 响应消息
          example: 改写成功
    ErrorResponse:
      type: object
      required:
        - detail
      properties:
        detail:
          type: string
          description: 错误详情
          example: API密钥无效或已过期
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 使用API Key进行认证，格式：Bearer ak_xxxxxxxxxxxxxxxx

````