[GH-ISSUE #12393] feat: load initial data on startup via json files (e.g. workspace models / user groups / ...) #32110

Closed
opened 2026-04-25 06:00:05 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @MaxStroh on GitHub (Apr 3, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/12393

Check Existing Issues

  • I have searched the existing issues and discussions.

Problem Description

We are running OpenWebUI in Kubernetes and with PostgresDB and would like to enhance the Infrastructure as Code behaviour of OpenWebUI.

To ensure, that everything relevant is set up, when we start with a fresh new instance (or in case we have to fully reset an existing environment), we would like to automatically import data that ist not configurable otherwise.

Some exemplary Use Cases:

  • We built some "Custom Bots" (= Workspace Models, wrapping the base models with pre-defined Prompts / Knowledge / Params for individual use cases). We already are able to export these as a json file and import the json file manually after a reset of the environment, but we would love to get rid of manual work on startup
  • As we are using SSO and Group Management, we have to make sure, that the corresponding User Groups exist in OpenWebUI on startup, so that users can be automatically be assigned to these without manually adding these groups (via a json file or as an env var to set a list of groupnames to automatically create on startup)
  • If it was possible to add groups via loading a json file, we could define specific groupIDs for the groups to be created and would be able to also reference these ids in our models.json to already set up the access assignments of groups to our custom models (workspace models)

Desired Solution you'd like

  • We found out in the code, that a similar behaviour is already implemented for the config.json file. If on startup (e.g. in an init container) a config.json exists in the DATA_DIR, it will be loaded into the db and the settings are added or resetted/updates to the values defined in our config.json - which is perfect from the point of view of an IaC principle (see https://github.com/open-webui/open-webui/blob/main/backend/open_webui/config.py#L104-L108)
  • It would be great if it would be possible to have the same functionalities for other settings, e.g.:
    • Putting a workspace-models.json into the DATA_DIR automatically loads/updates these models into the db on startup
    • Putting a user-groups.json into the DATA_DIR automatically loads/updates the defined user groups into the db on startup
    • (Optionally:) If loading both via json file is possible: Adding "readable" GroupIDs to already assign access of groups to workspace models in the workspace-models.json

Alternatives Considered

  • For Groups it would for now be enough, if there would be an env var like: GROUPS_TO_CREATE=["IT", "Marketing", ...]
  • Alternatively we could import some data on startup via psql (we are using PostgresDB), but these kind of scripts will easily break when changes are made on the tables we want to fill

Additional Context

  • If accidentally removing your volumes, this could be also nice to save your settings when using OpenWebUI with Docker
Originally created by @MaxStroh on GitHub (Apr 3, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/12393 ### Check Existing Issues - [x] I have searched the existing issues and discussions. ### Problem Description We are running OpenWebUI in Kubernetes and with PostgresDB and would like to enhance the Infrastructure as Code behaviour of OpenWebUI. To ensure, that everything relevant is set up, when we start with a fresh new instance (or in case we have to fully reset an existing environment), we would like to automatically import data that ist not configurable otherwise. **Some exemplary Use Cases:** * We built some "Custom Bots" (= Workspace Models, wrapping the base models with pre-defined Prompts / Knowledge / Params for individual use cases). We already are able to export these as a json file and import the json file manually after a reset of the environment, but we would love to get rid of manual work on startup * As we are using SSO and Group Management, we have to make sure, that the corresponding User Groups exist in OpenWebUI on startup, so that users can be automatically be assigned to these without manually adding these groups (via a json file or as an env var to set a list of groupnames to automatically create on startup) * If it was possible to add groups via loading a json file, we could define specific groupIDs for the groups to be created and would be able to also reference these ids in our `models.json` to already set up the access assignments of groups to our custom models (workspace models) ### Desired Solution you'd like * We found out in the code, that a similar behaviour is already implemented for the `config.json` file. If on startup (e.g. in an init container) a `config.json` exists in the `DATA_DIR`, it will be loaded into the db and the settings are added or resetted/updates to the values defined in our `config.json` - which is perfect from the point of view of an IaC principle (see https://github.com/open-webui/open-webui/blob/main/backend/open_webui/config.py#L104-L108) * It would be great if it would be possible to have the same functionalities for other settings, e.g.: * Putting a `workspace-models.json` into the `DATA_DIR` automatically loads/updates these models into the db on startup * Putting a `user-groups.json` into the `DATA_DIR` automatically loads/updates the defined user groups into the db on startup * (Optionally:) If loading both via json file is possible: Adding "readable" GroupIDs to already assign access of groups to workspace models in the `workspace-models.json` ### Alternatives Considered * For Groups it would for now be enough, if there would be an env var like: `GROUPS_TO_CREATE=["IT", "Marketing", ...]` * Alternatively we could import some data on startup via `psql` (we are using PostgresDB), but these kind of scripts will easily break when changes are made on the tables we want to fill ### Additional Context * If accidentally removing your volumes, this could be also nice to save your settings when using OpenWebUI with Docker
Author
Owner

@rgaricano commented on GitHub (Apr 3, 2025):

yes, this will do config more modular & reproducible,

another in the middle solution is have a preconfigurated database (a db copy after first configs), & then replace it at first start of new installations.

<!-- gh-comment-id:2775924833 --> @rgaricano commented on GitHub (Apr 3, 2025): yes, this will do config more modular & reproducible, another in the middle solution is have a preconfigurated database (a db copy after first configs), & then replace it at first start of new installations.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#32110