2023-07-15 20:14:47 +00:00
---
title: Configuration
---
# :material-tune-variant: InvokeAI Configuration
## Intro
2024-03-15 08:16:08 +00:00
Runtime settings, including the location of files and
directories, memory usage, and performance, are managed via the
2024-03-15 08:47:26 +00:00
`invokeai.yaml` config file or environment variables. A subset
of settings may be set via commandline arguments.
Settings sources are used in this order:
- CLI args
- Environment variables
- `invokeai.yaml` settings
- Fallback: defaults
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
### InvokeAI Root Directory
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
On startup, InvokeAI searches for its "root" directory. This is the directory
that contains models, images, the database, and so on. It also contains
a configuration file called `invokeai.yaml` .
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
InvokeAI searches for the root directory in this order:
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
1. The `--root <path>` CLI arg.
2. The environment variable INVOKEAI_ROOT.
3. The directory containing the currently active virtual environment.
4. Fallback: a directory in the current user's home directory named `invokeai` .
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
### InvokeAI Configuration File
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
Inside the root directory, we read settings from the `invokeai.yaml` file.
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
It has two sections - one for internal use and one for user settings:
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
```yaml
# Internal metadata - do not edit:
2024-03-19 06:16:23 +00:00
schema_version: 4
2023-07-15 20:14:47 +00:00
2024-03-19 06:16:23 +00:00
# Put user settings here - see https://invoke-ai.github.io/InvokeAI/features/CONFIGURATION/:
2024-03-15 08:47:26 +00:00
host: 0.0.0.0 # serve the app on your local network
models_dir: D:\invokeai\models # store models on an external drive
precision: float16 # always use fp16 precision
2024-03-15 08:16:08 +00:00
```
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
The settings in this file will override the defaults. You only need
to change this file if the default for a particular setting doesn't
work for you.
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
Some settings, like [Model Marketplace API Keys], require the YAML
to be formatted correctly. Here is a [basic guide to YAML files].
2023-07-15 20:14:47 +00:00
You can fix a broken `invokeai.yaml` by deleting it and running the
2023-10-17 16:59:48 +00:00
configuration script again -- option [6] in the launcher, "Re-run the
2023-07-15 20:14:47 +00:00
configure script".
2024-03-19 06:16:23 +00:00
#### Custom Config File Location
You can use any config file with the `--config` CLI arg. Pass in the path to the `invokeai.yaml` file you want to use.
Note that environment variables will trump any settings in the config file.
2024-03-15 08:47:26 +00:00
### Environment Variables
2023-07-15 20:14:47 +00:00
2024-03-15 08:47:26 +00:00
All settings may be set via environment variables by prefixing `INVOKEAI_`
to the variable name. For example, `INVOKEAI_HOST` would set the `host`
setting.
2023-07-15 20:14:47 +00:00
2024-03-15 08:47:26 +00:00
For non-primitive values, pass a JSON-encoded string:
```sh
export INVOKEAI_REMOTE_API_TOKENS='[{"url_regex":"modelmarketplace", "token": "12345"}]'
2023-07-15 20:14:47 +00:00
```
2024-03-15 08:47:26 +00:00
We suggest using `invokeai.yaml` , as it is more user-friendly.
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
### CLI Args
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
A subset of settings may be specified using CLI args:
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
- `--root` : specify the root directory
2024-03-19 06:16:23 +00:00
- `--config` : override the default `invokeai.yaml` file location
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
### All Settings
2023-07-15 20:14:47 +00:00
2024-03-08 00:55:05 +00:00
Following the table are additional explanations for certain settings.
2023-08-17 17:47:26 +00:00
2024-03-08 00:55:05 +00:00
<!-- prettier - ignore - start -->
::: invokeai.app.services.config.config_default.InvokeAIAppConfig
options:
2024-03-15 08:16:08 +00:00
heading_level: 4
members: false
show_docstring_description: false
group_by_category: true
show_category_heading: false
2024-03-08 00:55:05 +00:00
<!-- prettier - ignore - end -->
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
#### Model Marketplace API Keys
2024-03-09 06:30:13 +00:00
Some model marketplaces require an API key to download models. You can provide a URL pattern and appropriate token in your `invokeai.yaml` file to provide that API key.
The pattern can be any valid regex (you may need to surround the pattern with quotes):
```yaml
2024-03-15 08:47:26 +00:00
remote_api_tokens:
# Any URL containing `models.com` will automatically use `your_models_com_token`
- url_regex: models.com
token: your_models_com_token
# Any URL matching this contrived regex will use `some_other_token`
- url_regex: '^[a-z]{3}whatever.*\.com$'
token: some_other_token
2024-03-09 06:30:13 +00:00
```
The provided token will be added as a `Bearer` token to the network requests to download the model files. As far as we know, this works for all model marketplaces that require authorization.
2024-03-15 08:16:08 +00:00
#### Model Hashing
2024-03-09 06:30:13 +00:00
2024-03-14 13:09:34 +00:00
Models are hashed during installation, providing a stable identifier for models across all platforms. The default algorithm is `blake3` , with a multi-threaded implementation.
2024-03-09 06:30:13 +00:00
2024-03-14 13:09:34 +00:00
If your models are stored on a spinning hard drive, we suggest using `blake3_single` , the single-threaded implementation. The hashes are the same, but it's much faster on spinning disks.
2024-03-09 06:30:13 +00:00
```yaml
2024-03-15 08:47:26 +00:00
hashing_algorithm: blake3_single
2024-03-09 06:30:13 +00:00
```
2024-03-14 13:09:34 +00:00
Model hashing is a one-time operation, but it may take a couple minutes to hash a large model collection. You may opt out of model hashing entirely by setting the algorithm to `random` .
```yaml
2024-03-15 08:47:26 +00:00
hashing_algorithm: random
2024-03-14 13:09:34 +00:00
```
Most common algorithms are supported, like `md5` , `sha256` , and `sha512` . These are typically much, much slower than `blake3` .
2024-03-15 08:47:26 +00:00
#### Path Settings
2023-07-15 20:14:47 +00:00
These options set the paths of various directories and files used by
2024-03-08 00:55:05 +00:00
InvokeAI. Relative paths are interpreted relative to the root directory, so
if root is `/home/fred/invokeai` and the path is
2023-07-15 20:14:47 +00:00
`autoimport/main` , then the corresponding directory will be located at
`/home/fred/invokeai/autoimport/main` .
2024-03-08 00:55:05 +00:00
Note that the autoimport directory will be searched recursively,
2023-07-15 20:14:47 +00:00
allowing you to organize the models into folders and subfolders in any
2024-03-08 00:55:05 +00:00
way you wish.
2023-07-15 20:14:47 +00:00
2024-03-15 08:16:08 +00:00
#### Logging
2023-07-15 20:14:47 +00:00
Several different log handler destinations are available, and multiple destinations are supported by providing a list:
2024-03-15 08:47:26 +00:00
```yaml
log_handlers:
- console
- syslog=localhost
- file=/var/log/invokeai.log
2023-07-15 20:14:47 +00:00
```
2024-03-08 00:55:05 +00:00
- `console` is the default. It prints log messages to the command-line window from which InvokeAI was launched.
2023-07-15 20:14:47 +00:00
2024-03-08 00:55:05 +00:00
- `syslog` is only available on Linux and Macintosh systems. It uses
2023-07-15 20:14:47 +00:00
the operating system's "syslog" facility to write log file entries
locally or to a remote logging machine. `syslog` offers a variety
of configuration options:
```
syslog=/dev/log` - log to the /dev/log device
syslog=localhost` - log to the network logger running on the local machine
syslog=localhost:512` - same as above, but using a non-standard port
syslog=fredserver,facility=LOG_USER,socktype=SOCK_DRAM`
- Log to LAN-connected server "fredserver" using the facility LOG_USER and datagram packets.
```
2024-03-08 00:55:05 +00:00
- `http` can be used to log to a remote web server. The server must be
2023-07-15 20:14:47 +00:00
properly configured to receive and act on log messages. The option
accepts the URL to the web server, and a `method` argument
indicating whether the message should be submitted using the GET or
POST method.
```
http=http://my.server/path/to/logger,method=POST
```
The `log_format` option provides several alternative formats:
2024-03-08 00:55:05 +00:00
- `color` - default format providing time, date and a message, using text colors to distinguish different log severities
- `plain` - same as above, but monochrome text only
- `syslog` - the log level and error message only, allowing the syslog system to attach the time and date
- `legacy` - a format similar to the one used by the legacy 2.3 InvokeAI releases.
2024-03-15 08:16:08 +00:00
[basic guide to yaml files]: https://circleci.com/blog/what-is-yaml-a-beginner-s-guide/
[Model Marketplace API Keys]: #model -marketplace-api-keys