Stability.ai¶
1. Overview¶
Stability AI develops AI models, and its best-known family is Stable Diffusion, a deep-learning image generation model widely used for creating high-quality images from text descriptions.
Description:
- Models in this family are not optimized for Chinese prompts. Use English natural-language prompts when possible.
2. Request¶
- Method:
POST -
Endpoint:
https://gateway.serevixai.ai/v1/images/generations
3. Parameters¶
3.1 Header Parameters¶
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
Content-Type |
string | Yes | Sets the request content type. It must be multipart/form-data. |
multipart/form-data; boundary=------------------------y0QNRDhXQUE3yHQi7DEbLz |
Accept |
string | Yes | Sets the response content type. It must be image/*. |
image/* |
Authorization |
string | Yes | API key required for authentication, in the format Bearer $YOUR_API_KEY. |
Bearer $YOUR_API_KEY |
3.2 Body Parameters (multipart/form-data)¶
| Parameter | Type | Required | Description | Example (default) |
|---|---|---|---|---|
| model | string | Yes | The model ID to use. See Model List for available versions, such as sd3-large. |
sd3-large |
| prompt | string | Yes | A text prompt describing the image to generate. Maximum prompt length is 10,000 characters. | A cute baby sea otter |
| mode | string | No | Controls whether the request runs in text-to-image or image-to-image mode. text-to-image requires only prompt, while image-to-image requires prompt, image, and strength. sd-core does not support image-to-image. |
text-to-image |
| image | string(binary) | No | Input image used as the starting point for image-to-image. Supported formats: jpeg, png, and webp. Each side must be at least 64 pixels. |
|
| strength | number[0,1] | No | Sometimes called denoising, this controls how much the source image influences the result. A value of 0 keeps the result identical to the input image, while 1 behaves as if no image was supplied. |
0.9 |
| negative_prompt | string | No | Keywords describing content you do not want to appear in the output image. sd3-large-turbo does not support this parameter. |
a cat |
| seed | number[0,4294967294] | No | Specific seed value used to control randomness. If omitted or set to 0, a random seed is used. |
0 |
| aspect_ratio | string | No | Controls the generated image aspect ratio. Supported values: 16:9, 1:1, 21:9, 2:3, 3:2, 4:5, 5:4, 9:16, and 9:21. |
1:1 |
| output_format | string | No | Output image format. Supported values are jpeg and png. |
png |
| style_preset | string | No | Guides the image model toward a specific style. Supported values include 3d-model, analog-film, anime, cinematic, comic-book, digital-art, enhance, fantasy-art, isometric, line-art, low-poly, modeling-compound, neon-punk, origami, photographic, pixel-art, and tile-texture. Only sd-core supports this parameter. |
4. Request Examples¶
text-to-image
curl https://gateway.serevixai.ai/v1/images/generations \
-H "Accept: image/*" \
-H "Authorization: Bearer $YOUR_API_KEY" \
-F model="sd3-large" \
-F prompt="A cute baby sea otter wearing a beret"
image-to-image
curl https://gateway.serevixai.ai/v1/images/generations \
-H "Accept: image/*" \
-H "Authorization: Bearer $YOUR_API_KEY" \
-F model="sd3-large" \
-F prompt="A cute baby sea otter wearing a beret" \
-F mode="image-to-image" \
-F image="@input.png" \
-F strength=0.9 \
5. Response Example¶
HTTP/1.1 200 OK
Content-Type: image/png
Binary image file