Generate images
The synchronous JSON response contains image results in data.
On this page
https://api.shareai.now/api/v1/imagesGenerate images
- Base URL
https://api.shareai.now- Authentication
- Bearer API key or approved OAuth access token
- Required scope
inferenceormonetization_gateway
The synchronous JSON response contains image results in data. The alias /api/v1/images/generations is also supported. Options such as size, resolution, aspect_ratio, quality and output format depend on the selected model. Responses are bounded to 2 MiB; reduce image count or size when needed. Returned images are limited to 8192 pixels per side.
Before you start#
Set SHAREAI_API_KEY on your server and replace the model placeholder with a currently enabled model. Never expose the API key in browser code. The model, account, credential and provider must all permit this operation. Optional settings below require model support; the API safety bounds are not a promise that every model supports every value.
Send a request#
cURL
curl --fail-with-body --request POST "https://api.shareai.now/api/v1/images" \
-H "Authorization: Bearer $SHAREAI_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"model": "YOUR_ENABLED_IMAGES_MODEL",
"prompt": "A quiet forest painted in watercolor.",
"n": 1
}'Python
import json
import os
import urllib.request
payload = {'model': 'YOUR_ENABLED_IMAGES_MODEL',
'prompt': 'A quiet forest painted in watercolor.',
'n': 1}
headers = {'Content-Type': 'application/json'}
headers["Authorization"] = "Bearer " + os.environ["SHAREAI_API_KEY"]
request = urllib.request.Request('https://api.shareai.now/api/v1/images', data=json.dumps(payload).encode(), headers=headers, method="POST")
with urllib.request.urlopen(request, timeout=180) as response:
result = json.load(response)
print(result)TypeScript
const response = await fetch("https://api.shareai.now/api/v1/images", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.SHAREAI_API_KEY}`, ...{"Content-Type": "application/json"} },
body: JSON.stringify({
"model": "YOUR_ENABLED_IMAGES_MODEL",
"prompt": "A quiet forest painted in watercolor.",
"n": 1
}),
});
if (!response.ok) throw new Error(await response.text());
const result = await response.json();
console.log(result);Request fields#
| Field | Type | Meaning and limits |
|---|---|---|
model required | string | Exact enabled public model identifier. Must declare this operation and be allowed by your credential. |
prompt required | string | Nonempty generation prompt, at most 256 KiB of UTF-8 text. |
n | integer | Optional image count, 1–10; default 1. Your model may allow fewer. |
size | string | Model-supported output size, at most 100 characters, for example 1024×1024. Not every model supports this option. |
resolution | string | Model-supported resolution selector, at most 100 characters; must match the published tariff variant. |
aspect_ratio | string | Model-supported aspect ratio selector, at most 100 characters. |
quality | string | Model-supported quality selector, at most 100 characters; may select a different rate. |
response_format | string | Model-supported response format, at most 100 characters. The operation determines whether the result is JSON or binary. |
output_format | string | Model-supported output encoding selector, at most 100 characters. |
background | string | Optional image background setting when supported by the model. |
seed | integer | Optional model-supported seed. Video requires a nonnegative integer; reproducibility depends on the executor. |
input_references | array | At most 16 typed image_url parts with image_url.url set to an HTTPS URL or supported image data URL. Model support is required. |
provider | object | Optional provider routing preferences. Use provider.only for accepted provider tags, not a prefix in the model ID. Account and credential restrictions still apply. |
Read the result#
Success returns HTTP 200 with JSON. The synchronous JSON response contains image results in data. The alias /api/v1/images/generations is also supported. Options such as size, resolution, aspect_ratio, quality and output format depend on the selected model. Responses are bounded to 2 MiB; reduce image count or size when needed. Returned images are limited to 8192 pixels per side.
Billing units#
Image tariffs can use generated images, measured megapixels, input references, requests or provider-reported tokens. An image URL is not an image-size measurement. Megapixel tariffs require returned image dimensions; use base64 output for those routes.
Choose the exact enabled model identifier from Console. Its declared operation and input/output capabilities must match this endpoint; a text chat model cannot be substituted for another operation. Your credential, provider and account restrictions still apply.
Pricing and usage#
Rates are published in EUR AI credits for the selected model, provider, units and variants. Only the dimensions in its active tariff are charged. An estimate reserves credits before execution; final charges use measured usage. Prices can depend on resolution, output format or a usage band. Check Console Usage for the final ShareAI debit. Upstream cost fields and media bytes are not converted into invented token counts.
Access and errors#
Use inference for approved network-cost inference or monetization_gateway for an approved Builder markup and accepted billing terms. Identity-only access does not authorize spending. Validation, model authorization, insufficient credits, rate limits and execution failures return a structured error. After a timeout or uncertain submission, inspect Usage or the video job before creating another potentially paid request.
Last updated November 3, 2026