curl --request POST \
--url https://api.maxapi.ai/sd/v1/generation/{engine_id}/text-to-image \
--header 'Content-Type: application/json' \
--data '
{
"text_prompts": [
{
"text": "A lighthouse on a cliff",
"weight": 1
}
]
}
'import requests
url = "https://api.maxapi.ai/sd/v1/generation/{engine_id}/text-to-image"
payload = { "text_prompts": [
{
"text": "A lighthouse on a cliff",
"weight": 1
}
] }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({text_prompts: [{text: 'A lighthouse on a cliff', weight: 1}]})
};
fetch('https://api.maxapi.ai/sd/v1/generation/{engine_id}/text-to-image', 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/v1/generation/{engine_id}/text-to-image"
payload := strings.NewReader("{\n \"text_prompts\": [\n {\n \"text\": \"A lighthouse on a cliff\",\n \"weight\": 1\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
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/v1/generation/{engine_id}/text-to-image")
.header("Content-Type", "application/json")
.body("{\n \"text_prompts\": [\n {\n \"text\": \"A lighthouse on a cliff\",\n \"weight\": 1\n }\n ]\n}")
.asString();{
"artifacts": [
[
{
"base64": "...very long string...",
"finishReason": "SUCCESS",
"seed": 1050625087
},
{
"base64": "...very long string...",
"finishReason": "CONTENT_FILTERED",
"seed": 1229191277
}
]
]
}{
"id": "296a972f-666a-44a1-a3df-c9c28a1f56c0",
"name": "bad_request",
"message": "init_image: is required"
}{
"id": "9160aa70-222f-4a36-9eb7-475e2668362a",
"name": "unauthorized",
"message": "missing authorization header"
}{
"id": "5cf19777-d17f-49fe-9bd9-39ff0ec6bb50",
"name": "permission_denied",
"message": "You do not have permission to access this resource"
}{
"id": "92b19e7f-22a2-4e71-a821-90edda229293",
"name": "not_found",
"message": "The specified engine (ID some-fake-engine) was not found."
}{
"id": "f81964d6-619b-453e-97bc-9fd7ac3f04e7",
"name": "server_error",
"message": "An unexpected server error occurred, please try again."
}Text-to-image
Generate an image from a text prompt.
Using SDXL 1.0
Use stable-diffusion-xl-1024-v1-0 as the engine_id of your request and pass in height & width as one of the following combinations:
- 1024x1024
- 1152x896
- 896x1152
- 1216x832
- 1344x768
- 768x1344
- 1536x640
- 640x1536.
Using SD 1.6
Pass in stable-diffusion-v1-6 as the engine_id of your request and ensure the height & width you pass in adhere to the following restrictions:
- No dimension can be less than 320 pixels
- No dimension can be greater than 1536 pixels
Using SD Beta
Pass in stable-diffusion-xl-beta-v2-2-2 as the engine_id of your request and ensure the height & width you pass in adhere to the following restrictions:
- dimensions must be between 128x128 and 512x896 (or 896x512)
- only one dimension can be greater than 512, but not both
NOTE: Only Version 1 engines will work with this endpoint.
curl --request POST \
--url https://api.maxapi.ai/sd/v1/generation/{engine_id}/text-to-image \
--header 'Content-Type: application/json' \
--data '
{
"text_prompts": [
{
"text": "A lighthouse on a cliff",
"weight": 1
}
]
}
'import requests
url = "https://api.maxapi.ai/sd/v1/generation/{engine_id}/text-to-image"
payload = { "text_prompts": [
{
"text": "A lighthouse on a cliff",
"weight": 1
}
] }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({text_prompts: [{text: 'A lighthouse on a cliff', weight: 1}]})
};
fetch('https://api.maxapi.ai/sd/v1/generation/{engine_id}/text-to-image', 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/v1/generation/{engine_id}/text-to-image"
payload := strings.NewReader("{\n \"text_prompts\": [\n {\n \"text\": \"A lighthouse on a cliff\",\n \"weight\": 1\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
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/v1/generation/{engine_id}/text-to-image")
.header("Content-Type", "application/json")
.body("{\n \"text_prompts\": [\n {\n \"text\": \"A lighthouse on a cliff\",\n \"weight\": 1\n }\n ]\n}")
.asString();{
"artifacts": [
[
{
"base64": "...very long string...",
"finishReason": "SUCCESS",
"seed": 1050625087
},
{
"base64": "...very long string...",
"finishReason": "CONTENT_FILTERED",
"seed": 1229191277
}
]
]
}{
"id": "296a972f-666a-44a1-a3df-c9c28a1f56c0",
"name": "bad_request",
"message": "init_image: is required"
}{
"id": "9160aa70-222f-4a36-9eb7-475e2668362a",
"name": "unauthorized",
"message": "missing authorization header"
}{
"id": "5cf19777-d17f-49fe-9bd9-39ff0ec6bb50",
"name": "permission_denied",
"message": "You do not have permission to access this resource"
}{
"id": "92b19e7f-22a2-4e71-a821-90edda229293",
"name": "not_found",
"message": "The specified engine (ID some-fake-engine) was not found."
}{
"id": "f81964d6-619b-453e-97bc-9fd7ac3f04e7",
"name": "server_error",
"message": "An unexpected server error occurred, please try again."
}Headers
The format of the response. Leave blank for JSON, or set to 'image/png' for a PNG image.
application/json, image/png Allows for requests to be scoped to an organization other than the user's default. If not provided, the user's default organization will be used.
Used to identify the source of requests, such as the client application or sub-organization. Optional, but recommended for organizational clarity.
Used to identify the version of the application or service making the requests. Optional, but recommended for organizational clarity.
Path Parameters
Body
Represents the optional parameters that can be passed to any generation request.
An array of text prompts to use for generation.
Given a text prompt with the text A lighthouse on a cliff and a weight of 0.5, it would be represented as:
"text_prompts": [
{
"text": "A lighthouse on a cliff",
"weight": 0.5
}
]
1Height of the image to generate, in pixels, in an increment divisible by 64.
x >= 128Must be a multiple of 64512
Width of the image to generate, in pixels, in an increment divisible by 64.
x >= 128Must be a multiple of 64512
How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt)
0 <= x <= 357
FAST_BLUE, FAST_GREEN, NONE, SIMPLE, SLOW, SLOWER, SLOWEST "FAST_BLUE"
Which sampler to use for the diffusion process. If this value is omitted we'll automatically select an appropriate sampler for you.
DDIM, DDPM, K_DPMPP_2M, K_DPMPP_2S_ANCESTRAL, K_DPM_2, K_DPM_2_ANCESTRAL, K_EULER, K_EULER_ANCESTRAL, K_HEUN, K_LMS "K_DPM_2_ANCESTRAL"
Number of images to generate
1 <= x <= 101
Random noise seed (omit this option or use 0 for a random seed)
0 <= x <= 42949672950
Number of diffusion steps to run.
10 <= x <= 5050
Pass in a style preset to guide the image model towards a particular style. This list of style presets is subject to change.
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, tile-texture Extra parameters passed to the engine. These parameters are used for in-development or experimental features and may change without warning, so please use with caution.
Response
Request succeeded.
An array of results from the generation request, where each image is a base64 encoded PNG.