More APIs
Image Generation
Generate images from text prompts using the OpenAI-compatible images API.
DEVUP AI supports the OpenAI-compatible image generation API. The default model is FLUX Schnell.
Example
import urllib.request
from openai import OpenAI
client = OpenAI(
api_key="$DEVUP_API_KEY",
base_url="https://api.devupai.com/v1",
)
response = client.images.generate(
prompt="A photo of an astronaut riding a horse on Mars.",
size="1024x1024",
n=1,
)
image_url = response.data[0].url
with urllib.request.urlopen(image_url) as res:
image_bytes = res.read()
with open("output.png", "wb") as f:
f.write(image_bytes)Supported parameters
| Parameter | Notes |
|---|---|
| prompt | Text description of the image |
| model | Defaults to FLUX Schnell |
| size | Image dimensions (e.g., "1024x1024") |
| n | Number of images to generate |
| response_format | Format of the generated images: "url" (default, returns a signed proxy URL in data[].url) or "b64_json" (returns Base64-encoded image bytes inline in data[].b64_json). Any other value is rejected with HTTP 400. |
| quality, style | Available for compatibility only |
URL expiry
The generated image URL in data[].url is signed and expires 5 minutes after the response is generated. After expiry, the media proxy returns HTTP 403 Forbidden. Applications should download the image bytes directly upon receiving the response rather than storing the proxy URL. This expiration applies only to the "url" response; callers who do not want to handle expiring URLs can request "b64_json" instead.
With response_format: "url" (the default), the link expires after 5 minutes and the image is deleted 30 minutes after it is created. Use b64_json to receive the image in the response instead.
Response format
Default response (response_format: "url"):
{
"data": [
{
"url": "https://api.devupai.com/v1/images/proxy?d=<b64url>&s=<hmac>"
}
],
"_devup": {
"request_id": "req_9fd8ddec5b2149539860a86dccba58cf"
}
}Inline Base64 response (response_format: "b64_json"):
{
"data": [
{
"b64_json": "<base64>"
}
],
"_devup": {
"request_id": "req_9fd8ddec5b2149539860a86dccba58cf"
}
}The _devup object contains:
cost_dzd(number): Cost of the request in DZD.balance_dzd(number): Remaining balance in DZD.request_id(string): Equal to thex-request-idresponse header.
The examples above are abridged: they show _devup with request_id only.
LoRA image adapters
You can also use custom LoRA adapters for image generation — see LoRA for Image Generation.
Tutorial
For a deeper example including advanced options, see the Stable Diffusion tutorial.