Esta página no está disponible en español. Se muestra la versión en inglés.

OpenAI Images connector

Generate, edit, and create variations of images with OpenAI image models from AgentRuntime workflows.

En esta página

The openaiimage connector calls the OpenAI Images API with your own OpenAI API key. Images come back as base64 data (or a temporary URL for DALL-E models), ready to pass to another step that stores, emails, or publishes them.

Typical uses:

  • Generate a hero image for each blog post or campaign from a model-written prompt.
  • Restyle or fix an existing product image with an edit instruction.
  • Produce a few variations of an approved image for a person to pick from.

Prerequisites

  • An OpenAI account with API access and billing set up.
  • An OpenAI API key. Some image models may require extra account verification at OpenAI; check OpenAI's documentation if a model is rejected.
  • For edits and variations, the source image as base64 text.
  • The project_contributor role or higher in AgentRuntime.

Connect in AgentRuntime

  1. Create an OpenAI API key

    Sign in at platform.openai.com, open the API keys page, create a new secret key, and copy it. OpenAI shows the full key only once.

  2. Create a connection

    In the Console, go to Connections and click New custom connection. Enter a display name, then under Credentials set Key to api_key and Value to your OpenAI key. To change the default model, click Add field and add default_model (for example gpt-image-1). Click Save.

  3. Add the MCP instance

    Go to MCP, click Add connectors, click the openaiimage connector and then Add to workspace, then open Instance config. Pick your connection, set the profile to active, and save.

  4. Smoke test

    In Workflow Studio, add a connector step (type mcp) with tool_name openai_image_text_to_image and tool_args of { "prompt": "A red circle on a white background" }, then run it. The result has count of 1 and an entry in images.

See Integration authentication for how connections are bound to MCP instances.

What you can build

  • Marketing assets. A model writes a creative brief, openai_image_text_to_image renders it, and the Google Drive connector upload_file tool stores the base64 result.
  • Product image touch-ups. Pass a product photo to openai_image_edit_image with an instruction such as "replace the background with plain white".
  • A/B variants. openai_image_create_variation on an approved image, then a human step to pick the winner.
  • Report illustrations. Turn workflow data into a prompt and generate a matching image for a report.

Tools

All three tools create new images, which you are billed for by OpenAI. None change your existing files.

ToolDescription
openai_image_text_to_imageGenerate images from a text prompt
openai_image_edit_imageEdit an image with a text instruction; an optional mask limits where edits apply
openai_image_create_variationCreate variations of a source image (DALL-E 2 only)

Arguments, required ones first:

ToolArguments
openai_image_text_to_imageprompt (required); model (gpt-image-1, dall-e-3, dall-e-2), size, quality, n (default 1), background (transparent or opaque), output_format (png, jpeg, webp), output_compression (0-100), response_format (url or b64_json)
openai_image_edit_imageprompt, image_base64 (both required); image_mime_type, images_base64 (extra images, gpt-image-1), mask_base64 (PNG), model, size, n, background, output_format, response_format
openai_image_create_variationimage_base64 (required); image_mime_type, model (only dall-e-2, the default), size, n, response_format

quality, background, output_format, and output_compression apply to gpt-image-1 models. response_format applies to DALL-E models and defaults to b64_json; gpt-image-1 always returns base64.

Every tool returns model, count, and images. Each item in images has image_base64 (or url), mime_type, and size_bytes.

Example

Generate a square image from an earlier step's prompt:

{
  "id": "hero-image",
  "type": "mcp",
  "name": "Generate hero image",
  "tool_name": "openai_image_text_to_image",
  "tool_args": {
    "prompt": "{{steps.write-prompt.result.text}}",
    "model": "gpt-image-1",
    "size": "1024x1024",
    "output_format": "png",
    "n": 1
  },
  "depends_on": ["write-prompt"],
  "timeout_s": 120
}

A later step can read the picture from {{steps.hero-image.result.images}}. In Workflow Studio you pick the MCP instance on the step.

Configuration

These are the keys the connector reads. A custom connection whose field names match these keys is wired automatically on Instance config.

KeyRequiredDefaultDescription
api_keyYesnoneOpenAI API key
default_modelNogpt-image-1Model used when a tool call leaves out model
api_baseNohttps://api.openai.com/v1OpenAI API base URL

Troubleshooting

IssueFix
resolved config is missing api_keyThe connection has no api_key field, or it is not wired. Check the connection and Instance config.
OpenAI API error 401The key is wrong or revoked. Create a new key and update the connection.
OpenAI API error 400 mentioning a modelThe model is not available to your account, or a parameter does not suit the model. Try dall-e-3 or dall-e-2, and check OpenAI's documentation for the model's limits.
Request blocked for contentOpenAI rejected the prompt. Rewrite it to follow OpenAI's usage policies.
Variation failsVariations use dall-e-2 and need a PNG source image; OpenAI also limits its size and shape.
invalid base64Send the image as plain base64 text. A data: prefix is accepted.
Slow or timed-out stepRaise timeout_s (the example uses 120).
Very large step resultsImages arrive as base64 text. Store them in a file or Drive step instead of passing them through many steps.
Editar esta páginaagentruntime-io/agentruntime-docs