> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/artificial-intelligence/chatgpt.md).

# ChatGPT

Chat GPT 是一个内置的操作，使您的脚本能够通过 API 协议直接与 OpenAI 的大型语言模型进行通信。这个操作使得 Automation 脚本变得智能，能够自动处理自然语言、翻译、文本摘要、信息提取，或在运行流中自动创作内容。

#### 步骤 1：在 OpenAI 注册账户并购买积分（API）

与 ChatGPT Plus 账户（每月 $20 的付费计划，用于网页界面）不同，使用 API 的账户采用预付费机制，按需付费（Pay-as-you-go）。

1. 注册账户：您可以访问 OpenAI 的开发者页面 [https://platform.openai.com](https://platform.openai.com/) 并进行账户注册（通过电子邮件或直接与 Google 账户链接）。
2. 充值购买 API：
   * 在管理界面中，找到设置 ➔ 账单。
   * 点击添加积分（Add credits）或设置支付（Set up payment）以链接您的国际支付卡（Visa/Mastercard）。
   * 向账户充值一个小额的最低金额（通常为 $5）。这笔金额将根据您的脚本发送和接收的文本字符（Token）逐渐扣除。

#### 步骤 2：初始化并获取 API 密钥（GPT API）

API 密钥充当安全钥匙，帮助 GPM Automate 连接并使用您刚刚充值的金额来调用 AI 处理工作。

1. 在 OpenAI 平台的左侧菜单栏中，访问 API 密钥（API Keys）部分。
2. 点击创建新密钥（Create new secret key）。
3. 为这个密钥命名一个容易记住的名称（例如：`GPM_Automate_Key`）。
4. 系统将显示一个以 `sk-...` 开头的长字符串。

   > ⚠️ 注意：请立即复制并将此密钥保存到一个安全的文件中，因为 OpenAI 只会显示此串一次。如果丢失，您将需要创建一个新的密钥。

#### 步骤 3：获取准确的模型名称（GPT Model）

OpenAI 提供了许多不同代的 AI，具有不同的速度、成本和智能水平。为了准确填写 GPM Automate 中的模型名称：

访问 OpenAI 平台上的模型（Models）部分以查看列表：<https://developers.openai.com/api/docs/models/all>。或者快速查看以下最常用模型的列表：

| **模型名称（填写到 GPM）** | **特点与推荐使用**                                    |
| ----------------- | ---------------------------------------------- |
| gpt-4o-mini       | 新一代模型，响应速度超快，token 成本极低，最优化于常规的 Automation 任务。 |
| gpt-4o            | 目前最智能的模型，出色处理数学逻辑、编程或深度内容创作，但成本较高。             |
| gpt-3.5-turbo     | 传统模型，智能水平基本，能够良好处理翻译或简单文本清理任务。                 |

#### 配置参数解释：

* GPT API：填写从您的 OpenAI 账户管理页面生成的密钥（Secret Key API）（字符串通常以 `sk-...` 开头）。
* GPT Model：填写您希望使用的人工智能模型的标识符名称，例如：`gpt-3.5-turbo`、`gpt-3.5-turbo-0125`、`gpt-4o`...
* Prompt：填写您希望 ChatGPT 处理和回答的问题、上下文或详细要求。您可以将从浏览器中抓取的数据变量嵌入到此框中，以供 AI 分析。
* Output variable：保存 ChatGPT 响应的整个文本字符串的变量名称。

#### 实际示例：自动翻译和重写文章标题（Rewrite Title）以避免版权问题

当您进行市场营销、POD 或在国际市场（例如德国市场）上创建内容时，您需要从英文电子商务网站抓取产品标题，然后翻译成德语并稍作重写，以便在自己的商店中发布，以优化 SEO 并避免内容重复。

* 配置方法：
  * 假设您已经抓取了原始英文标题并将其保存到变量 `$originTitle` 中。
  * 在脚本中调用 Chat GPT 操作。
  * GPT API：`sk-proj-xxxxxxxxxxxxxxxxxxxx`
  * GPT Model：`gpt-3.5-turbo`
  * Prompt：您填写指示 AI 的内容：

    ```
    请将以下产品标题翻译成德语，并自然、简洁、吸引人地重写，以便进行市场营销。原始标题：“$originTitle”。仅返回翻译和重写后的结果字符串，不添加任何引导或解释。
    ```
  * Output variable：将输出变量命名为 `aiContent`。

结果：系统将把变量 `$originTitle` 中的标题推送到 ChatGPT 进行处理。AI 将迅速翻译并优化语言为德语，然后将结果文本直接加载到变量 `$aiContent` 中。在接下来的步骤中，您只需调用这个变量 `$aiContent` 来自动填充到您网站的输入框中，从而实现跨境内容制作的高度自动化。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/artificial-intelligence/chatgpt.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
