AI Prompt
Prompt an AI model with custom instructions and optional context data via OpenRouter (GPT-4, Claude, Llama, etc.). Supports structured JSON output with schema enforcement via OpenRouter (best with OpenAI models). Pass in data from previous workflow steps as context. Ideal for: AI-driven decisions, data analysis, content generation, automated reasoning in workflows.
目录操作 实用工具
通过 OpenRouter(GPT-4、Claude、Llama 等)使用自定义指令和可选上下文数据提示 AI 模型。支持通过 OpenRouter 强制执行架构的结构化 JSON 输出(OpenAI 模型最佳)。将先前工作流步骤的数据作为上下文传入。理想用于:AI 驱动决策、数据分析、内容生成、工作流中的自动化推理。
概览
| 字段 | 值 |
|---|---|
| 操作 ID | ai-llm-chat |
| 类别 | 实用工具 |
| 连接器 | 不需要 |
| 需要 Gas | 否 |
| 资金移动 | 无声明 |
| 标签 | ai, llm, chat, openrouter, gpt, utility, transform, text |
负载架构
| 字段 | 类型 | 必需 | 描述 |
|---|---|---|---|
prompt | string | 是 | AI 的指令或问题(例如,“基于 ETH 价格数据,我应该买入还是卖出?”) |
context | string | 否 | 与提示一起包含的附加数据或上下文。从先前工作流步骤传入数据(例如,ETH K 线数据、星座文本、钱包余额)。如果传入对象或数组,必须将其字符串化为 JSON。 |
systemPrompt | string | 否 | 系统提示,用于设置 AI 的角色和行为(例如,“您是一位加密货币交易顾问。始终以包含决策和推理的 JSON 对象进行响应。”) |
model | string | 否 | 要使用的 OpenRouter 模型(默认:'openai/gpt-4o-mini') |
temperature | number | 否 | 创造力/随机性(0.0 = 确定性,2.0 = 高度创造性,默认:0.7) |
maxTokens | number | 否 | 响应中的最大令牌数(默认:2048,最大:16384) |
responseFormat | string | 否 | 响应格式。使用 'json_schema' 以生成匹配您的架构的结构化 JSON 输出(在 API 级别强制执行,OpenAI 模型支持最佳)。选择时需要 jsonSchema。默认:'text' |
jsonSchema | string | 否 | 当 responseFormat 为 'json_schema' 时必需。定义 AI 必须遵循的确切 JSON 架构。AI 的输出将结构化为匹配此架构。OpenAI 模型强制执行最佳;其他提供商可能返回错误或忽略架构。所有对象属性必须列在 'required' 中,且 'additionalProperties' 必须为 false(OpenAI 严格模式约束)。示例:'{"type": "object", "properties": {"decision": {"type": "string", "enum": ["buy", "sell", "hold"]}, "confidence": {"type": "number"}, "reasoning": {"type": "string"}}, "required": ["decision", "confidence", "reasoning"], "additionalProperties": false}' |
结果架构
| 字段 | 类型 | 必需 | 描述 |
|---|---|---|---|
output | string | object | 是 | AI 的响应。当 responseFormat 为 'text' 时,此为纯字符串。当 responseFormat 为 'json_schema' 时,此为解析的 JSON 对象,匹配提供的 jsonSchema — 可直接访问字段(例如,output.decision、output.confidence)。 |
model | string | 否 | 使用的模型 |
usage | object | 否 | 来自 OpenRouter 的令牌使用统计 |
示例
json{ "type": "ai-llm-chat", "payload": { "prompt": "example-prompt" }, "children": []}
bashcurl -X POST "https://api.b3os.org/v1/actions/ai-llm-chat/test" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "inputs": { "prompt": "example-prompt" }}'
负载字段可以在值应来自触发器、先前节点或可重用工作流属性时,使用工作流表达式,例如 {{$trigger.body.amount}}、{{$nodes.fetch.result.price}} 和 {{$props.asset}}。
