[1.x] Allow overriding OpenAI image moderation through provider options
Merged
EF
7d ago+58+58+01234567890123456789-4-4-0123456789
For gpt-image models the OpenAI gateway always sends moderation: low on generations and edits. It is written after the provider options are merged, so withProviderOptions(['moderation' => 'auto']) has no effect and there is no way to ask for OpenAI's own default.
OpenAI accepts low or auto for moderation, with auto as the default, on both image generation and image edits.
This keeps low as the default but uses moderation from the provider options when it is given:
Image::of('A red apple')
->withProviderOptions(['moderation' => 'auto'])
->generate(provider: 'openai', model: 'gpt-image-1');
Tests in tests/Feature/Providers/OpenAi/ImageGenerationTest.php and ImageEditTest.php cover the override on both endpoints, plus the low default for edits. The full suite (excluding the integration group) and PHPStan pass locally.