curl --request POST \
--url https://api.maxapi.ai/sd/v2beta/stable-image/generate/sd3 \
--header 'accept: <accept>' \
--header 'authorization: <authorization>' \
--header 'content-type: multipart/form-data' \
--form prompt= \
--form image='@example-file'import requests
url = "https://api.maxapi.ai/sd/v2beta/stable-image/generate/sd3"
files = { "image": ("example-file", open("example-file", "rb")) }
payload = { "prompt": "" }
headers = {
"authorization": "<authorization>",
"accept": "<accept>"
}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('prompt', '');
form.append('image', '{
"fileName": "example-file"
}');
const options = {
method: 'POST',
headers: {authorization: '<authorization>', accept: '<accept>'}
};
options.body = form;
fetch('https://api.maxapi.ai/sd/v2beta/stable-image/generate/sd3', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.maxapi.ai/sd/v2beta/stable-image/generate/sd3"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
req.Header.Add("accept", "<accept>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.maxapi.ai/sd/v2beta/stable-image/generate/sd3")
.header("authorization", "<authorization>")
.header("accept", "<accept>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
.asString();"<string>"{
"id": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4",
"name": "bad_request",
"errors": [
"some-field: is required"
]
}{
"id": "ed14db44362126aab3cbd25cca51ffe3",
"name": "content_moderation",
"errors": [
"Your request was flagged by our content moderation system, as a result your request was denied and you were not charged."
]
}{
"id": "4212a4b66fbe1cedca4bf2133d35dca5",
"name": "payload_too_large",
"errors": [
"body: payloads cannot be larger than 10MiB in size"
]
}{
"id": "ff54b236a3acdde1522cb1ba641c43ed",
"name": "invalid_language",
"errors": [
"English is the only supported language for this service."
]
}{
"id": "rate_limit_exceeded",
"name": "rate_limit_exceeded",
"errors": [
"You have exceeded the rate limit of 150 requests within a 10 second period, and have been timed out for 60 seconds."
]
}{
"id": "2a1b2d4eafe2bc6ab4cd4d5c6133f513",
"name": "internal_error",
"errors": [
"An unexpected server error has occurred, please try again later."
]
}Stable Diffusion 3
Generate an image using a Stable Diffusion 3 model:
- SD3 Medium - the 2 billion parameter model
- SD3 Large - the 8 billion parameter model
- SD3 Large Turbo - the 8 billion parameter model with a faster inference time
This API is powered by Fireworks AI. API status can be reviewed here.
Try it out
Grab your API key and head over to one of the following sites:
How to use
Please invoke this endpoint with a POST request.
The headers of the request must include an API key in the authorization field. The body of the request must be
multipart/form-data. The accept header should be set to one of the following:
image/*to receive the image in the format specified by theoutput_formatparameter.application/jsonto receive the image encoded as base64 in a JSON response.
Generating with a prompt
Commonly referred to as text-to-image, this mode generates an image from text alone. While the only required
parameter is the prompt, it also supports an aspect_ratio parameter which can be used to control the
aspect ratio of the generated image.
Generating with a prompt and an image
Commonly referred to as image-to-image, this mode also generates an image from text but uses an existing image as the starting point. The required parameters are:
prompt- text to generate the image fromimage- the image to use as the starting point for the generationstrength- controls how much influence theimageparameter has on the output imagemode- must be set toimage-to-image
Note: maximum request size is 10MiB.
Optional Parameters:
Both modes support the following optional parameters:
model- the model to use (SD3 Medium, SD3 Large, or SD3 Large Turbo)output_format- the the format of the output imageseed- the randomness seed to use for the generationnegative_prompt- keywords of what you do not wish to see in the output image
Note: for more details about these parameters please see the request schema below.
Output
The resolution of the generated image will be 1MP. The default resolution is 1024x1024.
Credits
- SD3 Medium: Flat rate of 3.5 credits per successful generation.
- SD3 Large: Flat rate of 6.5 credits per successful generation.
- SD3 Large Turbo: Flat rate of 4 credits per successful generation.
As always, you will not be charged for failed generations.
curl --request POST \
--url https://api.maxapi.ai/sd/v2beta/stable-image/generate/sd3 \
--header 'accept: <accept>' \
--header 'authorization: <authorization>' \
--header 'content-type: multipart/form-data' \
--form prompt= \
--form image='@example-file'import requests
url = "https://api.maxapi.ai/sd/v2beta/stable-image/generate/sd3"
files = { "image": ("example-file", open("example-file", "rb")) }
payload = { "prompt": "" }
headers = {
"authorization": "<authorization>",
"accept": "<accept>"
}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('prompt', '');
form.append('image', '{
"fileName": "example-file"
}');
const options = {
method: 'POST',
headers: {authorization: '<authorization>', accept: '<accept>'}
};
options.body = form;
fetch('https://api.maxapi.ai/sd/v2beta/stable-image/generate/sd3', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.maxapi.ai/sd/v2beta/stable-image/generate/sd3"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
req.Header.Add("accept", "<accept>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.maxapi.ai/sd/v2beta/stable-image/generate/sd3")
.header("authorization", "<authorization>")
.header("accept", "<accept>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
.asString();"<string>"{
"id": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4",
"name": "bad_request",
"errors": [
"some-field: is required"
]
}{
"id": "ed14db44362126aab3cbd25cca51ffe3",
"name": "content_moderation",
"errors": [
"Your request was flagged by our content moderation system, as a result your request was denied and you were not charged."
]
}{
"id": "4212a4b66fbe1cedca4bf2133d35dca5",
"name": "payload_too_large",
"errors": [
"body: payloads cannot be larger than 10MiB in size"
]
}{
"id": "ff54b236a3acdde1522cb1ba641c43ed",
"name": "invalid_language",
"errors": [
"English is the only supported language for this service."
]
}{
"id": "rate_limit_exceeded",
"name": "rate_limit_exceeded",
"errors": [
"You have exceeded the rate limit of 150 requests within a 10 second period, and have been timed out for 60 seconds."
]
}{
"id": "2a1b2d4eafe2bc6ab4cd4d5c6133f513",
"name": "internal_error",
"errors": [
"An unexpected server error has occurred, please try again later."
]
}请求头
Your Stability API key, used to authenticate your requests. Although you may have multiple keys in your account, you should use the same key for all requests to this API.
1The content type of the request body. Do not manually specify this header; your HTTP client library will automatically include the appropriate boundary parameter.
1"multipart/form-data"
Specify image/* to get the image bytes directly. Otherwise specify application/json to receive the image as base64 encoded JSON.
application/json, image/* 请求体
What you wish to see in the output image. A strong, descriptive prompt that clearly defines elements, colors, and subjects will lead to better results.
1 - 10000""
Controls whether this is a text-to-image or image-to-image generation, which affects which parameters are required:
- text-to-image requires only the
promptparameter - image-to-image requires the
prompt,image, andstrengthparameters
image-to-image, text-to-image "text-to-image"
The image to use as the starting point for the generation.
Supported formats:
- jpeg
- png
- webp
Supported dimensions:
- Every side must be at least 64 pixels
Important: This parameter is only valid for image-to-image requests.
Sometimes referred to as denoising, this parameter controls how much influence the
image parameter has on the generated image. A value of 0 would yield an image that
is identical to the input. A value of 1 would be as if you passed in no image at all.
Important: This parameter is only valid for image-to-image requests.
0 <= x <= 1""
Controls the aspect ratio of the generated image. Defaults to 1:1.
Important: This parameter is only valid for text-to-image requests.
16:9, 1:1, 21:9, 2:3, 3:2, 4:5, 5:4, 9:16, 9:21 "1:1"
The model to use for generation.
sd3-mediumrequires 3.5 credits per generationsd3-largerequires 6.5 credits per generationsd3-large-turborequires 4 credits per generation
sd3-large, sd3-large-turbo, sd3-medium "sd3-large"
A specific value that is used to guide the 'randomness' of the generation. (Omit this parameter or pass 0 to use a random seed.)
0 <= x <= 4294967294""
Dictates the content-type of the generated image.
jpeg, png "png"
Keywords of what you do not wish to see in the output image. This is an advanced feature.
Important: This parameter does not work with
sd3-large-turbo.
10000""
响应
图片生成成功。返回格式由请求中的 Accept 头决定。
The response is of type file.