curl --request POST \
--url https://api.trymorse.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "flux-2-max",
"prompt": "a red apple on a wooden table, morning light",
"n": 2,
"aspect_ratio": "16:9"
}
'import requests
url = "https://api.trymorse.ai/v1/images/generations"
payload = {
"model": "flux-2-max",
"prompt": "a red apple on a wooden table, morning light",
"n": 2,
"aspect_ratio": "16:9"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'flux-2-max',
prompt: 'a red apple on a wooden table, morning light',
n: 2,
aspect_ratio: '16:9'
})
};
fetch('https://api.trymorse.ai/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"created": 1792187825,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"mime_type": "image/png"
},
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"mime_type": "image/png"
}
]
}{
"error": {
"message": "n must be between 1 and 4.",
"type": "invalid_request_error",
"param": null,
"code": "invalid_parameter"
}
}{
"error": {
"message": "Incorrect API key provided.",
"type": "invalid_request_error",
"param": null,
"code": "invalid_api_key"
}
}{
"error": {
"message": "The account balance does not cover the most this request could cost. Add credit, or ask for fewer images or reference images.",
"type": "insufficient_balance",
"param": null,
"code": "insufficient_balance"
}
}{
"error": {
"message": "This account has been disabled. Contact support.",
"type": "invalid_request_error",
"param": null,
"code": "account_disabled"
}
}{
"error": {
"message": "The requested model does not exist.",
"type": "invalid_request_error",
"param": null,
"code": "model_not_found"
}
}{
"error": {
"message": "The request body did not arrive in time.",
"type": "invalid_request_error",
"param": null,
"code": "request_timeout"
}
}{
"error": {
"message": "Request body is too large.",
"type": "invalid_request_error",
"param": null,
"code": "request_too_large"
}
}{
"error": {
"message": "Rate limit reached for this account. Retry after the time in the Retry-After header.",
"type": "requests",
"param": null,
"code": "rate_limit_exceeded"
}
}{
"error": {
"message": "The upstream model server failed.",
"type": "upstream_error",
"param": null,
"code": "upstream_error"
}
}{
"error": {
"message": "The service is temporarily unable to authorize requests. Try again shortly.",
"type": "server_error",
"param": null,
"code": "service_unavailable"
}
}Generate images
Generates up to four images from a prompt and optional reference images, and returns them inline as base64.
Each image costs the model’s micros_per_image, plus micros_per_reference for each reference image. Each image costs at least one credit. You pay only for the images delivered. If the request ends before the images return, you pay nothing.
curl --request POST \
--url https://api.trymorse.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "flux-2-max",
"prompt": "a red apple on a wooden table, morning light",
"n": 2,
"aspect_ratio": "16:9"
}
'import requests
url = "https://api.trymorse.ai/v1/images/generations"
payload = {
"model": "flux-2-max",
"prompt": "a red apple on a wooden table, morning light",
"n": 2,
"aspect_ratio": "16:9"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'flux-2-max',
prompt: 'a red apple on a wooden table, morning light',
n: 2,
aspect_ratio: '16:9'
})
};
fetch('https://api.trymorse.ai/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"created": 1792187825,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"mime_type": "image/png"
},
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"mime_type": "image/png"
}
]
}{
"error": {
"message": "n must be between 1 and 4.",
"type": "invalid_request_error",
"param": null,
"code": "invalid_parameter"
}
}{
"error": {
"message": "Incorrect API key provided.",
"type": "invalid_request_error",
"param": null,
"code": "invalid_api_key"
}
}{
"error": {
"message": "The account balance does not cover the most this request could cost. Add credit, or ask for fewer images or reference images.",
"type": "insufficient_balance",
"param": null,
"code": "insufficient_balance"
}
}{
"error": {
"message": "This account has been disabled. Contact support.",
"type": "invalid_request_error",
"param": null,
"code": "account_disabled"
}
}{
"error": {
"message": "The requested model does not exist.",
"type": "invalid_request_error",
"param": null,
"code": "model_not_found"
}
}{
"error": {
"message": "The request body did not arrive in time.",
"type": "invalid_request_error",
"param": null,
"code": "request_timeout"
}
}{
"error": {
"message": "Request body is too large.",
"type": "invalid_request_error",
"param": null,
"code": "request_too_large"
}
}{
"error": {
"message": "Rate limit reached for this account. Retry after the time in the Retry-After header.",
"type": "requests",
"param": null,
"code": "rate_limit_exceeded"
}
}{
"error": {
"message": "The upstream model server failed.",
"type": "upstream_error",
"param": null,
"code": "upstream_error"
}
}{
"error": {
"message": "The service is temporarily unable to authorize requests. Try again shortly.",
"type": "server_error",
"param": null,
"code": "service_unavailable"
}
}Authorizations
An API key from the Morse app. It starts with sk_morse_.
Body
Morse refuses any field not listed here, such as size, style, or user, with invalid_parameter.
An image model's id from GET /v1/models.
11 <= x <= 4Defaults to 1:1. With reference images, it defaults to the ratio nearest the first reference image's.
1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3 Some models take 1k only.
1k, 2k Applies only to models with a quality setting. Values include low, medium, and high.
Images always come back inline.
Reference images, as base64 data URLs of PNG, JPEG, or WebP images. Each model sets its own maximum, and some models take none. Each reference image adds to the price of every image.