Image Generation Parameters
The image generation API accepts several parameters including prompt (text description), n (number of images per request, 1-10), size (image dimensions), quality (low, medium, high, xhigh, max, auto), and output_format (png, jpeg). For GPT-Image-1 and later models, additional parameters include background (auto or transparent, requires PNG output) and output_compression (0-100, JPEG output only). The quality parameter defaults vary by model: GPT-Image-1 defaults to high, while GPT-Image-1-Mini defaults to medium. Image size options differ between model generations: GPT-Image-1 and GPT-Image-1-Mini support 1024x1024, 1024x1536, and 1536x1024, while GPT-Image-2 and later support custom dimensions with specific constraints on pixel count and aspect ratio.
Error Handling and Response Codes
The Azure OpenAI image generation API returns specific error codes for common issues. DeploymentNotFound errors occur when the deployment name doesn't exist or is misspelled. 401 Unauthorized errors indicate invalid or missing API keys. 429 Too Many Requests errors indicate rate limit exceeded, requiring retry logic with exponential backoff. The content_policy_violation error occurs when prompts or generated output are blocked by the content filter. The documentation provides example error responses showing the contentFilter error code with messages like 'Your task failed as a result of our safety system.' Successful responses include a created timestamp (Unix epoch time) and a data array with at least one image object containing base64-encoded image data. Developers should implement proper error handling to manage these scenarios.