This feature allows you to supply one or more reference images (including online image URLs) that contain a clear subject. Combined with a text prompt, the service generates a new image that preserves the subject’s key characteristics.
This is particularly useful for scenarios that require consistent visual identity, such as generating images of the same virtual character in different contexts.
import base64import requestsimport osurl = "https://api.minimax.io/v1/image_generation"api_key = os.environ["MINIMAX_API_KEY"]headers = {"Authorization": f"Bearer {api_key}"}payload = { "model": "image-01", "prompt": "A girl stands by the library window, gazing into the distance", "aspect_ratio": "16:9", "subject_reference": [ { "type": "character", "image_file": "https://cdn.hailuoai.com/prod/2025-08-12-17/video_cover/1754990600020238321-411603868533342214-cover.jpg", } ], "response_format": "base64",}response = requests.post(url, headers=headers, json=payload)response.raise_for_status()images = response.json()["data"]["image_base64"]for i in range(len(images)): with open(f"output-{i}.jpeg", "wb") as f: f.write(base64.b64decode(images[i]))