Skip to content

Prompts Endpoints

Prompts API endpoints.


Overview

Method Endpoint Description
POST /api/v1/prompts/create-editing-prompt Create Editing Prompt
POST /api/v1/prompts/create-for-generation Create Prompt For Generation

API Reference

Sartiq Backend Server - Prompts 0.1.0

prompts


POST /api/v1/prompts/create-for-generation

Create Prompt For Generation

Description

Generate an optimized prompt directly from GenerationCreate data.

This endpoint takes a GenerationCreate instance and enriches it with data from the database if entity IDs are provided but descriptions are missing. It then builds a prompt for it.

Args: session: The database session current_user: The current authenticated user generation_data: A GenerationCreate instance with prompt data prompt_builder: The prompt builder instance

Returns: A dictionary with AI-crafted prompts for the specified shot type(s)

Input parameters

Parameter In Type Default Nullable Description
OAuth2PasswordBearer header string N/A No

Request body

{
    "batch_size": 0,
    "negative_prompt": null,
    "subject_id": null,
    "subject_slug": null,
    "product_id": null,
    "product_slug": null,
    "product_image": null,
    "product_lora_weight": 10.12,
    "subject_lora_weight": 10.12,
    "product2_id": null,
    "product2_slug": null,
    "product2_image": null,
    "product2_lora_weight": 10.12,
    "style_id": null,
    "style_slug": null,
    "style_lora_weight": 10.12,
    "width": null,
    "height": null,
    "steps": 0,
    "seed": null,
    "refine": true,
    "scale_factor": null,
    "target_width": null,
    "target_height": null,
    "lighting": null,
    "framing": null,
    "perspective": null,
    "background": null,
    "tone": null,
    "pose": null,
    "extra_prompt": null,
    "generated_prompt": null,
    "auto_generate_prompt": true,
    "generation_type": null,
    "generation_strategy": null,
    "tool": null,
    "shot_type_string": null,
    "shot_type": null,
    "shot_type_id": null,
    "pose_preset_id": null,
    "subject_description": null,
    "product_description": null,
    "product2_description": null,
    "style_description": null,
    "subject_lora_enabled": true,
    "product_lora_enabled": true,
    "product2_lora_enabled": true,
    "style_lora_enabled": true,
    "subject_lora_trigger": null,
    "product_lora_trigger": null,
    "product2_lora_trigger": null,
    "style_lora_trigger": null,
    "subject_gender": null,
    "product_gender": null,
    "status": null,
    "garment_placement_base_image_url": null,
    "reference_images_paths": [
        "string"
    ],
    "autogenerated": true,
    "config": null,
    "reference_image_strength": null,
    "generative_models_id": null,
    "organization_id": null
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the request body
{
    "properties": {
        "batch_size": {
            "type": "integer",
            "title": "Batch Size",
            "default": 4
        },
        "negative_prompt": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Negative Prompt"
        },
        "subject_id": {
            "anyOf": [
                {
                    "type": "string",
                    "format": "uuid"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Subject Id"
        },
        "subject_slug": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Subject Slug"
        },
        "product_id": {
            "anyOf": [
                {
                    "type": "string",
                    "format": "uuid"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Product Id"
        },
        "product_slug": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Product Slug"
        },
        "product_image": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Product Image"
        },
        "product_lora_weight": {
            "type": "number",
            "title": "Product Lora Weight",
            "default": 0.9
        },
        "subject_lora_weight": {
            "type": "number",
            "title": "Subject Lora Weight",
            "default": 1.0
        },
        "product2_id": {
            "anyOf": [
                {
                    "type": "string",
                    "format": "uuid"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Product2 Id"
        },
        "product2_slug": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Product2 Slug"
        },
        "product2_image": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Product2 Image"
        },
        "product2_lora_weight": {
            "type": "number",
            "title": "Product2 Lora Weight",
            "default": 0.8
        },
        "style_id": {
            "anyOf": [
                {
                    "type": "string",
                    "format": "uuid"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Style Id"
        },
        "style_slug": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Style Slug"
        },
        "style_lora_weight": {
            "type": "number",
            "title": "Style Lora Weight",
            "default": 0.7
        },
        "width": {
            "anyOf": [
                {
                    "type": "integer"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Width"
        },
        "height": {
            "anyOf": [
                {
                    "type": "integer"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Height"
        },
        "steps": {
            "type": "integer",
            "title": "Steps",
            "default": 20
        },
        "seed": {
            "anyOf": [
                {
                    "type": "integer"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Seed"
        },
        "refine": {
            "type": "boolean",
            "title": "Refine",
            "default": false
        },
        "scale_factor": {
            "anyOf": [
                {
                    "type": "number"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Scale Factor"
        },
        "target_width": {
            "anyOf": [
                {
                    "type": "integer"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Target Width"
        },
        "target_height": {
            "anyOf": [
                {
                    "type": "integer"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Target Height"
        },
        "lighting": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Lighting"
        },
        "framing": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Framing"
        },
        "perspective": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Perspective"
        },
        "background": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Background"
        },
        "tone": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Tone"
        },
        "pose": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Pose"
        },
        "extra_prompt": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Extra Prompt"
        },
        "generated_prompt": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Generated Prompt"
        },
        "auto_generate_prompt": {
            "type": "boolean",
            "title": "Auto Generate Prompt",
            "default": true
        },
        "generation_type": {
            "anyOf": [
                {
                    "$ref": "#/components/schemas/GenerationType"
                },
                {
                    "type": "null"
                }
            ],
            "default": "BASE"
        },
        "generation_strategy": {
            "anyOf": [
                {
                    "$ref": "#/components/schemas/GenerationStrategy"
                },
                {
                    "type": "null"
                }
            ],
            "default": "GENERATE"
        },
        "tool": {
            "anyOf": [
                {
                    "$ref": "#/components/schemas/GenerationTool"
                },
                {
                    "type": "null"
                }
            ]
        },
        "shot_type_string": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Shot Type String"
        },
        "shot_type": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Shot Type"
        },
        "shot_type_id": {
            "anyOf": [
                {
                    "type": "string",
                    "format": "uuid"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Shot Type Id"
        },
        "pose_preset_id": {
            "anyOf": [
                {
                    "type": "string",
                    "format": "uuid"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Pose Preset Id"
        },
        "subject_description": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Subject Description"
        },
        "product_description": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Product Description"
        },
        "product2_description": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Product2 Description"
        },
        "style_description": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Style Description"
        },
        "subject_lora_enabled": {
            "type": "boolean",
            "title": "Subject Lora Enabled",
            "default": true
        },
        "product_lora_enabled": {
            "type": "boolean",
            "title": "Product Lora Enabled",
            "default": false
        },
        "product2_lora_enabled": {
            "type": "boolean",
            "title": "Product2 Lora Enabled",
            "default": false
        },
        "style_lora_enabled": {
            "type": "boolean",
            "title": "Style Lora Enabled",
            "default": false
        },
        "subject_lora_trigger": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Subject Lora Trigger"
        },
        "product_lora_trigger": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Product Lora Trigger"
        },
        "product2_lora_trigger": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Product2 Lora Trigger"
        },
        "style_lora_trigger": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Style Lora Trigger"
        },
        "subject_gender": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Subject Gender"
        },
        "product_gender": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Product Gender"
        },
        "status": {
            "anyOf": [
                {
                    "$ref": "#/components/schemas/GenerationStatus"
                },
                {
                    "type": "null"
                }
            ]
        },
        "garment_placement_base_image_url": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Garment Placement Base Image Url"
        },
        "reference_images_paths": {
            "items": {
                "type": "string"
            },
            "type": "array",
            "title": "Reference Images Paths"
        },
        "autogenerated": {
            "type": "boolean",
            "title": "Autogenerated",
            "default": false
        },
        "config": {
            "anyOf": [
                {
                    "additionalProperties": true,
                    "type": "object"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Config"
        },
        "reference_image_strength": {
            "anyOf": [
                {
                    "type": "number",
                    "maximum": 100.0,
                    "minimum": 0.0
                },
                {
                    "type": "null"
                }
            ],
            "title": "Reference Image Strength",
            "description": "Influence of the reference image on generation (0-100)"
        },
        "generative_models_id": {
            "anyOf": [
                {
                    "type": "string",
                    "format": "uuid"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Generative Models Id"
        },
        "organization_id": {
            "anyOf": [
                {
                    "type": "string",
                    "format": "uuid"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Organization Id",
            "description": "Organization this generation belongs to"
        }
    },
    "type": "object",
    "title": "GenerationCreate",
    "description": "Schema for creating a new generation."
}

Responses

Schema of the response body
{
    "additionalProperties": true,
    "type": "object",
    "title": "Response Create Prompt For Generation"
}

{
    "detail": [
        {
            "loc": [
                null
            ],
            "msg": "string",
            "type": "string",
            "input": null,
            "ctx": {}
        }
    ]
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "detail": {
            "items": {
                "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
        }
    },
    "type": "object",
    "title": "HTTPValidationError"
}

POST /api/v1/prompts/create-editing-prompt

Create Editing Prompt

Description

Generate an optimized prompt for garment placement strategy (editing) generations.

This endpoint uses the Gemini garment swap prompt builder to create prompts specifically designed for the Kontext garment placement strategy. It analyzes a base image (model wearing a garment) and a reference image (garment to be placed) to generate appropriate editing prompts.

The images can be provided in multiple formats: - Base64 data URLs (e.g., "data:image/jpeg;base64,...") - HTTP/HTTPS URLs - Local file paths (relative to DATA_FILES_DIR or absolute)

Args: current_user: The current authenticated user request: Parameters containing base_image and reference_image

Returns: A dictionary containing the generated prompt for garment placement

Raises: HTTPException: If image processing fails

Input parameters

Parameter In Type Default Nullable Description
OAuth2PasswordBearer header string N/A No

Request body

{
    "base_image": "string",
    "reference_image": "string"
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the request body
{
    "properties": {
        "base_image": {
            "type": "string",
            "title": "Base Image",
            "description": "Base image (model wearing garment) - can be base64 data URL, HTTP URL, or local path"
        },
        "reference_image": {
            "type": "string",
            "title": "Reference Image",
            "description": "Reference garment image - can be base64 data URL, HTTP URL, or local path"
        }
    },
    "type": "object",
    "required": [
        "base_image",
        "reference_image"
    ],
    "title": "CreateEditingPromptRequest",
    "description": "Request model for the /create-editing-prompt endpoint.\n\nThis model defines the parameters for generating editing prompts for garment placement strategy."
}

Responses

Schema of the response body
{
    "additionalProperties": true,
    "type": "object",
    "title": "Response Create Editing Prompt"
}

{
    "detail": [
        {
            "loc": [
                null
            ],
            "msg": "string",
            "type": "string",
            "input": null,
            "ctx": {}
        }
    ]
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "detail": {
            "items": {
                "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
        }
    },
    "type": "object",
    "title": "HTTPValidationError"
}

POST /api/v1/prompts/compose

Compose Prompt

Description

Compose a prompt by running the base system prompt through the builder pipeline.

Accepts optional entity IDs (shot_type_id, pose_id, etc.) in the request body. Each ID is resolved to its model and passed to the ordered builder chain.

Input parameters

Parameter In Type Default Nullable Description
OAuth2PasswordBearer header string N/A No

Request body

{
    "shot_type_id": null,
    "pose_id": null,
    "shooting_look_id": null
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the request body
{
    "properties": {
        "shot_type_id": {
            "anyOf": [
                {
                    "type": "string",
                    "format": "uuid"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Shot Type Id"
        },
        "pose_id": {
            "anyOf": [
                {
                    "type": "string",
                    "format": "uuid"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Pose Id"
        },
        "shooting_look_id": {
            "anyOf": [
                {
                    "type": "string",
                    "format": "uuid"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Shooting Look Id"
        }
    },
    "type": "object",
    "title": "PromptContextRequest",
    "description": "Request schema mirroring PromptContext fields as optional IDs.\n\nWhen new fields are added to PromptContext, add the corresponding\nID field here and update the resolver in deps.py."
}

Responses

{
    "prompt": "string"
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "prompt": {
            "type": "string",
            "title": "Prompt"
        }
    },
    "type": "object",
    "required": [
        "prompt"
    ],
    "title": "ComposedPromptResponse"
}

{
    "detail": [
        {
            "loc": [
                null
            ],
            "msg": "string",
            "type": "string",
            "input": null,
            "ctx": {}
        }
    ]
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "detail": {
            "items": {
                "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
        }
    },
    "type": "object",
    "title": "HTTPValidationError"
}

Schemas

ComposedPromptResponse

Name Type Description
prompt string

CreateEditingPromptRequest

Name Type Description
base_image string Base image (model wearing garment) - can be base64 data URL, HTTP URL, or local path
reference_image string Reference garment image - can be base64 data URL, HTTP URL, or local path

GenerationCreate

Name Type Description
auto_generate_prompt boolean
autogenerated boolean
background
batch_size integer
config
extra_prompt
framing
garment_placement_base_image_url
generated_prompt
generation_strategy
generation_type
generative_models_id
height
lighting
negative_prompt
organization_id Organization this generation belongs to
perspective
pose
pose_preset_id
product2_description
product2_id
product2_image
product2_lora_enabled boolean
product2_lora_trigger
product2_lora_weight number
product2_slug
product_description
product_gender
product_id
product_image
product_lora_enabled boolean
product_lora_trigger
product_lora_weight number
product_slug
reference_image_strength Influence of the reference image on generation (0-100)
reference_images_paths Array<string>
refine boolean
scale_factor
seed
shot_type
shot_type_id
shot_type_string
status
steps integer
style_description
style_id
style_lora_enabled boolean
style_lora_trigger
style_lora_weight number
style_slug
subject_description
subject_gender
subject_id
subject_lora_enabled boolean
subject_lora_trigger
subject_lora_weight number
subject_slug
target_height
target_width
tone
tool
width

GenerationStatus

Type: string

GenerationStrategy

Type: string

GenerationTool

Type: string

GenerationType

Type: string

HTTPValidationError

Name Type Description
detail Array<ValidationError>

PromptContextRequest

Name Type Description
pose_id
shooting_look_id
shot_type_id

ValidationError

Name Type Description
ctx
input
loc Array<>
msg string
type string

Security schemes

Name Type Scheme Description
OAuth2PasswordBearer oauth2