Skip to content

Text-to-Image ​

The following API calls require that you have installed the 文生图 application. Click to install

The text-to-image API follows the OpenAI API format.

  1. Get model endpoint (currently only one default model: sd-cpp-local corresponding to z-image-turbo)

curl https://imagen-ai.$微服名称.heiyu.space/v1/models

  1. Image generation endpoint (https://platform.openai.com/docs/api-reference/images/create)
curl https://imagen-ai.微服.heiyu.space/v1/images/generations \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sd-cpp-local",
    "prompt": "A lovely cat",
    "n": 1,
    "size": "512x512",
    "response_format": "b64_json"
  }' \
  -o >(jq -r '.data[0].b64_json' | base64 --decode > output.png)

Parameter usage similar to OpenAI:

  • prompt: prompt text
  • n: number of generated images
  • size: image dimensions; both width and height must be integer multiples of 16, otherwise the input is invalid
  • response_format: currently only supports a fixed format

Model-specific parameters: Since the OpenAI format does not reserve additional parameter interfaces, the advanced parameters of Z-Image-Turbo can be placed within the prompt for current version.

"prompt": "A lovely cat<sd_cpp_extra_args>{\"seed\": 357925}</sd_cpp_extra_args>",

Currently supported:

  • steps: iteration step count. The default value set by the backend in the current version is 7, with the model-recommended value of 9. The valid range is 0–9. Fewer steps result in faster generation; for demonstration or testing, you can set it to 4 to quickly generate results without waiting too long. Note that "turbo" refers to a distilled model, and the step count must not exceed 20, otherwise the generated image will be improperly rendered and unusable.
  • seed: generation seed. The default is a random value. A user can manually specify a fixed seed to achieve consistent and reproducible results, which is essential for specific use cases requiring stability.