# Tailored Generation API Reference

Tailored Generation provides capabilities to generate visuals (photos, illustrations, vectors) 
that preserve and faithfully reproduce specific IP elements or guidelines, ensuring consistency 
across all generated outputs.

The Tailored Generation APIs allow you to manage and train tailored models that maintain the 
integrity of your visual IP. You can train models through our Console or implement training 
directly via API.

**Fully Automated Training Mode**
Bria supports users in training high-quality finetuned models without the guesswork. Based on the selected IP type & dataset, Bria automatically selects the right training parameters. 
This means that the user only needs to spend time curating their dataset.

**Advanced Customization and Access:** Bria offers 2 types of advanced training customization: Expert training mode and source-code & weights.
  - **Expert training mode** is for LoRa Finetune experts and provides the ability to finetune training parameters and upload larger training datasets.
  - **Source-code & Weights** is for developers seeking deeper customization and access to Bria's source-available GenAI models via [Hugging Face](https://huggingface.co/briaai).  

All methods allow full control over fine-tuning, pipeline creation, and integration into proprietary workflows—empowering AI teams to develop and optimize their own generative AI solutions.

The Tailored Generation Training API provides a set of endpoints to manage the entire lifecycle 
of a tailored generation project:

1. **Project Management**: Create and manage projects that define IP characteristics:
  - **Create and Retrieve Projects**: Use the `/projects` endpoints to create a new project or 
    retrieve existing projects that belong to your organization.
  - **Define IP Type**: Specify the IP type (e.g., multi_object_set, defined_character, 
    stylized_scene) and medium.
  - **Manage Project Details**: Use the `/projects/{id}` endpoints to update or delete 
    specific projects.

2. **Dataset Management**: Organize and refine datasets within your projects:
  - **Create and Retrieve Datasets**: Use the `/datasets` endpoints to create new datasets or 
    retrieve existing ones.
  - **Generate a Visual Schema**
    - Use `/tailored-gen/generate_visual_schema` to create a structured visual schema using 5-10 sample images.
  - **Refine Structured Data**
    - Use `/tailored-gen/refine_structured_prompt` to iterate on your **Visual Schema** or **Image Captions** using natural language instructions.
    - *Example:* You can send your generated schema with the instruction "Character's name is Lucy" to improve the training metadata programmatically.
  - **Upload and Manage Images**: 
    - **Basic upload**: Use `/datasets/{dataset_id}/images` to upload up to 200 images individually.
    - **Bulk upload**: Use `/datasets/{dataset_id}/images/bulk` to upload zip files with >200 high-quality images (Advanced).
  - **Clone Datasets**: Create variations of existing datasets using the clone functionality.

3. **Model Management**: Train and optimize tailored models based on your datasets:
  - **Create and Retrieve Models**: Use the `/models` endpoints to create new models or list 
    existing ones.
  - **Choose training mode**: Select between Fully automated mode (automatic training based on Bria's recipes) and Expert mode (for training parameter tweaking).
  - **Monitor and Control**: Manage the model lifecycle, including training start/stop, 
    status monitoring, and version control over the training parameters.

4. **Generation Capabilities**:
  - **Image Generation**: Use `/image/generate/tailored` for text-to-image generation.
  - **Structured Prompting**: Use `/structured_prompt/generate/tailored` to create structured prompts via VLM before generation.
  - **Video Generation**: Use `/video/generate/tailored/image-to-video` to animate tailored images.

### **Training Process**

To train a tailored model:

1. **Create a Project**: Use the `/projects` endpoint to define your IP type and medium.
2. **Create a Dataset**: Use the `/datasets` endpoint to create a dataset within your project.
3. **Define Visual Identity**:
   - **Step A (Generate):** Call `/tailored-gen/generate_visual_schema`, sampling 5-10 images from your input set.
   - **Step B (Refine - Optional):** Call `/tailored-gen/refine_structured_prompt` with the generated schema and instructions to tweak the definitions (e.g., "Remove references to blue background").
   - **Step C (Apply):** Update the dataset with the final schema using `/datasets/{dataset_id}`.
4. **Upload Images**: Upload images using the `/datasets/{dataset_id}/images` or `/datasets/{dataset_id}/images/bulk` endpoints 
  (minimum resolution: 1024x1024px). note: if you upload images before updating the visual schema, use the Regenerate All Captions endpoint to caption the images.
5. **Prepare Dataset**: Review auto-generated captions (you can also use `refine_structured_prompt` to fix specific image captions) and update the dataset status to 'completed'.
6. **Create Model**: Use the `/models` endpoint to create a model, which requires a training mode.
7. **Start Training**: Initiate training via the `/models/{id}/start_training` endpoint. 
  Training typically takes 4-6 hours.
8. **Monitor Progress**: Check the training status using the `/models/{id}` endpoint until 
  training is 'Completed'.
9. **Generate Images**: 
  - Use `v2/image/generate/tailored` for text-to-image generation.



## Servers

```
https://engine.prod.bria-api.com/v2/
```

## Download OpenAPI description

 - [Tailored Generation API Reference](https://docs.bria.ai/_bundle/tailored-generation.yaml)

## Project

 - [POST /tailored-gen/projects](https://docs.bria.ai/tailored-generation/project/create-project.md): Create a new project within the organization. The following IP types are supported: **Defined Character** A specific character that maintains consistent identity and unique traits while being reproduc
 - [GET /tailored-gen/projects](https://docs.bria.ai/tailored-generation/project/get-projects.md): Retrieve all projects within the organization. If there are no projects, returns an empty array.
 - [GET /tailored-gen/projects/{project_id}](https://docs.bria.ai/tailored-generation/project/get-project-by-id.md): Retrieve full project information.
 - [PUT /tailored-gen/projects/{project_id}](https://docs.bria.ai/tailored-generation/project/update-project.md): Update a specific project.
 - [DELETE /tailored-gen/projects/{project_id}](https://docs.bria.ai/tailored-generation/project/delete-project.md): Permanently delete a project and all its associated resources, including all datasets, images, and models. This action cannot be undone. Training models must be stopped before deletion.
## Dataset

 - [POST /tailored-gen/datasets](https://docs.bria.ai/tailored-generation/dataset/create-dataset.md): Create a new dataset. Datasets use JSON structured data (`visual_schema`) for training. You must generate a visual schema via `/generate_visual_schema` before completing the dataset. **Completion Requ
 - [GET /tailored-gen/datasets](https://docs.bria.ai/tailored-generation/dataset/get-datasets.md): Retrieve a list of all datasets. If there are no datasets, returns an empty array.
 - [GET /tailored-gen/projects/{project_id}/datasets](https://docs.bria.ai/tailored-generation/dataset/get-datasets-by-project.md): Retrieve all datasets for a specific project.
 - [GET /tailored-gen/datasets/{dataset_id}](https://docs.bria.ai/tailored-generation/dataset/get-dataset-by-id.md): Retrieve a specific dataset including its images.
 - [PUT /tailored-gen/datasets/{dataset_id}](https://docs.bria.ai/tailored-generation/dataset/update-dataset.md): Update a dataset. You can update `visual_schema` only when the dataset status is `draft`. **Completion Requirements:** To set `status` to `completed`, the dataset must have at least **5 images**.
 - [DELETE /tailored-gen/datasets/{dataset_id}](https://docs.bria.ai/tailored-generation/dataset/delete-dataset.md): Delete a specific dataset. Deletes all associated images.
 - [POST /tailored-gen/datasets/{dataset_id}/clone](https://docs.bria.ai/tailored-generation/dataset/clone-dataset.md): Create a new draft dataset based on an existing one. This is useful when you would like to use the same dataset again for another training, but with some modification (create a variation). The cloned
 - [POST /tailored-gen/datasets/{dataset_id}/images](https://docs.bria.ai/tailored-generation/dataset/upload-image.md): Upload a new image to a dataset. **Image Requirements:** - Recommended minimum resolution: 1024x1024 pixels for best quality - By default, smaller images (down to 256x256) will be automatically upsc
 - [GET /tailored-gen/datasets/{dataset_id}/images](https://docs.bria.ai/tailored-generation/dataset/get-images.md): Retrieve all images in a specific dataset.
 - [PUT /tailored-gen/datasets/{dataset_id}/images](https://docs.bria.ai/tailored-generation/dataset/regenerate-all-captions.md): Regenerate captions for all images in a dataset. This is crucial after updating the visual schema, to ensure full compatibility with the new schema. This is an asynchronous operation. Once called, pol
 - [POST /tailored-gen/datasets/{dataset_id}/images/bulk-upload](https://docs.bria.ai/tailored-generation/dataset/bulk-upload-images.md): Efficiently upload a large volume of images (up to 5000) from a ZIP file to an advanced dataset. **Upload without Schema:** You can initiate a bulk upload even if `visual_schema` is null. Images will
 - [GET /tailored-gen/datasets/{dataset_id}/images/{image_id}](https://docs.bria.ai/tailored-generation/dataset/get-image.md): Retrieve full image information.
 - [PUT /tailored-gen/datasets/{dataset_id}/images/{image_id}](https://docs.bria.ai/tailored-generation/dataset/update-image-caption.md): Update the caption of a specific image. Two mutually exclusive options: 1. **Provide a new caption**: Use the `caption` parameter (sets `caption_source` to "manual"). The caption must be a string cont
 - [DELETE /tailored-gen/datasets/{dataset_id}/images/{image_id}](https://docs.bria.ai/tailored-generation/dataset/delete-image.md): Permanently remove an image from a dataset. Cannot delete images from completed datasets.
 - [GET /tailored-gen/datasets/{dataset_id}/images/bulk-upload/status](https://docs.bria.ai/tailored-generation/dataset/get-bulk-upload-status.md): Retrieve the status and progress of a bulk image upload job.
 - [POST /tailored-gen/generate_visual_schema](https://docs.bria.ai/tailored-generation/dataset/generate-visual-schema.md): Generates a structured JSON visual schema (backbone) based on the provided sample images. The visual schema represents mutual characteristics (style, IP, colors, etc.) across training images and is us
 - [POST /tailored-gen/refine_structured_prompt](https://docs.bria.ai/tailored-generation/dataset/refine-json.md): Refines a Structured Prompt object (such as a Visual Schema or an Image Caption) based on user instructions. **Access Control & Validation:** * Requires a valid `dataset_id` to verify ownership. * The
 - [GET /datasets/{dataset_id}/download](https://docs.bria.ai/tailored-generation/dataset/download-dataset.md): Download an advanced dataset. Returns a pre-signed URL for downloading the dataset.
## Model

 - [POST /tailored-gen/models](https://docs.bria.ai/tailored-generation/model/create-model.md): Create a new model.
 - [GET /tailored-gen/models](https://docs.bria.ai/tailored-generation/model/get-models.md): Retrieve a list of models. If there are no models, an empty array is returned.
 - [GET /tailored-gen/projects/{project_id}/models](https://docs.bria.ai/tailored-generation/model/get-models-by-project.md): Retrieve all models for a project.
 - [GET /tailored-gen/models/{model_id}](https://docs.bria.ai/tailored-generation/model/get-model.md): Retrieve full model information.
 - [PUT /tailored-gen/models/{model_id}](https://docs.bria.ai/tailored-generation/model/update-model.md): Update a model's name and description.
 - [DELETE /tailored-gen/models/{model_id}](https://docs.bria.ai/tailored-generation/model/delete-model.md): Delete a specific model.
 - [POST /tailored-gen/models/{model_id}/start_training](https://docs.bria.ai/tailored-generation/model/start-training.md): Start model training. Training duration is typically 2-4 hours. The associated dataset must have a status of 'completed' before training can begin. **Default Training Parameters:** If parameters are n
 - [POST /tailored-gen/models/{model_id}/stop_training](https://docs.bria.ai/tailored-generation/model/stop-training.md): Stop an ongoing model training process. Once stopped, training cannot be resumed - a new model would need to be created and trained.
 - [GET /tailored-gen/models/{model_id}/checkpoints](https://docs.bria.ai/tailored-generation/model/list-checkpoints.md): Retrieve a list of all available checkpoints for a model. Only available for models trained in `expert` mode.
 - [GET /tailored-gen/models/{model_id}/checkpoints/{checkpoint_step}](https://docs.bria.ai/tailored-generation/model/get-checkpoint.md): Retrieve details for a specific model checkpoint.
 - [DELETE /tailored-gen/models/{model_id}/checkpoints/{checkpoint_step}](https://docs.bria.ai/tailored-generation/model/delete-checkpoint.md): Permanently delete a specific model checkpoint. Cannot delete the checkpoint currently selected for inference.
 - [GET /tailored-gen/models/{model_id}/download](https://docs.bria.ai/tailored-generation/model/download-tailored-model.md): Download a trained tailored generation model after completing the training process. The response includes a pre-signed URL for downloading the model and details about the base model used. To use the t
## Image Generation

 - [POST /image/generate/tailored](https://docs.bria.ai/tailored-generation/image-generation/image-generate-tailored.md): **Description** Generates a new image using a tailored model. This endpoint translates your input (`prompt` and/or `structured_prompt`) into a structured JSON prompt using the state-of-the-art **Gemin
 - [POST /structured_prompt/generate/tailored](https://docs.bria.ai/tailored-generation/image-generation/structured-prompt-generate-tailored.md): **Description** Creates a new detailed, machine-readable structured prompt in JSON format or refines an existing one using text inputs and a tailored model's visual schema (backbone). This endpoint us
## Video Generation

 - [POST /video/generate/tailored/image-to-video](https://docs.bria.ai/tailored-generation/video-generation/generate-video-from-tailored-image.md): (Beta) Initiates an asynchronous job to generate a 5-second MP4 video file animating a source image created by a tailored model. **Asynchronous Requests and the Status Service** Bria API endpoints pro
