Skip to content

create_update

router module-attribute

router = APIRouter(
    responses={404: {"description": "Not Found"}},
    tags=["v1_create_update"],
)

delete_model_route_subpath module-attribute

delete_model_route_subpath = (
    f"/{{model_category_name}}/{{model_name}}"
)

/{model_category_name}/{model_name}

image_generation_route_subpath module-attribute

image_generation_route_subpath = f'/{image_generation}'

/image_generation

text_generation_route_subpath module-attribute

text_generation_route_subpath = f'/{text_generation}'

/text_generation

clip_route_subpath module-attribute

clip_route_subpath = f'/{clip}'

/clip

create_model_blip_route_subpath module-attribute

create_model_blip_route_subpath = f'/{blip}'

/blip

codeformer_route_subpath module-attribute

codeformer_route_subpath = f'/{codeformer}'

/codeformer

controlnet_route_subpath module-attribute

controlnet_route_subpath = f'/{controlnet}'

/controlnet

esrgan_route_subpath module-attribute

esrgan_route_subpath = f'/{esrgan}'

/esrgan

gfpgan_route_subpath module-attribute

gfpgan_route_subpath = f'/{gfpgan}'

/gfpgan

safety_checker_route_subpath module-attribute

safety_checker_route_subpath = f'/{safety_checker}'

/safety_checker

miscellaneous_route_subpath module-attribute

miscellaneous_route_subpath = f'/{miscellaneous}'

/miscellaneous

delete_legacy_model async

delete_legacy_model(
    model_category_name: MODEL_REFERENCE_CATEGORY,
    model_name: str,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse | Response

Delete a model from a legacy model reference category.

When pending queue is enabled, this enqueues the deletion and returns HTTP 202. When pending queue is disabled, this deletes the model immediately and returns HTTP 204.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.delete(
    delete_model_route_subpath,
    responses={
        204: {
            "description": "Model deleted successfully",
        },
        202: {
            "description": "Model deletion queued for approval",
            "model": PendingChangeRecord,
        },
        404: {"description": "Model not found"},
        503: {"description": "Service unavailable (not in legacy canonical mode)"},
    },
    summary="Delete a legacy model entry.",
    operation_id="delete_legacy_model",
    response_model=None,
)
async def delete_legacy_model(
    model_category_name: MODEL_REFERENCE_CATEGORY,
    model_name: str,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse | Response:
    """Delete a model from a legacy model reference category.

    When pending queue is enabled, this enqueues the deletion and returns HTTP 202.
    When pending queue is disabled, this deletes the model immediately and returns HTTP 204.
    """
    return await _delete_legacy_model(
        manager,
        model_category_name,
        model_name,
        apikey,
        route_name="delete_legacy_model",
    )

create_legacy_image_generation_model async

create_legacy_image_generation_model(
    new_model_record: LegacyStableDiffusionRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Create a new image generation model in legacy format.

The model name in the request body must not already exist in the image generation category.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.post(
    image_generation_route_subpath,
    status_code=status.HTTP_201_CREATED,
    responses={
        201: {
            "description": "Model created successfully",
        },
        202: {
            "description": "Model creation queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        409: {"description": "Model already exists"},
        422: {"description": "Validation error"},
    },
    summary="Create a new image generation model in legacy format",
    response_model=get_legacy_model_type(MODEL_REFERENCE_CATEGORY.image_generation),
    operation_id="create_legacy_image_generation_model",
)
async def create_legacy_image_generation_model(
    new_model_record: LegacyStableDiffusionRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Create a new image generation model in legacy format.

    The model name in the request body must not already exist in the image generation category.
    """
    model_name = new_model_record.name
    category = MODEL_REFERENCE_CATEGORY.image_generation

    return await _create_or_update_legacy_model(
        manager,
        category,
        model_name,
        new_model_record,
        Operation.create,
        apikey,
        route_name="create_legacy_image_generation_model",
    )

update_legacy_image_generation_model async

update_legacy_image_generation_model(
    new_model_record: LegacyStableDiffusionRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Update an existing image generation model in legacy format.

The model must already exist in the specified category. Use POST to create new models.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.put(
    image_generation_route_subpath,
    responses={
        200: {
            "description": "Model updated successfully",
        },
        202: {
            "description": "Model update queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        422: {"description": "Validation error"},
        503: {"description": "Service unavailable (not in legacy canonical mode)"},
    },
    response_model=LegacyStableDiffusionRecord,
    summary="Update an existing model in legacy format",
    description=(
        "Update an existing model or create if it doesn't exist (upsert) in legacy format.\n\n"
        "This endpoint is only available when canonical_format='LEGACY' in PRIMARY mode."
    ),
    operation_id="update_legacy_model",
)
async def update_legacy_image_generation_model(
    new_model_record: LegacyStableDiffusionRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Update an existing image generation model in legacy format.

    The model must already exist in the specified category. Use POST to create new models.
    """
    model_category_name = MODEL_REFERENCE_CATEGORY.image_generation
    model_name = new_model_record.name

    return await _create_or_update_legacy_model(
        manager,
        model_category_name,
        model_name,
        new_model_record,
        Operation.update,
        apikey,
        route_name="update_legacy_model",
    )

create_legacy_text_generation_model async

create_legacy_text_generation_model(
    new_model_record: LegacyTextGenerationRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Create a new text generation model in legacy format.

The model name in the request body must not already exist in the text generation category.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.post(
    text_generation_route_subpath,
    status_code=status.HTTP_201_CREATED,
    responses={
        201: {
            "description": "Model created successfully",
        },
        202: {
            "description": "Model creation queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        409: {"description": "Model already exists"},
        422: {"description": "Validation error"},
    },
    summary="Create a new text generation model in legacy format",
    response_model=get_legacy_model_type(MODEL_REFERENCE_CATEGORY.text_generation),
    operation_id="create_legacy_text_generation_model",
)
async def create_legacy_text_generation_model(
    new_model_record: LegacyTextGenerationRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Create a new text generation model in legacy format.

    The model name in the request body must not already exist in the text generation category.
    """
    model_name = new_model_record.name
    category = MODEL_REFERENCE_CATEGORY.text_generation

    return await _create_or_update_legacy_model(
        manager,
        category,
        model_name,
        new_model_record,
        Operation.create,
        apikey,
        route_name="create_legacy_text_generation_model",
    )

update_legacy_text_generation_model async

update_legacy_text_generation_model(
    new_model_record: LegacyTextGenerationRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Update an existing text generation model in legacy format.

The model must already exist in the specified category. Use POST to create new models.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.put(
    text_generation_route_subpath,
    responses={
        200: {
            "description": "Model updated successfully",
        },
        202: {
            "description": "Model update queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        422: {"description": "Validation error"},
        503: {"description": "Service unavailable (not in legacy canonical mode)"},
    },
    response_model=LegacyTextGenerationRecord,
    summary="Update an existing model in legacy format",
    description=(
        "Update an existing model or create if it doesn't exist (upsert) in legacy format.\n\n"
        "This endpoint is only available when canonical_format='LEGACY' in PRIMARY mode."
    ),
    operation_id="update_legacy_text_generation_model",
)
async def update_legacy_text_generation_model(
    new_model_record: LegacyTextGenerationRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Update an existing text generation model in legacy format.

    The model must already exist in the specified category. Use POST to create new models.
    """
    model_name = new_model_record.name
    model_category_name = MODEL_REFERENCE_CATEGORY.text_generation

    return await _create_or_update_legacy_model(
        manager,
        model_category_name,
        model_name,
        new_model_record,
        Operation.update,
        apikey,
        route_name="update_legacy_text_generation_model",
    )

create_legacy_clip_model async

create_legacy_clip_model(
    new_model_record: LegacyClipRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Create a new CLIP model in legacy format.

The model name in the request body must not already exist in the clip category.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.post(
    clip_route_subpath,
    status_code=status.HTTP_201_CREATED,
    responses={
        201: {
            "description": "Model created successfully",
        },
        202: {
            "description": "Model creation queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        409: {"description": "Model already exists (use PUT to update)"},
        422: {"description": "Validation error in request body"},
    },
    summary="Create a new clip model in legacy format",
    response_model=get_legacy_model_type(MODEL_REFERENCE_CATEGORY.clip),
    operation_id="create_legacy_clip_model",
)
async def create_legacy_clip_model(
    new_model_record: LegacyClipRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Create a new CLIP model in legacy format.

    The model name in the request body must not already exist in the clip category.
    """
    model_name = new_model_record.name
    category = MODEL_REFERENCE_CATEGORY.clip

    return await _create_or_update_legacy_model(
        manager,
        category,
        model_name,
        new_model_record,
        Operation.create,
        apikey,
        route_name="create_legacy_clip_model",
    )

update_legacy_clip_model async

update_legacy_clip_model(
    new_model_record: LegacyClipRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Update an existing CLIP model in legacy format.

The model must already exist in the specified category. Use POST to create new models.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.put(
    clip_route_subpath,
    responses={
        200: {
            "description": "Model updated successfully",
        },
        202: {
            "description": "Model update queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        422: {"description": "Validation error"},
        503: {"description": "Service unavailable (not in legacy canonical mode)"},
    },
    response_model=LegacyClipRecord,
    summary="Update an existing CLIP model in legacy format",
    description=(
        "Update an existing model or create if it doesn't exist (upsert) in legacy format.\n\n"
        "This endpoint is only available when canonical_format='LEGACY' in PRIMARY mode."
    ),
    operation_id="update_legacy_clip_model",
)
async def update_legacy_clip_model(
    new_model_record: LegacyClipRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Update an existing CLIP model in legacy format.

    The model must already exist in the specified category. Use POST to create new models.
    """
    model_name = new_model_record.name
    model_category_name = MODEL_REFERENCE_CATEGORY.clip

    return await _create_or_update_legacy_model(
        manager,
        model_category_name,
        model_name,
        new_model_record,
        Operation.update,
        apikey,
        route_name="update_legacy_clip_model",
    )

create_legacy_blip_model async

create_legacy_blip_model(
    new_model_record: LegacyBlipRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Create a new BLIP model in legacy format.

The model name in the request body must not already exist in the blip category.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.post(
    create_model_blip_route_subpath,
    status_code=status.HTTP_201_CREATED,
    responses={
        201: {
            "description": "Model created successfully",
        },
        202: {
            "description": "Model creation queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        409: {"description": "Model already exists (use PUT to update)"},
        422: {"description": "Validation error in request body"},
    },
    summary="Create a new BLIP model in legacy format",
    response_model=get_legacy_model_type(MODEL_REFERENCE_CATEGORY.blip),
    operation_id="create_legacy_blip_model",
)
async def create_legacy_blip_model(
    new_model_record: LegacyBlipRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Create a new BLIP model in legacy format.

    The model name in the request body must not already exist in the blip category.
    """
    model_name = new_model_record.name
    category = MODEL_REFERENCE_CATEGORY.blip

    return await _create_or_update_legacy_model(
        manager,
        category,
        model_name,
        new_model_record,
        Operation.create,
        apikey,
        route_name="create_legacy_blip_model",
    )

update_legacy_blip_model async

update_legacy_blip_model(
    new_model_record: LegacyBlipRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Update an existing BLIP model in legacy format.

The model must already exist in the specified category. Use POST to create new models.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.put(
    create_model_blip_route_subpath,
    responses={
        200: {
            "description": "Model updated successfully",
        },
        202: {
            "description": "Model update queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        422: {"description": "Validation error"},
        503: {"description": "Service unavailable (not in legacy canonical mode)"},
    },
    response_model=LegacyBlipRecord,
    summary="Update an existing BLIP model in legacy format",
    description=(
        "Update an existing model or create if it doesn't exist (upsert) in legacy format.\n\n"
        "This endpoint is only available when canonical_format='LEGACY' in PRIMARY mode."
    ),
    operation_id="update_legacy_blip_model",
)
async def update_legacy_blip_model(
    new_model_record: LegacyBlipRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Update an existing BLIP model in legacy format.

    The model must already exist in the specified category. Use POST to create new models.
    """
    model_name = new_model_record.name
    model_category_name = MODEL_REFERENCE_CATEGORY.blip

    return await _create_or_update_legacy_model(
        manager,
        model_category_name,
        model_name,
        new_model_record,
        Operation.update,
        apikey,
        route_name="update_legacy_blip_model",
    )

create_legacy_codeformer_model async

create_legacy_codeformer_model(
    new_model_record: LegacyCodeformerRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Create a new Codeformer model in legacy format.

The model name in the request body must not already exist in the codeformer category.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.post(
    codeformer_route_subpath,
    status_code=status.HTTP_201_CREATED,
    responses={
        201: {
            "description": "Model created successfully",
        },
        202: {
            "description": "Model creation queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        409: {"description": "Model already exists (use PUT to update)"},
        422: {"description": "Validation error in request body"},
    },
    summary="Create a new Codeformer model in legacy format",
    response_model=get_legacy_model_type(MODEL_REFERENCE_CATEGORY.codeformer),
    operation_id="create_legacy_codeformer_model",
)
async def create_legacy_codeformer_model(
    new_model_record: LegacyCodeformerRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Create a new Codeformer model in legacy format.

    The model name in the request body must not already exist in the codeformer category.
    """
    model_name = new_model_record.name
    category = MODEL_REFERENCE_CATEGORY.codeformer

    return await _create_or_update_legacy_model(
        manager,
        category,
        model_name,
        new_model_record,
        Operation.create,
        apikey,
        route_name="create_legacy_codeformer_model",
    )

update_legacy_codeformer_model async

update_legacy_codeformer_model(
    new_model_record: LegacyCodeformerRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Update an existing Codeformer model in legacy format.

The model must already exist in the specified category. Use POST to create new models.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.put(
    codeformer_route_subpath,
    responses={
        200: {
            "description": "Model updated successfully",
        },
        202: {
            "description": "Model update queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        422: {"description": "Validation error"},
        503: {"description": "Service unavailable (not in legacy canonical mode)"},
    },
    response_model=LegacyCodeformerRecord,
    summary="Update an existing Codeformer model in legacy format",
    description=(
        "Update an existing model or create if it doesn't exist (upsert) in legacy format.\n\n"
        "This endpoint is only available when canonical_format='LEGACY' in PRIMARY mode."
    ),
    operation_id="update_legacy_codeformer_model",
)
async def update_legacy_codeformer_model(
    new_model_record: LegacyCodeformerRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Update an existing Codeformer model in legacy format.

    The model must already exist in the specified category. Use POST to create new models.
    """
    model_name = new_model_record.name
    model_category_name = MODEL_REFERENCE_CATEGORY.codeformer

    return await _create_or_update_legacy_model(
        manager,
        model_category_name,
        model_name,
        new_model_record,
        Operation.update,
        apikey,
        route_name="update_legacy_codeformer_model",
    )

create_legacy_controlnet_model async

create_legacy_controlnet_model(
    new_model_record: LegacyControlnetRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Create a new ControlNet model in legacy format.

The model name in the request body must not already exist in the controlnet category.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.post(
    controlnet_route_subpath,
    status_code=status.HTTP_201_CREATED,
    responses={
        201: {
            "description": "Model created successfully",
        },
        202: {
            "description": "Model creation queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        409: {"description": "Model already exists (use PUT to update)"},
        422: {"description": "Validation error in request body"},
    },
    summary="Create a new ControlNet model in legacy format",
    response_model=get_legacy_model_type(MODEL_REFERENCE_CATEGORY.controlnet),
    operation_id="create_legacy_controlnet_model",
)
async def create_legacy_controlnet_model(
    new_model_record: LegacyControlnetRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Create a new ControlNet model in legacy format.

    The model name in the request body must not already exist in the controlnet category.
    """
    model_name = new_model_record.name
    category = MODEL_REFERENCE_CATEGORY.controlnet

    return await _create_or_update_legacy_model(
        manager,
        category,
        model_name,
        new_model_record,
        Operation.create,
        apikey,
        route_name="create_legacy_controlnet_model",
    )

update_legacy_controlnet_model async

update_legacy_controlnet_model(
    new_model_record: LegacyControlnetRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Update an existing ControlNet model in legacy format.

The model must already exist in the specified category. Use POST to create new models.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.put(
    controlnet_route_subpath,
    responses={
        200: {
            "description": "Model updated successfully",
        },
        202: {
            "description": "Model update queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        422: {"description": "Validation error"},
        503: {"description": "Service unavailable (not in legacy canonical mode)"},
    },
    response_model=LegacyControlnetRecord,
    summary="Update an existing ControlNet model in legacy format",
    description=(
        "Update an existing model or create if it doesn't exist (upsert) in legacy format.\n\n"
        "This endpoint is only available when canonical_format='LEGACY' in PRIMARY mode."
    ),
    operation_id="update_legacy_controlnet_model",
)
async def update_legacy_controlnet_model(
    new_model_record: LegacyControlnetRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Update an existing ControlNet model in legacy format.

    The model must already exist in the specified category. Use POST to create new models.
    """
    model_name = new_model_record.name
    model_category_name = MODEL_REFERENCE_CATEGORY.controlnet

    return await _create_or_update_legacy_model(
        manager,
        model_category_name,
        model_name,
        new_model_record,
        Operation.update,
        apikey,
        route_name="update_legacy_controlnet_model",
    )

create_legacy_esrgan_model async

create_legacy_esrgan_model(
    new_model_record: LegacyEsrganRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Create a new ESRGAN model in legacy format.

The model name in the request body must not already exist in the esrgan category.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.post(
    esrgan_route_subpath,
    status_code=status.HTTP_201_CREATED,
    responses={
        201: {
            "description": "Model created successfully",
        },
        202: {
            "description": "Model creation queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        409: {"description": "Model already exists (use PUT to update)"},
        422: {"description": "Validation error in request body"},
    },
    summary="Create a new ESRGAN model in legacy format",
    response_model=get_legacy_model_type(MODEL_REFERENCE_CATEGORY.esrgan),
    operation_id="create_legacy_esrgan_model",
)
async def create_legacy_esrgan_model(
    new_model_record: LegacyEsrganRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Create a new ESRGAN model in legacy format.

    The model name in the request body must not already exist in the esrgan category.
    """
    model_name = new_model_record.name
    category = MODEL_REFERENCE_CATEGORY.esrgan

    return await _create_or_update_legacy_model(
        manager,
        category,
        model_name,
        new_model_record,
        Operation.create,
        apikey,
        route_name="create_legacy_esrgan_model",
    )

update_legacy_esrgan_model async

update_legacy_esrgan_model(
    new_model_record: LegacyEsrganRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Update an existing ESRGAN model in legacy format.

The model must already exist in the specified category. Use POST to create new models.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.put(
    esrgan_route_subpath,
    responses={
        200: {
            "description": "Model updated successfully",
        },
        202: {
            "description": "Model update queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        422: {"description": "Validation error"},
        503: {"description": "Service unavailable (not in legacy canonical mode)"},
    },
    response_model=LegacyEsrganRecord,
    summary="Update an existing ESRGAN model in legacy format",
    description=(
        "Update an existing model or create if it doesn't exist (upsert) in legacy format.\n\n"
        "This endpoint is only available when canonical_format='LEGACY' in PRIMARY mode."
    ),
    operation_id="update_legacy_esrgan_model",
)
async def update_legacy_esrgan_model(
    new_model_record: LegacyEsrganRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Update an existing ESRGAN model in legacy format.

    The model must already exist in the specified category. Use POST to create new models.
    """
    model_name = new_model_record.name
    model_category_name = MODEL_REFERENCE_CATEGORY.esrgan

    return await _create_or_update_legacy_model(
        manager,
        model_category_name,
        model_name,
        new_model_record,
        Operation.update,
        apikey,
        route_name="update_legacy_esrgan_model",
    )

create_legacy_gfpgan_model async

create_legacy_gfpgan_model(
    new_model_record: LegacyGfpganRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Create a new GFPGAN model in legacy format.

The model name in the request body must not already exist in the gfpgan category.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.post(
    gfpgan_route_subpath,
    status_code=status.HTTP_201_CREATED,
    responses={
        201: {
            "description": "Model created successfully",
        },
        202: {
            "description": "Model creation queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        409: {"description": "Model already exists (use PUT to update)"},
        422: {"description": "Validation error in request body"},
    },
    summary="Create a new GFPGAN model in legacy format",
    response_model=get_legacy_model_type(MODEL_REFERENCE_CATEGORY.gfpgan),
    operation_id="create_legacy_gfpgan_model",
)
async def create_legacy_gfpgan_model(
    new_model_record: LegacyGfpganRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Create a new GFPGAN model in legacy format.

    The model name in the request body must not already exist in the gfpgan category.
    """
    model_name = new_model_record.name
    category = MODEL_REFERENCE_CATEGORY.gfpgan

    return await _create_or_update_legacy_model(
        manager,
        category,
        model_name,
        new_model_record,
        Operation.create,
        apikey,
        route_name="create_legacy_gfpgan_model",
    )

update_legacy_gfpgan_model async

update_legacy_gfpgan_model(
    new_model_record: LegacyGfpganRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Update an existing GFPGAN model in legacy format.

The model must already exist in the specified category. Use POST to create new models.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.put(
    gfpgan_route_subpath,
    responses={
        200: {
            "description": "Model updated successfully",
        },
        202: {
            "description": "Model update queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        422: {"description": "Validation error"},
        503: {"description": "Service unavailable (not in legacy canonical mode)"},
    },
    response_model=LegacyGfpganRecord,
    summary="Update an existing GFPGAN model in legacy format",
    description=(
        "Update an existing model or create if it doesn't exist (upsert) in legacy format.\n\n"
        "This endpoint is only available when canonical_format='LEGACY' in PRIMARY mode."
    ),
    operation_id="update_legacy_gfpgan_model",
)
async def update_legacy_gfpgan_model(
    new_model_record: LegacyGfpganRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Update an existing GFPGAN model in legacy format.

    The model must already exist in the specified category. Use POST to create new models.
    """
    model_name = new_model_record.name
    model_category_name = MODEL_REFERENCE_CATEGORY.gfpgan

    return await _create_or_update_legacy_model(
        manager,
        model_category_name,
        model_name,
        new_model_record,
        Operation.update,
        apikey,
        route_name="update_legacy_gfpgan_model",
    )

create_legacy_safety_checker_model async

create_legacy_safety_checker_model(
    new_model_record: LegacySafetyCheckerRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Create a new safety checker model in legacy format.

The model name in the request body must not already exist in the safety_checker category.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.post(
    safety_checker_route_subpath,
    status_code=status.HTTP_201_CREATED,
    responses={
        201: {
            "description": "Model created successfully",
        },
        202: {
            "description": "Model creation queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        409: {"description": "Model already exists (use PUT to update)"},
        422: {"description": "Validation error in request body"},
    },
    summary="Create a new safety checker model in legacy format",
    response_model=get_legacy_model_type(MODEL_REFERENCE_CATEGORY.safety_checker),
    operation_id="create_legacy_safety_checker_model",
)
async def create_legacy_safety_checker_model(
    new_model_record: LegacySafetyCheckerRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Create a new safety checker model in legacy format.

    The model name in the request body must not already exist in the safety_checker category.
    """
    model_name = new_model_record.name
    category = MODEL_REFERENCE_CATEGORY.safety_checker

    return await _create_or_update_legacy_model(
        manager,
        category,
        model_name,
        new_model_record,
        Operation.create,
        apikey,
        route_name="create_legacy_safety_checker_model",
    )

update_legacy_safety_checker_model async

update_legacy_safety_checker_model(
    new_model_record: LegacySafetyCheckerRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Update an existing safety checker model in legacy format.

The model must already exist in the specified category. Use POST to create new models.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.put(
    safety_checker_route_subpath,
    responses={
        200: {
            "description": "Model updated successfully",
        },
        202: {
            "description": "Model update queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        422: {"description": "Validation error"},
        503: {"description": "Service unavailable (not in legacy canonical mode)"},
    },
    response_model=LegacySafetyCheckerRecord,
    summary="Update an existing safety checker model in legacy format",
    description=(
        "Update an existing model or create if it doesn't exist (upsert) in legacy format.\n\n"
        "This endpoint is only available when canonical_format='LEGACY' in PRIMARY mode."
    ),
    operation_id="update_legacy_safety_checker_model",
)
async def update_legacy_safety_checker_model(
    new_model_record: LegacySafetyCheckerRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Update an existing safety checker model in legacy format.

    The model must already exist in the specified category. Use POST to create new models.
    """
    model_name = new_model_record.name
    model_category_name = MODEL_REFERENCE_CATEGORY.safety_checker

    return await _create_or_update_legacy_model(
        manager,
        model_category_name,
        model_name,
        new_model_record,
        Operation.update,
        apikey,
        route_name="update_legacy_safety_checker_model",
    )

create_legacy_miscellaneous_model async

create_legacy_miscellaneous_model(
    new_model_record: LegacyMiscellaneousRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Create a new miscellaneous model in legacy format.

The model name in the request body must not already exist in the miscellaneous category.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.post(
    miscellaneous_route_subpath,
    status_code=status.HTTP_201_CREATED,
    responses={
        201: {
            "description": "Model created successfully",
        },
        202: {
            "description": "Model creation queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        409: {"description": "Model already exists (use PUT to update)"},
        422: {"description": "Validation error in request body"},
    },
    summary="Create a new miscellaneous model in legacy format",
    response_model=get_legacy_model_type(MODEL_REFERENCE_CATEGORY.miscellaneous),
    operation_id="create_legacy_miscellaneous_model",
)
async def create_legacy_miscellaneous_model(
    new_model_record: LegacyMiscellaneousRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Create a new miscellaneous model in legacy format.

    The model name in the request body must not already exist in the miscellaneous category.
    """
    model_name = new_model_record.name
    category = MODEL_REFERENCE_CATEGORY.miscellaneous

    return await _create_or_update_legacy_model(
        manager,
        category,
        model_name,
        new_model_record,
        Operation.create,
        apikey,
        route_name="create_legacy_miscellaneous_model",
    )

update_legacy_miscellaneous_model async

update_legacy_miscellaneous_model(
    new_model_record: LegacyMiscellaneousRecord,
    manager: Annotated[
        ModelReferenceManager,
        Depends(get_model_reference_manager),
    ],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse

Update an existing miscellaneous model in legacy format.

The model must already exist in the specified category. Use POST to create new models.

Source code in src/horde_model_reference/service/v1/routers/create_update.py
@router.put(
    miscellaneous_route_subpath,
    responses={
        200: {
            "description": "Model updated successfully",
        },
        202: {
            "description": "Model update queued for approval",
            "model": PendingChangeRecord,
        },
        400: {"description": "Invalid request"},
        422: {"description": "Validation error"},
        503: {"description": "Service unavailable (not in legacy canonical mode)"},
    },
    response_model=LegacyMiscellaneousRecord,
    summary="Update an existing miscellaneous model in legacy format",
    description=(
        "Update an existing model or create if it doesn't exist (upsert) in legacy format.\n\n"
        "This endpoint is only available when canonical_format='LEGACY' in PRIMARY mode."
    ),
    operation_id="update_legacy_miscellaneous_model",
)
async def update_legacy_miscellaneous_model(
    new_model_record: LegacyMiscellaneousRecord,
    manager: Annotated[ModelReferenceManager, Depends(get_model_reference_manager)],
    apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse:
    """Update an existing miscellaneous model in legacy format.

    The model must already exist in the specified category. Use POST to create new models.
    """
    model_name = new_model_record.name
    model_category_name = MODEL_REFERENCE_CATEGORY.miscellaneous

    return await _create_or_update_legacy_model(
        manager,
        model_category_name,
        model_name,
        new_model_record,
        Operation.update,
        apikey,
        route_name="update_legacy_miscellaneous_model",
    )