Image Generation with IONOS CLOUD AI Model Hub
The IONOS CLOUD AI Model Hub provides an OpenAI-compatible API that enables image editing using state-of-the-art foundation models. By supplying an input image and a descriptive prompt, you can modify existing images directly through the API without the need for managing underlying hardware or infrastructure.
Supported image editing models
You can edit images in AI Model Hub using select text-to-image models. For more information, see Models.
Overview
In this guide, you will learn how to edit images using foundation models through the IONOS CLOUD API. This guide is intended for developers with basic knowledge of:
REST APIs
A programming language for handling REST API endpoints (Python and Bash examples are provided)
By the end, you will be able to:
Retrieve a list of available image editing models in the IONOS CLOUD AI Model Hub.
Use prompts and input images to edit images with FLUX.2-klein-4B.
Getting started with image editing
To use image editing models, first set up your environment and authenticate using the OpenAI-compatible API endpoints.
Step 1: Retrieve available models
Check the model card for the feature image editing. Fetch the list of models from the API to retrieve the model name.
This query returns a JSON document listing each model's name, which you'll use to specify a model for image editing in the next step.
Step 2: Edit an image using a prompt and FLUX.2-klein-4B
To edit an image, send a prompt and an image URL to the /images/edits endpoint. The request must be sent as multipart/form-data. Note the following parameter restrictions for FLUX.2-klein-4B:
url: A public HTTP or HTTPS URL of the image to edit. Base64 data URLs (data:image/png;base64,...) are also accepted.prompt: Text description of the desired edit. Maximum 1000 characters.size: Width and height in"widthxheight"format. Both dimensions must be multiples of 16 and between 64 and 2048. Default:"1024x1024". Example values:"1024x1024","1536x1024","1024x1536","2048x2048","2048x1152".n: Number of images to generate. Defaults to1. Accepts values from1to10.output_format: File format of the generated image. Accepted values:jpg,jpeg,png,webp.mask_image: Optional. URL or base64 data URL of a mask image. Fully transparent areas (alpha=0) define where editing occurs. Must have the same dimensions as the input image.
Step 3: Extract and interpret the result
The returned JSON includes several key fields, most importantly:
data.[].b64_json: The edited image inbase64format. You can decode thisbase64string to obtain the edited image in the specified format (e.g., PNG, JPEG).
What you learned
In this guide, you learned how to:
Access available image editing models.
Use descriptive prompts and input images to edit images with FLUX.2-klein-4B.
For information on generating images from scratch, see Image Generation.
Last updated
Was this helpful?