Melious
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/generations

Quick 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

ParameterTypeRequiredDefaultDescription
promptstringYes-Text description of the image to generate
modelstringNoflux-schnellModel ID (see Available Models)
nintegerNo1Number of images (1-4)
sizestringNo1024x1024Image dimensions
response_formatstringNourlurl or b64_json
userstringNonullEnd-user identifier

Available Models

ModelBrandDescriptionBest For
flux-schnellBlack Forest LabsFast generationQuick iterations, prototyping
flux-devBlack Forest LabsHigh-quality generationProduction images
sdxl-base-1.0Stability AISDXL base modelGeneral purpose
sdxl-base-v10Stability AISDXL base v10General purpose
sdxl-lightning-4stepByteDanceFast 4-step generationSpeed priority
sdxl-lightning-8stepByteDanceQuality 8-step generationQuality priority

Available Sizes

SizeAspect RatioDescription
512x5121:1Square (small)
768x7681:1Square (medium)
1024x10241:1Square (large)
1024x7684:3Landscape
768x10243:4Portrait
1280x72016:9Widescreen
720x12809:16Vertical

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"
  }
}
FieldTypeDescription
createdintegerUnix timestamp
dataarrayArray of generated images
data[].urlstringImage URL (valid for 1 hour)
data[].b64_jsonstringBase64 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 style

With Style Reference:

A portrait of a cat wearing a crown, oil painting style,
Renaissance era, dramatic lighting, rich colors

Technical Specifications:

Product photography of a sleek smartphone, white background,
soft shadows, 45-degree angle, professional studio lighting
  1. Be specific - Include details about style, lighting, colors
  2. Specify medium - "oil painting", "3D render", "photograph"
  3. Describe composition - "close-up", "wide shot", "aerial view"
  4. Set mood - "serene", "dramatic", "whimsical"
  5. Avoid ambiguity - "a dog" vs "a golden retriever puppy"

Error Handling

Error CodeDescriptionSolution
BILLING_INSUFFICIENT_ENERGYNot enough balanceTop up credits
VALIDATION_INVALID_VALUEInvalid size or parameterCheck allowed values
INFERENCE_PROVIDER_ERRORGeneration failedRetry or modify prompt

Content Policy: Prompts that violate content policies will be rejected. Avoid explicit, violent, or harmful content.


See Also

On this page