Skip to main content

openai_image_generation

Generates an image from a text description and other attributes, using the OpenAI API.

This processor sends an image description and related attributes, such as size and quality, to the OpenAI API, which generates an image. By default the entire message payload is submitted as the prompt string, unless you customize it using the prompt field.

# Config fields, showing default values
processor:
label: ""
openai_image_generation:
server_address: https://api.openai.com/v1
api_key: "" # No default (required)
model: "" # No default (required)
prompt: ""
quality: ""
size: ""
style: ""

Examples

Generate an image from a text description held in each message.

processor:
openai_image_generation:
server_address: https://api.openai.com/v1
api_key: "${OPENAI_API_KEY}"
model: dall-e-3
prompt: "${! this.description }"

Fields

api_key

The API key for the OpenAI API. :::warning Secret This field contains sensitive information that usually shouldn't be added to a config directly, read our secrets page for more info. :::

Type: string

model

The name of the OpenAI model to use, for example dall-e-3 or dall-e-2.

Type: string

prompt

A text description of the image you want to generate. When omitted, the entire message payload is submitted as the prompt. The maximum length is 1000 characters for dall-e-2 and 4000 characters for dall-e-3.

Type: string
Default: ""

quality

The quality of the image to generate. Accepts hd or standard, and is supported only by dall-e-3.

Type: string
Default: ""

server_address

The OpenAI API endpoint that the processor sends requests to.

Type: string
Default: "https://api.openai.com/v1"

size

The size of the generated image. For dall-e-2 this can be 256x256, 512x512, or 1024x1024. For dall-e-3 this can be 1024x1024, 1792x1024, or 1024x1792.

Type: string
Default: ""

style

The style of the generated image. Accepts vivid or natural, and is supported only by dall-e-3.

Type: string
Default: ""