# OpenAI - GPT-4o Vision

> Invoke OpenAI GPT-4o (Omni) via the Chat Completions API for image understanding, vision-based OCR, and visual reasoning over diagrams and charts.

Source: https://docs.sommatic.ai/en/nodes/integrations.openai.gpt-4o.vision/

- Slug: `integrations.openai.gpt-4o.vision`
- Family: Integrations
- Version: 1.0.0
- Status: Available
- Execution: async

Invoke OpenAI GPT-4o (Omni) via the Chat Completions API for image understanding, vision-based OCR, and visual reasoning over diagrams and charts.

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).

**Operations:**
- **Image captioning:** Natural-language descriptions of photographs, screenshots, and product imagery.
- **Chart and diagram interpretation:** Structured extraction of data series, labels, and relationships from bar charts, line charts, flow diagrams, and images containing tables.
- **Vision-based OCR:** Reads text in layouts that defeat classical OCR — low contrast, unusual typography, handwriting, skewed scans, stylized signage.
- **Scene understanding:** Identifies objects, activities, and contextual cues to support moderation, tagging, and routing workflows.

**Inputs:** base64-encoded image or a public image URL.
**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.

## Configuration

- `llm_provider_id` (string, required): Select a vision-capable LlmProvider from the cognitive-assets registry (e.g. an Azure OpenAI GPT-4o deployment).
- `prompt` (string, optional, accepts expressions): Default: `Describe the content of this image as accurately as possible. Include any visible text verbatim.`.
- `system_prompt` (string, optional): Default: `You are a vision assistant that describes images accurately and extracts any visible text verbatim.`.
- `max_tokens` (number, optional): Default: `1024`.
- `temperature` (number, optional): Lower values produce more deterministic output, better for OCR-style tasks. Default: `0.2`.

Its configuration shows the shared execution settings, but this node does not apply retries (`retryOnFail`, `maxTries`) yet. `continueOnFail` is not applied by any node.

## Output ports

- `extracted` (default): Extracted
- `empty`: Empty
- `error`: Error

## Input contract

- `content_base64` (string, optional)
- `content_type` (string, optional): Default: `image/png`.
- `image_url` (string, optional): Public URL to an image (alternative to content_base64).

## Output contract

- `text` (string, optional)
- `chars` (number, optional)
- `empty` (boolean, optional)
- `method` (string, optional)
- `metadata` (object, optional)

## In expressions

What a later node can read from this node's output with `$("OpenAI - GPT-4o Vision").item.json.<path>` (write your node's label instead of `OpenAI - GPT-4o Vision`). **Editor** marks the paths the workflow editor suggests under Previous Nodes (the output contract); **Worker** marks the paths the worker really returns through `extracted`, from the output shown in Ports.

- `$("OpenAI - GPT-4o Vision").item.json.text` (string) = `"Receipt from Example Store. Total: $42.10. D…"`
- `$("OpenAI - GPT-4o Vision").item.json.chars` (number) = `60`
- `$("OpenAI - GPT-4o Vision").item.json.empty` (boolean) = `false`
- `$("OpenAI - GPT-4o Vision").item.json.method` (string) = `"llm.vision"`
- `$("OpenAI - GPT-4o Vision").item.json.metadata` (object) = `{…}`
- `$("OpenAI - GPT-4o Vision").item.json.metadata.llm_provider_id` (string) = `"<llm_provider_id>"` (Not suggested by the editor)
- `$("OpenAI - GPT-4o Vision").item.json.metadata.usage` (object) = `{…}` (Not suggested by the editor)


## How it works

Sends one image and a prompt to a vision-capable LLM provider registered in Sommatic AI and returns the model's text. The call goes through the Sommatic AI backend, which resolves the provider and its secret.

1. Resolves the node config and requires `llm_provider_id`.
2. Takes the image from `content_base64` (with `content_type`, default `image/png`) or from `image_url`, reading each key from the config first and then from the incoming item. Base64 content is sent as a `data:` URL.
3. Builds a chat request with `system_prompt`, a user message containing `prompt` and the image, `max_tokens` (default 1024) and `temperature` (default 0.2).
4. Calls the backend LLM provider invocation endpoint with a timeout of `execution.timeout_ms` (default 120000).
5. Trims the returned text and builds `{ text, chars, empty, method: "llm.vision", metadata: { llm_provider_id, usage } }`; empty text goes to `empty`, otherwise `extracted`.

## In a workflow

### Node

```json
{
  "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
  }
}
```

### Envelope

```json
{
  "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"
}
```

## Output ports (behaviour in the code)

### `extracted`

The model returned text.

```json
{
  "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`

The call succeeded but the text is empty.

```json
{
  "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`

Validation failed, the backend answered with HTTP 400 or more or `success: false`, or the request timed out.

```json
{
  "error": "Either content_base64 or image_url is required."
}
```

## Behaviour in the code

- `llm_provider_id`: The model is whatever this provider is configured with; the node name does not force GPT-4o. Pick a vision-capable deployment.
- `content_base64`: Undeclared in the config schema; normally comes from the incoming item together with `content_type`. `image_url` is used only when `content_base64` is absent.
- `temperature`: Must be a number; any other type falls back to 0.2. A `max_tokens` of 0 or empty falls back to 1024.
- `execution`: Only `timeout_ms` is read (default 120000). The retry settings are not applied.

## Errors

| Message | Port | Cause and fix |
| --- | --- | --- |
| `llm_provider_id is required.` | `error` | No LLM provider selected. |
| `Either content_base64 or image_url is required.` | `error` | Neither the config nor the incoming item carries an image. |
| `LLM provider invoke returned HTTP <status>` | `error` | The backend rejected the call without a message. When it sends one (for example `LLM Invocation Error (SDK): <detail>`), that message is returned instead. |
| `timeout of <ms>ms exceeded` | `error` | The provider did not answer within `execution.timeout_ms`. |

## Notes and limits

- The worker never calls OpenAI directly and holds no provider key; usage is billed to the provider's own account.
- `usage` is passed through from the provider response and may be absent. The node does not retry.


## Contracts (JSON Schema)

### All (`*.definition.js`)

```json
{
  "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
    }
  }
}
```

### config_schema

```json
{
  "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

```json
{
  "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

```json
{
  "type": "object",
  "properties": {
    "text": {
      "type": "string"
    },
    "chars": {
      "type": "number"
    },
    "empty": {
      "type": "boolean"
    },
    "method": {
      "type": "string"
    },
    "metadata": {
      "type": "object"
    }
  }
}
```

### ports

```json
[
  {
    "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
  }
]
```
