Complete an image generation

Choose a model and handle either a synchronous image or an asynchronous task.

Image providers do not all return results the same way. This workflow supports both gateway modes.

Choose an image model in the marketplace

Text-to-image workflow

Choose an image model and submit a prompt. Synchronous routes return data, while asynchronous routes return an id and status to poll.

curl
#!/usr/bin/env bash
set -euo pipefail

response=$(curl -fsS https://api.noxgate.net/v1/images/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"YOUR_MODEL_ID","prompt":"A quiet library at sunrise","n":1}')

task_id=$(printf '%s' "$response" | jq -r '.id // empty')
status=$(printf '%s' "$response" | jq -r '.status // empty')
if [ -n "$task_id" ] && [ -n "$status" ] && [ "$status" != "succeeded" ]; then
  for delay in 2 3 5 8 10 10 10 10; do
    sleep "$delay"
    response=$(curl -fsS "https://api.noxgate.net/v1/images/generations/$task_id" \
      -H "Authorization: Bearer sk-your-api-key")
    status=$(printf '%s' "$response" | jq -r '.status // empty')
    case "$status" in succeeded) break ;; failed|canceled|cancelled) printf '%s
' "$response" >&2; exit 1 ;; esac
  done
fi

printf '%s
' "$response" | jq .

Reference images and edits

When supported, add image_url or image_urls. Use mask_url for regional edits; the gateway still requires prompt. Upstream providers must be able to access every URL.

curl
curl https://api.noxgate.net/v1/images/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"YOUR_MODEL_ID","prompt":"Turn this sketch into a clean product illustration","image_url":"https://example.com/reference.png","mask_url":"https://example.com/mask.png","response_format":"b64_json"}'

Recognize and save the result

  • If data is present without an in-progress status, handle a synchronous result.
  • If id and a non-terminal status are present, poll GET /v1/images/generations/:task_id.
  • A data item can contain url or b64_json. Download expiring URLs promptly.