gpt-image (Azure) CODE-COMPLETE

Two proprietary image models - gpt-image-1.5 (transparent) and gpt-image-2 (top-quality opaque) - fulfilled inline via Azure OpenAI. The code is complete and lint-clean; it needs Azure credentials + deployment names to go live.

Azure only. Image generation goes through Azure OpenAI, never OpenAI direct. This is a hard platform rule. Azure uses the api-key header, not a Bearer token.

Call shape

ItemValue
URL<endpoint>/openai/v1/images/generations?api-version=preview
Auth headerapi-key: <key> (Azure style, NOT Bearer)
Content typeContent-Type: application/json
Body{ model, prompt, n, size, quality [, background=transparent] }
Responsedata[0].b64_json -> base64-decode -> PNG
POST https://<resource>.openai.azure.com/openai/v1/images/generations?api-version=preview
api-key: <AZURE_KEY>
Content-Type: application/json

{
  "model": "gpt-image-1.5",
  "prompt": "a neon fox mascot",
  "n": 1,
  "size": "1024x1024",
  "quality": "medium",
  "background": "transparent"
}

Model settings

ModelBackgroundDefault qualityNotes
gpt-image-1.5transparentmediumThe transparent-RGBA proprietary option. background=transparent is sent.
gpt-image-2opaquehighTop quality, opaque. No background field sent.

These jobs are claimed on a dedicated inline path (like text), never POSTed to the async RunPod /run endpoint. On success the PNG is saved to /uploads/gen/gen_<id>.png and that URL becomes the job result.

Configuration (to go live)

Set these in lib/faucet_config.php (gitignored):

KeyRequiredDescription
gen_azure_endpointyesAzure OpenAI resource endpoint.
gen_azure_api_keyyesAzure API key.
gen_azure_deploymentsrecommendedMap of model id -> Azure deployment name (defaults to the model name).
gen_azure_api_versionnoDefaults to preview.
gen_azure_sizenoDefaults to 1024x1024.
gen_azure_timeoutnoDefaults to 120 s.

With the endpoint or key unset, these jobs simply stay queued and nothing errors. Error handling maps Azure failures to the standard codes (429 insufficient_quota -> out_of_credits, 401/403 -> auth); see Error codes.

Official documentation