Custom Model Training

Train a custom model on your own images, then use it to generate new images in your unique style.

Overview

Custom model training lets you fine-tune an Ideogram model on your own dataset of images. Once training completes, you can use the model with the Generate endpoint by passing its custom_model_uri.

The workflow has four steps:

  1. Create a dataset to hold your training images.
  2. Upload images (and optional captions) to the dataset.
  3. Start training to kick off the model training job.
  4. Generate images using your trained model.

Step 1: Create a Dataset

1import requests
2
3response = requests.post(
4 "https://api.ideogram.ai/datasets",
5 headers={"Api-Key": "<apiKey>"},
6 json={"name": "My Training Dataset"}
7)
8dataset = response.json()
9dataset_id = dataset["dataset_id"]
10print(f"Created dataset: {dataset_id}")

Step 2: Upload Training Images

Upload your training images to the dataset. You can upload individual images (JPEG, PNG, WebP), optional .txt caption sidecar files, or ZIP archives containing both.

  • A dataset needs at least 10 images to start training.
  • A dataset can hold up to 100 images.
  • Caption files are matched by filename stem (e.g. sunset.txt captions sunset.jpg).
1import requests
2import glob
3
4# Upload individual images
5files = [("files", open(f, "rb")) for f in glob.glob("training_images/*.jpg")]
6
7response = requests.post(
8 f"https://api.ideogram.ai/datasets/{dataset_id}/upload_assets",
9 headers={"Api-Key": "<apiKey>"},
10 files=files
11)
12result = response.json()
13print(f"Uploaded {result['success_count']}/{result['total_count']} images")

You can also upload a ZIP file containing images and captions together, which is convenient for larger datasets.

Step 3: Train the Model

Once your dataset has enough images, start training by giving your model a name.

1import requests
2
3response = requests.post(
4 f"https://api.ideogram.ai/datasets/{dataset_id}/train_model",
5 headers={"Api-Key": "<apiKey>"},
6 json={"model_name": "my-custom-model"}
7)
8training = response.json()
9model_id = training["model_id"]
10print(f"Training started: {training['training_status']}")

Checking Training Status

Poll the model details endpoint to check when training completes.

1import requests
2import time
3
4while True:
5 response = requests.get(
6 f"https://api.ideogram.ai/models/{model_id}",
7 headers={"Api-Key": "<apiKey>"}
8 )
9 model = response.json()["model"]
10 print(f"Status: {model['status']}")
11
12 if model["status"] == "COMPLETED":
13 print(f"Model ready! URI: {model.get('custom_model_uri')}")
14 break
15 elif model["status"] == "ERRORED":
16 print("Training failed.")
17 break
18
19 time.sleep(60)

Step 4: Generate with Your Model

Once training is complete and is_available_for_generation is true, use the custom_model_uri from the model details to generate images.

1import requests
2
3response = requests.post(
4 "https://api.ideogram.ai/v1/ideogram-v3/generate",
5 headers={"Api-Key": "<apiKey>"},
6 data={
7 "prompt": "A photo in my custom style",
8 "custom_model_uri": "model/my-custom-model/version/1",
9 "rendering_speed": "DEFAULT"
10 }
11)
12result = response.json()
13if response.status_code == 200:
14 print(result["data"][0]["url"])

Tips for Better Results

  • Use high-quality images that clearly represent the style or subject you want the model to learn.
  • Add captions to guide the model on what each image represents. Captions are optional!
  • Use consistent subjects across your training images for best results with style transfer.