← PixelAPI · Tutorials · All docs · Pricing

Tutorial: Smart Generate and Text-to-Image

Two endpoints, one engine (FLUX.1 schnell, Apache-2.0). /v1/image/smart-generate enhances a short prompt for you; /v1/image/generate renders your prompt as written at the size you choose.

When to use which

EndpointUse it whenInputsPrice
POST /v1/image/smart-generateYou have a short idea and want a polished result.prompt1.2 credits
POST /v1/image/generateYou want full control of the prompt and size.prompt, width, height, model=flux-schnell1.2 credits

Code

import time, requests

API = "https://api.pixelapi.dev"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}

def wait(gen_id):
    while True:
        r = requests.get(f"{API}/v1/image/{gen_id}", headers=HEADERS).json()
        if r["status"] in ("completed", "failed", "blocked"):
            return r
        time.sleep(2)

# Smart Generate: a short idea, enhanced automatically
job = requests.post(f"{API}/v1/image/smart-generate", headers=HEADERS,
                    json={"prompt": "a cosy coffee shop at night"}).json()
print(wait(job["generation_id"]).get("output_url"))

# Plain generate: your exact prompt and size
job = requests.post(f"{API}/v1/image/generate", headers=HEADERS,
                    json={"prompt": "flat-lay of a leather wallet, keys and sunglasses on oak, top-down, soft light",
                          "width": 1344, "height": 768, "model": "flux-schnell"}).json()
print(wait(job["generation_id"]).get("output_url"))

Size limit: width × height up to 1920 × 1080 pixels of area. Poll GET /v1/image/{generation_id} for the result.

Try Smart GenerateText-to-image overviewFLUX.1 schnell model page