When using the Azure OpenAI implementation, the code was incorrectly converting the model parameter to a string, resulting in an unwanted "Optional" prefix being added to the deployment model value
Example:
... ImageGenerateParams.builder().model(ImageModel.GPT_IMAGE_1) ...
Will generate:
"/openai/deployments/Optional[gpt-image-1]/images/generations"
Instead of:
"/openai/deployments/gpt-image-1/images/generations"
Solution
On openai.java.core ImageServiceImpl.kt modified the code to properly handle the optional model parameter using map/orElse pattern specifically for Azure deployments, as the edit and createVariation methods handle this.
.prepare(
clientOptions,
params,
deploymentModel = params.model().map { it.toString() }.orElse(null)
)
ImageServiceImplDiff.txt
The fix ensures the correct model identifier is passed to the Azure API without the "Optional" prefix.
As an additional comment the model should be required on the Azure implementation since it refers to the model deployment.