tutorials

Flixly API Image Gen Guide

Step-by-step instructions for calling the Flixly image generation API with GPT-Image 2.0 and FLUX Kontext, including code samples, parameter tables, and error handling.

By Flixly TeamApril 10, 202613 views
Flixly API Image Gen Guide

TL;DR

The Flixly API accepts JSON requests to GPT-Image 2.0 and FLUX Kontext for 1024x1024 PNG outputs. Send an Authorization header with your key, include model and prompt fields, then poll for the completed asset URL. Credit cost is one per standard image.

The Flixly API for image generation lets developers send requests to models like GPT-Image 2.0 and receive outputs in PNG or JPEG. It differs from the dashboard interface because it supports scripted calls rather than manual uploads.

Core API Models and Limits

GPT-Image 2.0 accepts text prompts up to 500 characters and returns 1024x1024 images by default. FLUX Kontext handles contextual edits on reference images sized 512x512 to 2048x2048. Both models count credits at 1 per 512x512 output. Text to image calls map directly to the same backend endpoints used on the site.

Seedance 2.0 stays reserved for video tasks while Wan 2.7 and Kling 3.0 focus on motion. Image-only work stays with GPT-Image 2.0 or FLUX Kontext to keep credit costs predictable.

Request Structure

Every call requires an API key in the Authorization header. The body holds the model name, prompt, and optional parameters such as width, height, and seed. Responses return a job ID first, then the final asset URL after processing completes.

Parameters include:

  • model: string, one of gpt-image-2.0 or flux-kontext
  • prompt: string
  • width: integer, 512-2048
  • height: integer, 512-2048
  • negative_prompt: string, optional

Input and Output Examples

A minimal request for GPT-Image 2.0 looks like this:

{
  "model": "gpt-image-2.0",
  "prompt": "city skyline at dusk, 4k",
  "width": 1024,
  "height": 1024
}

The response contains a status field that moves from queued to completed in 4-12 seconds on average. When complete, the asset URL points to a 1.2 MB PNG file.

Where the API Fits in Workflows

Teams integrate the endpoint inside CI pipelines to create product mockups at scale. One studio runs nightly batches of 200 images through image to image to iterate on character designs. Another service pulls outputs into ai photo effects for batch color grading before delivery.

Developers also combine the API with image tools to upscale results automatically after generation. Credit usage stays visible in the account dashboard so teams can budget 5000 credits per month for production loads.

Authentication and Setup Steps

  1. Create an account through the registration form and confirm the email address.
  2. Navigate to the developer section inside the account menu and generate a new key.
  3. Store the key in an environment variable named FLIXLY_API_KEY.
  4. Install the official client library with npm or pip depending on your stack.
  5. Write a small test script that posts the JSON body shown earlier and prints the returned job ID.
  6. Poll the status endpoint every two seconds until the state changes to completed.
  7. Download the final image file and log the credit deduction shown in the response metadata.
  8. Rotate the key every 90 days and revoke old ones from the same dashboard panel.

Parameter Reference Table

Parameter Type Range Default Example Use
model string gpt-image-2.0, flux-kontext gpt-image-2.0 Switch between base and context models
width int 512-2048 1024 Match social media aspect ratios
height int 512-2048 1024 Control vertical crop
seed int 0-2147483647 random Reproduce exact outputs
negative_prompt string up to 400 chars none Remove unwanted elements

Error Handling

Rate limits return HTTP 429 with a retry-after header set to 60 seconds. Invalid model names trigger 400 errors that list accepted values in the message body. Credit exhaustion yields 402 responses so scripts can pause and top up the balance.

Where to Start

Begin with a single call to the text to image endpoint using GPT-Image 2.0 to confirm your key works.

FAQ

What authentication method does the Flixly image API require? Send the key generated in your account settings as a Bearer token in the Authorization header. No additional OAuth steps are needed.

How long does GPT-Image 2.0 take to return a 1024x1024 image? Average latency sits between 4 and 12 seconds depending on queue depth at the time of the request.

Can I pass a reference image when using FLUX Kontext through the API? Yes, include a base64 encoded image under the reference_image field along with the text prompt.

Does the API support batch generation in one request? No, each call produces a single image. Loop over multiple prompts in your client code to create batches.

What file formats are returned by default? PNG is the standard output. Add format: jpeg in the request body if you need smaller file sizes.

How do I track credit usage after each generation? The response JSON includes a credits_remaining field that updates immediately after the job finishes.

Frequently Asked Questions

What authentication method does the Flixly image API require?

Send the key generated in your account settings as a Bearer token in the Authorization header. No additional OAuth steps are needed.

How long does GPT-Image 2.0 take to return a 1024x1024 image?

Average latency sits between 4 and 12 seconds depending on queue depth at the time of the request.

Can I pass a reference image when using FLUX Kontext through the API?

Yes, include a base64 encoded image under the reference_image field along with the text prompt.

Does the API support batch generation in one request?

No, each call produces a single image. Loop over multiple prompts in your client code to create batches.

What file formats are returned by default?

PNG is the standard output. Add format: jpeg in the request body if you need smaller file sizes.

Tools mentioned in this post

apiimage-generationdevelopertutorialgpt-image

Ready to create with tutorials?

Jump straight into Flixly's AI studio and try tutorials with 50+ models — free to start.