Image API

Generate expressive imagery through the luntrex router.

Use the same dark, glass-inspired UI to explore how our /images/generate endpoint combines prompt routing, safety checks, and deterministic token accounting.

🖼️ Image Generation API

Generate cinematic visuals, concept art, or marketing assets on demand. luntrex handles provider selection, moderation, and billing while exposing a single, stable endpoint.
2 active models · 1 provider

Base URL https://luntrex.com/api/v1

Overview

Send a POST /images/generate request with your prompt, output size, and desired count. luntrex routes to the best image model for your policy, returning hosted URLs, usage metrics, and audit data.

Request payload

Provide the visual description, resolution, number of images, and optionally the model.

{
    "prompt": "A futuristic cityscape at night, neon lights",
    "size": "1024x1024",
    "n": 1,
    "model": "openai/dall-e-2"
}

Response payload

Receive signed URLs along with usage information to reconcile billing and quotas.

{
    "images": [
        "https://cdn.luntrex.com/images/uuid1.png"
    ],
    "usage": {
        "cost_tokens": 30000,
        "n": 1,
        "size": "1024x1024"
    }
}

Authentication

Protect requests with bearer tokens issued in the luntrex dashboard. Scope keys per environment or team, and rotate them instantly when needed.

Authorization header

Authorization: Bearer <YOUR_API_KEY>

Supported Models

Use the model parameter to specify the model to use for image generation.

Model catalog

Available Model Model sizes
dall-e-2 256x256, 512x512, 1024x1024
dall-e-3 1024x1024, 1024x1792, 1792x1024

Examples

Call the REST endpoint from your preferred language. These snippets cover JavaScript, Python, and Laravel.

JavaScript (fetch)

const resp = await fetch('https://luntrex.com/api/v1/images/generate', {
    method: 'POST',
    headers: {
        'Authorization': 'Bearer <YOUR_API_KEY>',
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({
        prompt: 'A cozy cabin in the snowy mountains, digital art',
        size: '512x512',
        n: 1,
        model: 'openai/dall-e-2',
    }),
});
const data = await resp.json();
console.log(data.images);

Python (requests)

import requests

    r = requests.post(
    "https://luntrex.com/api/v1/images/generate",
        headers={
            "Authorization": "Bearer <YOUR_API_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "An astronaut riding a horse on Mars",
            "size": "1024x1024",
            "n": 1,
            "model": "openai/dall-e-2"
         }
        )
     print(r.json()["images"])

PHP (Laravel Http client)

use Illuminate\Support\Facades\Http;
     $response = Http::withHeaders([
        'Authorization' => 'Bearer <YOUR_API_KEY>',
        'Content-Type'  => 'application/json',
    ])->post('https://luntrex.com/api/v1/images/generate', [
        'prompt' => 'A dragon flying over a medieval castle',
        'size'   => '512x512',
        'n'      => 1,
        'model'  => 'openai/dall-e-2',
 ]);

echo $response->json()['images'][0];

Postman / cURL

Validate credentials quickly via Postman or copy this cURL snippet into your terminal.

cURL example

curl --location "https://luntrex.com/api/v1/images/generate" \
  --header "Authorization: Bearer <YOUR_API_KEY>" \
  --header "Content-Type: application/json" \
  --data-raw '{
    "prompt": "Landscape with mountains and rivers",
    "size": "512x512",
    "n": 1,
    "model": "openai/dall-e-2"
  }'

Errors

Handle failures with structured error responses. Monitor status codes and error messages to trigger retries, alerts, or user-facing messaging.

Example error payload

{
    "error": "Insufficient credits",
    "status": 403
}

Credits & Pricing

Image costs depend on resolution and count. Balance is deducted only when generation succeeds. Adjust token rates and allowances inside the billing console.

Current library range: 0.0080 – 0.0800 tokens per image (provider pricing may vary).

Size Cost (Tokens)
256x256 5,000
512x512 15,000
1024x1024 30,000

Baseline conversion: 1 BDT = 500 tokens (fully configurable). Token usage is logged per request for reconciliation.

Back to top