Inference
Image Generation
Generate images from text prompts using FLUX and SDXL models
Image Generation
Generate images from text descriptions using open-source image generation models including FLUX and SDXL.
Privacy-first: All image models are open-source and self-hosted on European infrastructure. Your prompts are never sent to external APIs.
POST /v1/images/generationsQuick Example
from openai import OpenAI
client = OpenAI(
api_key="sk-mel-your-api-key-here",
base_url="https://api.melious.ai/v1"
)
response = client.images.generate(
model="flux-schnell",
prompt="A serene mountain landscape at sunset with a reflective lake",
size="1024x1024",
n=1
)
print(response.data[0].url)import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'sk-mel-your-api-key-here',
baseURL: 'https://api.melious.ai/v1'
});
const response = await client.images.generate({
model: 'flux-schnell',
prompt: 'A serene mountain landscape at sunset with a reflective lake',
size: '1024x1024',
n: 1
});
console.log(response.data[0].url);curl https://api.melious.ai/v1/images/generations \
-H "Authorization: Bearer sk-mel-your-api-key-here" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-schnell",
"prompt": "A serene mountain landscape at sunset with a reflective lake",
"size": "1024x1024",
"n": 1
}'Request Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | string | Yes | - | Text description of the image to generate |
model | string | No | flux-schnell | Model ID (see Available Models) |
n | integer | No | 1 | Number of images (1-4) |
size | string | No | 1024x1024 | Image dimensions |
response_format | string | No | url | url or b64_json |
user | string | No | null | End-user identifier |
Available Models
| Model | Brand | Description | Best For |
|---|---|---|---|
flux-schnell | Black Forest Labs | Fast generation | Quick iterations, prototyping |
flux-dev | Black Forest Labs | High-quality generation | Production images |
sdxl-base-1.0 | Stability AI | SDXL base model | General purpose |
sdxl-base-v10 | Stability AI | SDXL base v10 | General purpose |
sdxl-lightning-4step | ByteDance | Fast 4-step generation | Speed priority |
sdxl-lightning-8step | ByteDance | Quality 8-step generation | Quality priority |
Available Sizes
| Size | Aspect Ratio | Description |
|---|---|---|
512x512 | 1:1 | Square (small) |
768x768 | 1:1 | Square (medium) |
1024x1024 | 1:1 | Square (large) |
1024x768 | 4:3 | Landscape |
768x1024 | 3:4 | Portrait |
1280x720 | 16:9 | Widescreen |
720x1280 | 9:16 | Vertical |
Available sizes may vary by model. Check the model documentation for specific size support.
Response Format
{
"created": 1699999999,
"data": [
{
"url": "https://..../generated-image.png"
}
],
"environment_impact": {
"carbon_g_co2": 2.5,
"water_liters": 0.01,
"energy_kwh": 0.005,
"renewable_percent": 85,
"provider_id": "nebius",
"location": "NL"
}
}| Field | Type | Description |
|---|---|---|
created | integer | Unix timestamp |
data | array | Array of generated images |
data[].url | string | Image URL (valid for 1 hour) |
data[].b64_json | string | Base64 image data (if requested) |
Base64 Response
Request base64-encoded images instead of URLs:
response = client.images.generate(
model="flux-schnell",
prompt="A futuristic cityscape",
size="1024x1024",
response_format="b64_json"
)
import base64
image_data = base64.b64decode(response.data[0].b64_json)
with open("image.png", "wb") as f:
f.write(image_data)Prompt Guidelines
Descriptive and Specific:
A cozy coffee shop interior with warm lighting, wooden furniture,
plants on shelves, rain visible through large windows, soft jazz
atmosphere, watercolor painting styleWith Style Reference:
A portrait of a cat wearing a crown, oil painting style,
Renaissance era, dramatic lighting, rich colorsTechnical Specifications:
Product photography of a sleek smartphone, white background,
soft shadows, 45-degree angle, professional studio lighting- Be specific - Include details about style, lighting, colors
- Specify medium - "oil painting", "3D render", "photograph"
- Describe composition - "close-up", "wide shot", "aerial view"
- Set mood - "serene", "dramatic", "whimsical"
- Avoid ambiguity - "a dog" vs "a golden retriever puppy"
Error Handling
| Error Code | Description | Solution |
|---|---|---|
BILLING_INSUFFICIENT_ENERGY | Not enough balance | Top up credits |
VALIDATION_INVALID_VALUE | Invalid size or parameter | Check allowed values |
INFERENCE_PROVIDER_ERROR | Generation failed | Retry or modify prompt |
Content Policy: Prompts that violate content policies will be rejected. Avoid explicit, violent, or harmful content.
See Also
- Chat Completions - Text generation
- Models - Available models