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
- Create or update a model with
POST /models. - Upload
modelInputimages for the model. - Trigger training after the model has enough input images.
- Poll
GET /models/{modelID}about every 5 minutes until the model status isready. - 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.
| Field | Notes |
|---|---|
name | Human-readable model name. |
age | Numeric age metadata. |
gender | Male or Female. |
ethnicity | Optional descriptive metadata used by model setup. |
eyeColor | Optional descriptive metadata used by model setup. |
id | Include only when updating an existing model. |
userID | Present 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.resultpayload = {
"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.resultresponse = 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.resultmodel_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()