Configuration Options for Image Generation Models in Prompt-Optimizer: DALL-E and Seedream Guide

The Prompt-Optimizer framework configures image generation providers like DALL-E and Seedream through environment variables, provider adapters, and capability-driven model definitions that support both text-to-image and image-to-image workflows.

The linshenkx/prompt-optimizer repository implements a flexible provider-adapter architecture for AI image generation. Understanding the configuration options for image generation models allows developers to customize provider endpoints, manage API credentials, and control model capabilities across different services like OpenAI's DALL-E and Seedream (火山方舟).

Environment Variable Configuration

The system centralizes provider credentials and endpoint overrides in environment variables defined in packages/core/src/services/image-model/defaults.ts.

API Keys (IMAGE_PROVIDER_ENV_KEYS)

Each provider requires a specific environment variable to enable the model. If the variable is empty or undefined, the provider is automatically disabled.

  • VITE_OPENAI_API_KEY – Enables DALL-E 2/3 models
  • VITE_SEEDREAM_API_KEY – Primary key for Seedream/火山方舟 (falls back to VITE_ARK_API_KEY)

These mappings are stored in the IMAGE_PROVIDER_ENV_KEYS constant. The getDefaultImageModels() function iterates over these keys to build the runtime configuration map, setting enabled: true only when a valid API key is detected.

Base URL Overrides (IMAGE_BASE_URL_ENV_KEYS)

You can override default provider endpoints for self-hosted or region-specific deployments:

  • VITE_OPENAI_BASE_URL – Custom OpenAI-compatible endpoint
  • VITE_SEEDREAM_BASE_URL – Custom Seedream endpoint (falls back to VITE_ARK_BASE_URL)

This configuration lives in IMAGE_BASE_URL_ENV_KEYS within packages/core/src/services/image-model/defaults.ts.

Model Registration and Identification

Config IDs (IMAGE_CONFIG_IDS)

Every provider registers a stable identifier used by the UI and storage layer to reference specific model configurations:

  • image-openai-gpt – Maps to OpenAI DALL-E models
  • image-seedream – Maps to Seedream models

These IDs are defined in the IMAGE_CONFIG_IDS object and serve as the primary keys when calling ImageService.generate().

Enabled Flags and Default Models

The getDefaultImageModels() function automatically constructs the ImageModelConfig object for each provider. It selects the first available model from the adapter's getModels() list as the default and sets the enabled boolean based on the presence of the corresponding API key environment variable.

Provider Adapter Architecture

Each provider implements the AbstractImageProviderAdapter interface exposed in packages/core/src/services/image/types.ts.

OpenAI/DALL-E Adapter

Located at packages/core/src/services/image/adapters/openai.ts, this adapter:

  • Exposes getProvider() with connection schema requiring apiKey and optional baseURL
  • Returns static model definitions via getModels() including DALL-E 2 and DALL-E 3
  • Defines capabilities (text-to-image, image-to-image support) and parameter schemas
  • Implements doGenerate() to construct the final HTTP payload merging defaults with paramOverrides

Seedream Adapter

Found in packages/core/src/services/image/adapters/seedream.ts, this adapter provides:

  • Provider metadata for 火山方舟 integration
  • Static model definitions with 4K resolution support and watermark options
  • Parameter definitions for size selection and watermark toggling
  • Request handling that supports both text-to-image and image-to-image workflows

Capabilities and Parameters

Model Capabilities

Each model object declares supported generation modes through a capabilities property:

  • text2image: Boolean indicating text-to-image generation support
  • image2image: Boolean for image-to-image editing/variation support
  • multiImage: Boolean for batch generation capabilities

The UI uses these flags to disable unsupported interaction modes. For example, if a model returns capabilities: { text2image: true, image2image: false, multiImage: false }, the interface will block image-to-image uploads for that configuration.

Parameter Defaults and Overrides

Configuration options for image generation models include runtime parameter customization:

  • Default values: Each adapter defines defaultParameterValues for model-specific settings like resolution (1024x1024, 4K), quality (standard, high), and watermarks
  • Per-request overrides: The paramOverrides map in generation requests allows temporary value changes without modifying global defaults

The ImageService merges these values in the doGenerate() method before constructing the provider-specific payload.

Implementation Examples

Initialize the service and generate images using specific configuration IDs:

import { createImageService } from '@prompt-optimizer/core';

// Initialize the service (registry auto-wires adapters)
const imageService = createImageService();

// Generate with DALL-E 3
const dallEResult = await imageService.generate({
  configId: 'image-openai-gpt',          // References IMAGE_CONFIG_IDS.openai
  prompt: 'a futuristic city at sunset',
  paramOverrides: { 
    size: '1536x1024', 
    quality: 'high' 
  }
});

// Generate with Seedream (image-to-image)
const seedreamResult = await imageService.generate({
  configId: 'image-seedream',            // References IMAGE_CONFIG_IDS.seedream
  prompt: 'add vibrant colors',
  inputImage: {
    b64: '<base64-encoded-png>',
    mimeType: 'image/png'
  },
  paramOverrides: { 
    size: '4K', 
    watermark: true 
  }
});

The service validates capabilities before execution, preventing unsupported operations like calling image-to-image on text-only models.

Summary

  • Environment variables control provider availability through VITE_OPENAI_API_KEY and VITE_SEEDREAM_API_KEY, with optional base URL overrides for custom endpoints
  • Config IDs (image-openai-gpt, image-seedream) provide stable references to provider configurations managed in packages/core/src/services/image-model/defaults.ts
  • Provider adapters encapsulate model definitions, capabilities, and request logic in dedicated files under packages/core/src/services/image/adapters/
  • Capability flags automatically constrain UI options based on what each model supports (text2image, image2image, multiImage)
  • Parameter overrides allow runtime customization of generation settings without changing global defaults

Frequently Asked Questions

How do I enable DALL-E 3 in my Prompt-Optimizer deployment?

Set the VITE_OPENAI_API_KEY environment variable with your OpenAI API key. The getDefaultImageModels() function in packages/core/src/services/image-model/defaults.ts automatically detects this key and enables the image-openai-gpt configuration. If the variable is empty, the provider remains disabled in the UI.

Can I use a custom endpoint for Seedream instead of the default 火山方舟 servers?

Yes. Set the VITE_SEEDREAM_BASE_URL environment variable to your custom endpoint URL. The system falls back to VITE_ARK_BASE_URL if the Seedream-specific variable is undefined. The SeedreamImageAdapter uses this value when constructing HTTP requests in its doGenerate() method.

What determines whether image-to-image generation is available?

The capabilities.image2image boolean flag on each model definition controls this feature. In packages/core/src/services/image/service.ts, the ImageService validates these capabilities before processing requests. If a model's capability object sets image2image: false, the service rejects image-to-image requests with a validation error.

How do I change the image resolution for a specific generation request?

Pass a paramOverrides object in your generation request containing the size parameter. For DALL-E, use standard sizes like 1024x1024 or 1536x1024. For Seedream, specify resolutions like 4K. These values override the defaultParameterValues defined in the respective provider adapter while leaving the global configuration unchanged.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →