(options: GenerateImageOptions)
| 90 | } |
| 91 | |
| 92 | export async function generateImage(options: GenerateImageOptions): Promise<GenerateImageResult> { |
| 93 | if (!options.apiKey.trim()) { |
| 94 | throw new CodesignError('Missing image generation API key', ERROR_CODES.PROVIDER_AUTH_MISSING); |
| 95 | } |
| 96 | const prompt = options.prompt.trim(); |
| 97 | if (prompt.length === 0) { |
| 98 | throw new CodesignError('Image prompt cannot be empty', ERROR_CODES.INPUT_EMPTY_PROMPT); |
| 99 | } |
| 100 | if (options.provider === 'openrouter') return generateOpenRouterImage({ ...options, prompt }); |
| 101 | if (options.provider === 'chatgpt-codex') { |
| 102 | return generateChatGPTCodexImage({ ...options, prompt }); |
| 103 | } |
| 104 | return generateOpenAIImage({ ...options, prompt }); |
| 105 | } |
| 106 | |
| 107 | async function generateOpenAIImage( |
| 108 | options: GenerateImageOptions & { prompt: string }, |
no test coverage detected