PhotoGPT Developers

Create, list, inspect, and delete PhotoGPT models.

Models

Models are the core resources used for training and image generation. A model starts as metadata, can receive training images, can be trained, and can then be used by generation requests.

Typical statuses are new, training, ready, and deleted.

Model lifecycle

  1. Create or update a model with POST /models.
  2. Upload modelInput images for the model.
  3. Trigger training after the model has enough input images.
  4. Poll GET /models/{modelID} about every 5 minutes until the model status is ready.
  5. Use the model ID with image generation requests.

Training normally takes 20 to 25 minutes. Avoid very frequent polling; a 5-minute interval is a good default for integrations.

Create or update a model

Use POST /models to create a new model. Include id when updating an existing model.

FieldNotes
nameHuman-readable model name.
ageNumeric age metadata.
genderMale or Female.
ethnicityOptional descriptive metadata used by model setup.
eyeColorOptional descriptive metadata used by model setup.
idInclude only when updating an existing model.
userIDPresent in the schema, but normally inferred from your key.
const payload = {
  name: 'MyModel',
  age: 25,
  gender: 'Male',
  ethnicity: 'white',
  eyeColor: 'blue',
}

const response = await fetch(`${BASE_URL}/models`, {
  method: 'POST',
  headers: {
    ...headers,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(payload),
})

if (!response.ok) {
  throw new Error(await response.text())
}

const body = await response.json()
const model = body.result
payload = {
    "name": "MyModel",
    "age": 25,
    "gender": "Male",
    "ethnicity": "white",
    "eyeColor": "blue",
}

response = requests.post(f"{BASE_URL}/models", headers=headers, json=payload)
response.raise_for_status()

model = response.json()["result"]

Save the returned model ID; it is used for image uploads, training, and trained-model generation.

List models

const response = await fetch(`${BASE_URL}/models`, {
  headers,
})

if (!response.ok) {
  throw new Error(await response.text())
}

const body = await response.json()
const models = body.result
response = requests.get(f"{BASE_URL}/models", headers=headers)
response.raise_for_status()

models = response.json()["result"]

Get a model

const modelId = '<MODEL_ID>'

const response = await fetch(`${BASE_URL}/models/${modelId}`, {
  headers,
})

if (!response.ok) {
  throw new Error(await response.text())
}

const body = await response.json()
const model = body.result
model_id = "<MODEL_ID>"

response = requests.get(f"{BASE_URL}/models/{model_id}", headers=headers)
response.raise_for_status()

model = response.json()["result"]

Check the model status before starting trained-model generation. A trained model should be ready.

Delete a model

Deleting a model also deletes associated images according to the API reference.

const modelId = '<MODEL_ID>'

const response = await fetch(`${BASE_URL}/models/${modelId}`, {
  method: 'DELETE',
  headers,
})

if (!response.ok) {
  throw new Error(await response.text())
}
model_id = "<MODEL_ID>"

response = requests.delete(f"{BASE_URL}/models/{model_id}", headers=headers)
response.raise_for_status()

API reference

On this page