Skip to content

Image Models Guide ​

This guide explains how to call VLX FLUX image generation models through the OpenAI-compatible protocol and the Midjourney-Proxy protocol.

Prerequisites

  • Register on VLX FLUX and create an API key
  • Confirm the API base URL https://api.vlxflux.io
  • Install the required runtime locally

OpenAI-Compatible API ​

Through the standard /v1/images/generations endpoint, you can call DALL-E, proxied Midjourney models, and other image generation capabilities.

Install Dependencies ​

bash
pip install openai requests

Python Usage ​

Basic Request ​

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxxxxxx",
    base_url="https://api.vlxflux.io/v1"
)

response = client.images.generate(
    model="dall-e-3",
    prompt="A cute cat drinking coffee in cyberpunk style",
    size="1024x1024",
    quality="standard",
    n=1,
)

image_url = response.data[0].url
print("Image URL:", image_url)

Return Base64 ​

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxxxxxx",
    base_url="https://api.vlxflux.io/v1"
)

response = client.images.generate(
    model="dall-e-3",
    prompt="A cute cat drinking coffee in cyberpunk style",
    size="1024x1024",
    response_format="b64_json",
    n=1,
)

image_b64 = response.data[0].b64_json
print(image_b64[:50] + "...")

Save Image ​

python
import base64
from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxxxxxx",
    base_url="https://api.vlxflux.io/v1"
)

response = client.images.generate(
    model="dall-e-3",
    prompt="A cute cat drinking coffee in cyberpunk style",
    size="1024x1024",
    response_format="b64_json",
    n=1,
)

image_data = response.data[0].b64_json
with open("cat.png", "wb") as f:
    f.write(base64.b64decode(image_data))

print("Saved as cat.png")

curl Usage ​

bash
curl https://api.vlxflux.io/v1/images/generations   -H "Content-Type: application/json"   -H "Authorization: Bearer sk-xxxxxxxx"   -d '{
    "model": "dall-e-3",
    "prompt": "a cute cat drinking coffee, cyberpunk style",
    "size": "1024x1024",
    "n": 1
  }'

Supported Models ​

ModelTypeDescription
dall-e-2ImageOfficial DALL-E 2
dall-e-3ImageBetter detail quality
midjourneyImageProxied Midjourney
stable-diffusionImageStable Diffusion model

Extra Prompt Parameters ​

python
response = client.images.generate(
    model="midjourney",
    prompt="a cute cat drinking coffee --ar 16:9 --niji 6",
    n=1,
)

Midjourney-Proxy Protocol ​

If your application already uses the midjourney-proxy format, you can switch the Base URL and API secret directly.

Authentication ​

text
mj-api-secret: sk-xxxxxxxx

Python Usage ​

Submit Imagine Task ​

python
import requests

url = "https://api.vlxflux.io/mj/submit/imagine"
headers = {
    "mj-api-secret": "sk-xxxxxxxx",
    "Content-Type": "application/json"
}
data = {
    "prompt": "a futuristic city, neon lights --ar 16:9"
}

response = requests.post(url, headers=headers, json=data)
print(response.json())

Fetch Task Status ​

python
import requests

task_id = "123456789"
url = f"https://api.vlxflux.io/mj/task/{task_id}/fetch"
headers = {
    "mj-api-secret": "sk-xxxxxxxx"
}

response = requests.get(url, headers=headers)
print(response.json())

Common Errors ​

StatusCauseSolution
400Invalid parametersCheck prompt, size, and related fields
401Authentication failedCheck API key or Bearer prefix
402Insufficient balanceRecharge and retry
403No access to modelCheck model permission
500Upstream overloadRetry later or switch model