Chapter 8 of 211 min

8. Images#

8.1 Image generation#

POST /v1/images/generations — text to image (synchronous response).

ParameterTypeRequiredDescription
modelstringYesImage model name
promptstringYesImage description
sizestringNoSize, e.g. 1024x1024
nintegerNoNumber of images to generate
cURL
curl http://183.240.79.21:52099/v1/images/generations \
  -H "Authorization: Bearer sk-你的YiTuoToken-Key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dall-e-3",
    "prompt": "一只戴着宇航头盔的柯基犬,赛博朋克风格",
    "size": "1024x1024"
  }'

8.2 Image editing#

POST /v1/images/edits — image-to-image / inpainting. The image file is uploaded with multipart/form-data.

cURL
curl http://183.240.79.21:52099/v1/images/edits \
  -H "Authorization: Bearer sk-你的YiTuoToken-Key" \
  -F model="dall-e-2" \
  -F image=@./input.png \
  -F prompt="把背景换成星空"