invoke-ai/InvokeAI · error · DuplicateModelException

A model with path '{config.path}' is already installed

Error message

A model with path '{config.path}' is already installed

What it means

add_model inserts a new model config into the SQLite models table; on an integrity error it inspects the constraint name and raises DuplicateModelException when another record already occupies the same path (unique constraint on models.path). The message reports the conflicting path.

Source

Thrown at invokeai/app/services/model_records/model_records_sql.py:139

                        config
                        )
                    VALUES (?,?);
                    """,
                    (
                        config.key,
                        config.model_dump_json(),
                    ),
                )

            except sqlite3.IntegrityError as e:
                if "UNIQUE constraint failed" in str(e):
                    if "models.path" in str(e):
                        msg = f"A model with path '{config.path}' is already installed"
                    elif "models.name" in str(e):
                        msg = f"A model with name='{config.name}', type='{config.type}', base='{config.base}' is already installed"
                    else:
                        msg = f"A model with key '{config.key}' is already installed"
                    raise DuplicateModelException(msg) from e
                else:
                    raise e

        return self.get_model(config.key)

    def del_model(self, key: str) -> None:
        """
        Delete a model.

        :param key: Unique key for the model to be deleted

        Can raise an UnknownModelException
        """
        with self._db.transaction() as cursor:
            cursor.execute(
                """--sql
                DELETE FROM models
                WHERE id=?;

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Get the existing record via search_by_path and reuse/update it instead of adding a new one.
  2. Delete the existing model entry if it is stale, then re-add.
  3. Change the new model's path (or the underlying file location) so it is unique.
  4. Update the existing record with update_model instead of insert.

Example fix

# before
records.add_model(config_with_path_already_installed)
# after
existing = records.search_by_path(path=config.path)
if existing:
    records.update_model(existing[0].key, changes)
else:
    records.add_model(config)
Defensive patterns

Strategy: validation

Validate before calling

existing = records.search_by_path(path=config.path)
if existing:
    raise ValueError(f"Path {config.path} already installed as key {existing[0].key}")

Try / catch

try:
    records.add_model(config)
except DuplicateModelException as e:
    if f"path '{config.path}'" in str(e):
        old = records.search_by_path(config.path)[0]
        records.update_model(old.key, changes)
    else:
        raise

Prevention

When it happens

Trigger: Calling add_model with a config whose path matches an already-installed model — installing a second copy from the same directory, or re-adding a scanned model without dedupe by path.

Common situations: Multiple scan directories containing the same model; re-running an install job after a partial failure that already recorded the record; pointing a new model entry at a shared folder like autoimport with duplicates.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/777b9e95b0b4d63b. Report an issue: GitHub.