OpenAI - GPT-4o Vision
通过 Chat Completions API 调用 OpenAI GPT-4o(Omni),用于图像理解、基于视觉的 OCR,以及对示意图和图表的视觉推理。
将一张图片和提示词发送给在 Sommatic AI 中注册的具备视觉能力的 LLM 提供方,并返回模型输出的文本。调用经由 Sommatic AI 后端,由后端解析提供方及其密钥。
通过后端 POST /cognitive-infrastructure/cognitive-assets/llm-provider/invoke 端点路由,使用在 cognitive-assets 注册表中登记的 llm_provider_id。费用由 OpenAI 或 Azure OpenAI 直接计入你的订阅。兼容任何具备 vision 能力的 GPT-4 级别模型(GPT-4o、GPT-4o mini、GPT-4 Turbo with vision)。
操作:
- 图像描述: 用自然语言描述照片、截图和产品图片。
- 图表与示意图解读: 从柱状图、折线图、流程图和含表格的图片中结构化抽取数据序列、标签和关系。
- 基于视觉的 OCR: 读取传统 OCR 难以处理的版面中的文字,如低对比度、特殊字体、手写体、倾斜扫描件和风格化标牌。
- 场景理解: 识别物体、活动和上下文线索,支撑内容审核、打标签和路由类工作流。
输入: base64 编码的图片或公开的图片 URL。 控制项: system prompt、user prompt(支持表达式)、temperature 和 max tokens 均作为节点配置暴露,因此同一节点既可运行确定性的 OCR 式调用,也可做创意性的图像描述。
工作原理
- 解析节点配置,必须提供
llm_provider_id。 - 从
content_base64(配合content_type,默认image/png)或image_url获取图片,每个键先读配置再读输入项。base64 内容以data:URL 形式发送。 - 构建聊天请求:包含
system_prompt、由prompt和图片组成的用户消息、max_tokens(默认 1024)和temperature(默认 0.2)。 - 调用后端的 LLM 提供方调用接口,超时时间为
execution.timeout_ms(默认 120000)。 - 去除返回文本首尾空白,生成
{ text, chars, empty, method: "llm.vision", metadata: { llm_provider_id, usage } };文本为空经empty输出,否则经extracted输出。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-read-receipt",
"label": "Read receipt image",
"operator_slug": "integrations.openai.gpt-4o.vision",
"operator_version": "1.0.0",
"config": {
"llm_provider_id": "<llm_provider_id>",
"prompt": "Extract the store name, total and date from this receipt.",
"max_tokens": 512,
"temperature": 0
}
}{
"ok": true,
"data": {
"text": "Receipt from Example Store. Total: $42.10. Date: 2026-11-25.",
"chars": 60,
"empty": false,
"method": "llm.vision",
"metadata": {
"llm_provider_id": "<llm_provider_id>",
"usage": {
"prompt_tokens": 1146,
"completion_tokens": 21,
"total_tokens": 1167
}
}
},
"port": "extracted"
}配置
-
llm_provider_idstring 必填 -
从 cognitive-assets 注册表中选择一个具备视觉能力的 LlmProvider(例如 Azure OpenAI GPT-4o 部署)。
-
promptstring 可选 支持表达式 -
system_promptstring 可选 -
max_tokensnumber 可选 -
temperaturenumber 可选 -
值越低,输出越确定,更适合 OCR 类任务。
配置中会显示通用执行设置,但该节点目前不执行重试(retryOnFail、maxTries)。所有节点均未实现 continueOnFail。
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
llm_provider_id - 实际使用的模型取决于该提供方的配置,节点名称并不强制使用 GPT-4o。请选择具备视觉能力的部署。
-
content_base64代码会读取,但未声明 - 未在配置 schema 中声明,通常与
content_type一起来自输入项。仅在缺少content_base64时使用image_url。 -
temperature - 必须为数字,其他类型会回退为 0.2。
max_tokens为 0 或为空时回退为 1024。 -
execution - 只读取
timeout_ms(默认 120000),重试设置不会生效。
输出端口
extracted 默认 模型返回了文本。
{
"text": "Receipt from Example Store. Total: $42.10. Date: 2026-11-25.",
"chars": 60,
"empty": false,
"method": "llm.vision",
"metadata": {
"llm_provider_id": "<llm_provider_id>",
"usage": {
"prompt_tokens": 1146,
"completion_tokens": 21,
"total_tokens": 1167
}
}
}empty 调用成功但文本为空。
{
"text": "",
"chars": 0,
"empty": true,
"method": "llm.vision",
"metadata": {
"llm_provider_id": "<llm_provider_id>",
"usage": {
"prompt_tokens": 1146,
"completion_tokens": 0,
"total_tokens": 1146
}
}
}error 校验失败、后端返回 HTTP 400 及以上或 success: false,或请求超时。
{
"error": "Either content_base64 or image_url is required."
}在表达式中
后续节点可通过 $("OpenAI - GPT-4o Vision").item.json.<路径> 读取此节点输出中的内容(请把 OpenAI - GPT-4o Vision 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 extracted 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("OpenAI - GPT-4o Vision").item.json.text | ||
$("OpenAI - GPT-4o Vision").item.json.chars | ||
$("OpenAI - GPT-4o Vision").item.json.empty | ||
$("OpenAI - GPT-4o Vision").item.json.method | ||
$("OpenAI - GPT-4o Vision").item.json.metadata | ||
$("OpenAI - GPT-4o Vision").item.json.metadata.llm_provider_id | — | |
$("OpenAI - GPT-4o Vision").item.json.metadata.usage | — |
— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
llm_provider_id is required. | error | 未选择 LLM 提供方。 |
Either content_base64 or image_url is required. | error | 配置和输入项中都没有图片。 |
LLM provider invoke returned HTTP <status> | error | 后端拒绝了调用且未提供信息。若后端返回了信息(例如 LLM Invocation Error (SDK): <detail>),则返回该信息。 |
timeout of <ms>ms exceeded | error | 提供方未在 execution.timeout_ms 内响应。 |
输入契约
-
content_base64string 可选 -
content_typestring 可选 -
image_urlstring 可选 -
图片的公开 URL(content_base64 的替代方式)。
输出契约
-
textstring 可选 -
charsnumber 可选 -
emptyboolean 可选 -
methodstring 可选 -
metadataobject 可选
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "integrations.openai.gpt-4o.vision",
"name": "OpenAI - GPT-4o Vision",
"category": "integrations",
"group": [
{
"key": "openai",
"name": "OpenAI",
"icon_url": "/icons/integrations/openai/openai.svg"
}
],
"icon_url": "/icons/integrations/openai/openai.svg",
"version": "1.0.0",
"description": "Invoke OpenAI GPT-4o (Omni) via the Chat Completions API for image understanding, vision-based OCR, and visual reasoning over diagrams and charts.\n\n Routes through the backend `POST /cognitive-infrastructure/cognitive-assets/llm-provider/invoke` endpoint using an `llm_provider_id` registered in the cognitive-assets registry. Billing is handled directly by OpenAI or Azure OpenAI against your subscription. Compatible with any GPT-4 class model that exposes the `vision` capability (GPT-4o, GPT-4o mini, GPT-4 Turbo with vision).\n\n **Operations:**\n - **Image captioning:** Natural-language descriptions of photographs, screenshots, and product imagery.\n - **Chart and diagram interpretation:** Structured extraction of data series, labels, and relationships from bar charts, line charts, flow diagrams, and images containing tables.\n - **Vision-based OCR:** Reads text in layouts that defeat classical OCR — low contrast, unusual typography, handwriting, skewed scans, stylized signage.\n - **Scene understanding:** Identifies objects, activities, and contextual cues to support moderation, tagging, and routing workflows.\n\n **Inputs:** base64-encoded image or a public image URL.\n **Controls:** system prompt, user prompt (expression-enabled), temperature, and max tokens exposed as node configuration so the same node can run deterministic OCR-style calls or creative captioning.",
"capabilities": [
"openai",
"gpt-4o",
"vision",
"image-understanding",
"ocr",
"llm"
],
"config_schema": {
"type": "object",
"properties": {
"llm_provider_id": {
"type": "string",
"title": "LLM Provider",
"description": "Select a vision-capable LlmProvider from the cognitive-assets registry (e.g. an Azure OpenAI GPT-4o deployment).",
"x-ui-widget": "llm-provider-picker"
},
"prompt": {
"type": "string",
"title": "User Prompt",
"default": "Describe the content of this image as accurately as possible. Include any visible text verbatim.",
"format": "expression"
},
"system_prompt": {
"type": "string",
"title": "System Prompt",
"default": "You are a vision assistant that describes images accurately and extracts any visible text verbatim."
},
"max_tokens": {
"type": "number",
"title": "Max Tokens",
"default": 1024
},
"temperature": {
"type": "number",
"title": "Temperature",
"default": 0.2,
"description": "Lower values produce more deterministic output, better for OCR-style tasks."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
},
"required": [
"llm_provider_id"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"content_base64": {
"type": "string"
},
"content_type": {
"type": "string",
"default": "image/png"
},
"image_url": {
"type": "string",
"description": "Public URL to an image (alternative to content_base64)."
}
}
},
"output_contract_schema": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"chars": {
"type": "number"
},
"empty": {
"type": "boolean"
},
"method": {
"type": "string"
},
"metadata": {
"type": "object"
}
}
},
"ports": [
{
"port_id": "extracted",
"label": "Extracted",
"is_default": true,
"supports_condition": true
},
{
"port_id": "empty",
"label": "Empty",
"is_default": false,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"required_resources": [],
"compatible_worker_pools": [
"standard-io",
"cloud-io"
],
"tags": [
"openai",
"gpt-4o",
"vision",
"llm",
"image"
],
"is_stateful": false,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://sommatic.ai",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"llm_provider_id": {
"type": "string",
"title": "LLM Provider",
"description": "Select a vision-capable LlmProvider from the cognitive-assets registry (e.g. an Azure OpenAI GPT-4o deployment).",
"x-ui-widget": "llm-provider-picker"
},
"prompt": {
"type": "string",
"title": "User Prompt",
"default": "Describe the content of this image as accurately as possible. Include any visible text verbatim.",
"format": "expression"
},
"system_prompt": {
"type": "string",
"title": "System Prompt",
"default": "You are a vision assistant that describes images accurately and extracts any visible text verbatim."
},
"max_tokens": {
"type": "number",
"title": "Max Tokens",
"default": 1024
},
"temperature": {
"type": "number",
"title": "Temperature",
"default": 0.2,
"description": "Lower values produce more deterministic output, better for OCR-style tasks."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
},
"required": [
"llm_provider_id"
]
}{
"type": "object",
"properties": {
"content_base64": {
"type": "string"
},
"content_type": {
"type": "string",
"default": "image/png"
},
"image_url": {
"type": "string",
"description": "Public URL to an image (alternative to content_base64)."
}
}
}{
"type": "object",
"properties": {
"text": {
"type": "string"
},
"chars": {
"type": "number"
},
"empty": {
"type": "boolean"
},
"method": {
"type": "string"
},
"metadata": {
"type": "object"
}
}
}[
{
"port_id": "extracted",
"label": "Extracted",
"is_default": true,
"supports_condition": true
},
{
"port_id": "empty",
"label": "Empty",
"is_default": false,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"is_default": false,
"supports_condition": false
}
]执行
- 执行方式
async- 有状态
- 否
- 重试(
retryOnFail) - 否
- 能力
openaigpt-4ovisionimage-understandingocrllm- 标签
openaigpt-4ovisionllmimage
说明与限制
- worker 从不直接调用 OpenAI,也不持有提供方密钥;用量计入提供方自己的账户。
usage直接取自提供方响应,可能不存在。节点不会重试。
已对照编排器代码核实 · 31e874b · 2026-11-26