OpenAI Images connector
Generate, edit, and create variations of images with OpenAI image models from AgentRuntime workflows.
On this page
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_contributorrole or higher in AgentRuntime.
Connect in AgentRuntime
- 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.
- 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_keyand Value to your OpenAI key. To change the default model, click Add field and adddefault_model(for examplegpt-image-1). Click Save. - 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.
- Smoke test
In Workflow Studio, add a connector step (type
mcp) withtool_nameopenai_image_text_to_imageandtool_argsof{ "prompt": "A red circle on a white background" }, then run it. The result hascountof 1 and an entry inimages.
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_imagerenders it, and the Google Drive connectorupload_filetool stores the base64 result. - Product image touch-ups. Pass a product photo to
openai_image_edit_imagewith an instruction such as "replace the background with plain white". - A/B variants.
openai_image_create_variationon 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.
| Tool | Description |
|---|---|
openai_image_text_to_image | Generate images from a text prompt |
openai_image_edit_image | Edit an image with a text instruction; an optional mask limits where edits apply |
openai_image_create_variation | Create variations of a source image (DALL-E 2 only) |
Arguments, required ones first:
| Tool | Arguments |
|---|---|
openai_image_text_to_image | prompt (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_image | prompt, 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_variation | image_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.
| Key | Required | Default | Description |
|---|---|---|---|
api_key | Yes | none | OpenAI API key |
default_model | No | gpt-image-1 | Model used when a tool call leaves out model |
api_base | No | https://api.openai.com/v1 | OpenAI API base URL |
Troubleshooting
| Issue | Fix |
|---|---|
resolved config is missing api_key | The connection has no api_key field, or it is not wired. Check the connection and Instance config. |
OpenAI API error 401 | The key is wrong or revoked. Create a new key and update the connection. |
OpenAI API error 400 mentioning a model | The 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 content | OpenAI rejected the prompt. Rewrite it to follow OpenAI's usage policies. |
| Variation fails | Variations use dall-e-2 and need a PNG source image; OpenAI also limits its size and shape. |
invalid base64 | Send the image as plain base64 text. A data: prefix is accepted. |
| Slow or timed-out step | Raise timeout_s (the example uses 120). |
| Very large step results | Images arrive as base64 text. Store them in a file or Drive step instead of passing them through many steps. |
Related
- Integrations quickstart
- Gemini Images connector: Google's image generation
- Google Drive connector: store generated images
- Connector catalog
- Troubleshooting