OpenAI Chat Model 节点#
¥OpenAI Chat Model node
使用 OpenAI 聊天模型节点,将 OpenAI 的聊天模型与对话式 agents 结合使用。
¥Use the OpenAI Chat Model node to use OpenAI's chat models with conversational agents.
本页提供 OpenAI 聊天模型节点的节点参数以及更多资源的链接。
¥On this page, you'll find the node parameters for the OpenAI Chat Model node and links to more resources.
Parameter resolution in sub-nodes
Sub-nodes behave differently to other nodes when processing multiple items using an expression.
Most nodes, including root nodes, take any number of items as input, process these items, and output the results. You can use expressions to refer to input items, and the node resolves the expression for each item in turn. For example, given an input of five name values, the expression {{ $json.name }} resolves to each name in turn.
In sub-nodes, the expression always resolves to the first item. For example, given an input of five name values, the expression {{ $json.name }} always resolves to the first name.
节点参数#
¥Node parameters
模型#
¥Model
选择用于生成补全的模型。
¥Select the model to use to generate the completion.
n8n 会动态加载来自 OpenAI 的模型,你只会看到你账户可用的模型。
¥n8n dynamically loads models from OpenAI, and you'll only see the models available to your account.
内置工具#
¥Built-in Tools
OpenAI 响应 API 提供了一系列 内置工具 来丰富模型的响应:
¥The OpenAI Responses API provides a range of built-in tools to enrich the model's response:
- Web 搜索:允许模型在生成响应之前搜索网络以获取最新信息。
¥Web Search: Allows models to search the web for the latest information before generating a response.
- MCP 服务器:允许模型连接到远程 MCP 服务器。了解更多关于使用远程 MCP 服务器作为 此处 工具的信息。
¥MCP Servers: Allows models to connect to remote MCP servers. Find out more about using remote MCP servers as tools here.
- 文件搜索:允许模型在生成响应之前,从先前上传的文件中搜索知识库中的相关信息。更多信息,请参阅 OpenAI 文档。
¥File Search: Allow models to search your knowledgebase from previously uploaded files for relevant information before generating a response. Refer to the OpenAI documentation for more information.
- 代码解释器:允许模型在沙盒环境中编写和运行 Python 代码。
¥Code Interpreter: Allows models to write and run Python code in a sandboxed environment.
节点选项#
¥Node options
使用这些选项来进一步细化节点的行为。
¥Use these options to further refine the node's behavior.
Base URL#
在此处输入 URL 以覆盖 API 的默认 URL。
¥Enter a URL here to override the default URL for the API.
频率惩罚#
¥Frequency Penalty
使用此选项可控制模型重复自身的概率。更高的值会降低模型重复的概率。
¥Use this option to control the chances of the model repeating itself. Higher values reduce the chance of the model repeating itself.
最大令牌数#
¥Maximum Number of Tokens
请输入使用的最大令牌数,这将设置完成时长。
¥Enter the maximum number of tokens used, which sets the completion length.
响应格式#
¥Response Format
选择文本或 JSON。JSON 确保模型返回有效的 JSON。
¥Choose Text or JSON. JSON ensures the model returns valid JSON.
在线惩罚#
¥Presence Penalty
使用此选项可控制模型讨论新主题的概率。数值越高,模型讨论新话题的概率越大。
¥Use this option to control the chances of the model talking about new topics. Higher values increase the chance of the model talking about new topics.
采样温度#
¥Sampling Temperature
使用此选项可控制采样过程的随机性。更高的温度会产生更多样化的采样,但会增加出现幻觉的风险。
¥Use this option to control the randomness of the sampling process. A higher temperature creates more diverse sampling, but increases the risk of hallucinations.
超时#
¥Timeout
请输入最大请求时间(以毫秒为单位)。
¥Enter the maximum request time in milliseconds.
最大重试次数#
¥Max Retries
请输入请求重试的最大次数。
¥Enter the maximum number of times to retry a request.
热门问题#
¥Top P
使用此选项可设置完成概率。使用较低的值来忽略可能性较小的选项。
¥Use this option to set the probability the completion should use. Use a lower value to ignore less probable options.
对话 ID#
¥Conversation ID
此回复所属的对话。此响应的输入项和输出项将在此响应完成后自动添加到此对话中。
¥The conversation that this response belongs to. Input items and output items from this response are automatically added to this conversation after this response completes.
提示缓存键#
¥Prompt Cache Key
使用此键缓存类似请求,以优化缓存命中率。
¥Use this key for caching similar requests to optimize cache hit rates.
安全标识符#
¥Safety Identifier
应用标识符来跟踪可能违反使用策略的用户。
¥Apply an identifier to track users who may violate usage policies.
服务层级#
¥Service Tier
选择符合你需求的服务层级:自动、灵活、默认或优先级。
¥Select the service tier that fits your needs: Auto, Flex, Default, or Priority.
元数据#
¥Metadata
一组用于存储结构化信息的键值对。你可以将最多 16 个节点对附加到对象,这对于添加可用于 API 或仪表板搜索的自定义数据非常有用。
¥A set of key-value pairs for storing structured information. You can attach up to 16 pairs to an object, which is useful for adding custom data that can be used for searching by the API or in the dashboard.
热门日志问题#
¥Top Logprobs
定义一个介于 0 和 20 之间的整数,指定在每个标记位置返回的最可能标记的数量,每个标记都关联一个对数概率。
¥Define an integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability.
输出格式#
¥Output Format
选择响应格式:文本、JSON Schema 或 JSON 对象。如果你希望接收 JSON 格式的数据,建议使用 JSON Schema。
¥Choose a response format: Text, JSON Schema, or JSON Object. Use of JSON Schema is recommended, if you want to receive data in JSON format.
提示#
¥Prompt
配置提示信息,使其包含唯一 ID、版本和可替换变量。
¥Configure the prompt filled with a unique ID, its version, and substitutable variables.
推断工作量#
¥Reasoning Effort
控制 AI 结果的推断级别:低、中或高。
¥Control the reasoning level of AI results: Low, Medium, or High.
模板和示例#
¥Templates and examples
相关资源#
¥Related resources
有关服务的更多信息,请参阅 LangChains 的 OpenAI 文档。
¥Refer to LangChains's OpenAI documentation for more information about the service.
有关参数的更多信息,请参阅 OpenAI 文档。
¥Refer to OpenAI documentation for more information about the parameters.
View n8n's Advanced AI documentation.
常见问题#
¥Common issues
有关常见问题或建议的解决方案,请参阅 常见问题。
¥For common questions or issues and suggested solutions, refer to Common issues.