linshenkx/prompt-optimizer · error · ImageError

MODEL_NOT_SUPPORT_IMAGE2IMAGE

MODEL_NOT_SUPPORT_IMAGE2IMAGE

Error message

MODEL_NOT_SUPPORT_IMAGE2IMAGE

What it means

Ollama's image API supports only text-to-image. doGenerate throws MODEL_NOT_SUPPORT_IMAGE2IMAGE (with modelName in metadata) whenever request.inputImage is present.

Source

Thrown at packages/core/src/services/image/adapters/ollama.ts:135

      {
        name: 'size',
        labelKey: 'image.params.size.label',
        descriptionKey: 'image.params.size.description',
        type: 'string',
        defaultValue: '1024x1024',
        allowedValues: ['1024x1024', '1536x1024', '1024x1536', 'auto']
      }
    ]
  }

  protected getDefaultParameterValues(_modelId: string): Record<string, unknown> {
    return { size: '1024x1024' }
  }

  protected async doGenerate(request: ImageRequest, config: ImageModelConfig): Promise<ImageResult> {
    // Ollama image API only supports text-to-image for now.
    if (request.inputImage) {
      throw new ImageError(IMAGE_ERROR_CODES.MODEL_NOT_SUPPORT_IMAGE2IMAGE, undefined, { modelName: config.modelId })
    }

    const merged: Record<string, any> = {
      ...config.paramOverrides,
      ...request.paramOverrides
    }

    const size = typeof merged.size === 'string' && merged.size.trim() ? merged.size : '1024x1024'

    const payload = {
      model: config.modelId,
      prompt: request.prompt,
      size,
      response_format: 'b64_json'
    }

    const url = this.resolveEndpointUrl(config, '/images/generations')
    const rawApiKey = typeof config.connectionConfig?.apiKey === 'string' ? config.connectionConfig.apiKey : ''

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Drop the input image and use text-to-image with Ollama
  2. Route edit requests to a provider supporting i2i
  3. Check adapter capabilities before offering the edit option

Example fix

// before
await ollamaAdapter.generate({ prompt, inputImage }, config)

// after
await ollamaAdapter.generate({ prompt }, config)
Defensive patterns

Strategy: validation

Validate before calling

if (provider === 'ollama' && request.inputImage) {
  throw new Error('Ollama image API is text-to-image only')
}

Type guard

function supportsInputImage(provider: string): boolean {
  return provider !== 'ollama' && provider !== 'modelscope'
}

Try / catch

if (request.inputImage && !supportsInputImage(provider))
  return userError('Image editing not supported for this model')

Prevention

When it happens

Trigger: Calling generate() with an inputImage against an Ollama-backed image model — e.g. an edit workflow routed to Ollama.

Common situations: Provider-agnostic UIs that allow attaching input images to any model; users assuming Ollama's OpenAI-compat API covers images/edits like OpenAI's.

Related errors


AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27). Data as JSON: /api/errors/b599e4766cf1c40b. Report an issue: GitHub.