﻿# Configure BRIX AI environment variables

> [HTML Version](cortex-environment-variables.html)

Before installing **BRIX AI**, specify the required values in the environment variables file: 

1. Go to the [downloaded BRIX AI installation files](cortex-download-installer.md).

2. Open the folder that corresponds to your installation method: `docker-compose` or `docker-swarm`. 

3. Select the `.env` file.

4. Configure the following parameters:

- [Project name](#project-name). Specified if you run multiple copies of **BRIX AI**.

- [Server address](#service-address). The host name and port.

- [TLS settings](#tls-settings). Certificate management mode and usage parameters.

- [Administrator authorization method for BRIX AI](#authentication). Via the BRIX platform.

- [Use of built-in or external services](#external-services).

- [Performance settings](#performance).

The parameters you set are applied during **BRIX AI** installation. If you change their values later, [apply them using a script](#apply-new-values).

## Project name

If you need to run multiple isolated copies of **BRIX AI** on a single host, assign a unique project name to each instance. They are used as follows: 

- When using Docker Compose: as the value for the `COMPOSE\_PROJECT\_NAME` parameter and as a container prefix.

- When using Docker Swarm: as a prefix for service names.

The default value is `elma-cortex`. You can specify a custom project name in two ways:

1. In the `.env` environment variables file.

This method is convenient if a separate installation directory is created for each instance of **BRIX AI** and scripts are executed from that directory. When using this method:

- Change the value of the `PROJECT\_NAME` variable to specify the project name.

- Run installation, diagnostic, and uninstallation scripts without passing the project name. The value will be retrieved automatically from the `.env` file.

2. When running a script.

This method allows you to explicitly pass the required project name every time you execute installation, diagnostic, or uninstallation scripts. When using this method:

- Pass the project name using the `--project-name` flag during the initial run of the installation script. For details, see articles on installing **BRIX AI**.

- Specify the project name in the `--project-name` parameter every time you execute scripts to update, diagnose, or remove **BRIX AI**.

## BRIX AI server address

Fill in the following variables:

- `ELMA\_CORTEX\_HOSTNAME`: Host name of your server.

- `ELMA\_CORTEX\_PORT`: HTTPS port. Port 443 is used by default.

## TLS settings

Set the TLS certificate management mode and configure usage parameters based on your certificate authority. 

For details, see [Configure TLS certificates for BRIX AI](cortex-tls-settings.md).

## Authorization

By default, users are automatically logged in as an administrator upon opening **BRIX AI**. To enhance security, configure sign-in via BRIX or ELMA Bot.

For details, see [Configure authorization in BRIX AI](cortex-auth-settings.md).

## Use of external services

Services required for operation, such as MongoDB, Redis, RabbitMQ, and others, are bundled with **BRIX AI**.

You can disable the installation of built-in services if they are already configured in your infrastructure. To do this, set the corresponding service variable to `false` in the `.env` file:

````
CADDY\_ENABLED=false  
REDIS\_ENABLED=false  
MONGO\_ENABLED=false  
RABBIT\_ENABLED=false  
MINIO\_ENABLED=false  
QDRANT\_ENABLED=false  
PHOENIX\_ENABLED=false

````
After that, configure the connection between **BRIX AI** and external services by uncommenting the relevant variables. The required connection settings depend on the specific service.

## Performance settings

To increase system throughput, you can configure scaling for **BRIX AI** as workload increases.

````
начало внимание

````
Resource scaling under increased workload is available only in specific [BRIX AI editions](cortex-editions.md).

````
конец внимание

````
To manage scaling, configure the following parameters in the `.env` file:

- Number of HTTP server workers. Usually equals the number of CPU cores. Default is `4`:

````
UVICORN\_WORKERS=8

- ````
Number of workers for background tasks. Default is **4**:

````
CELERY\_WORKER\_CONCURRENCY=8

- ````
Enabling autoscaling for worker pools. An advanced setting that allows defining the `CELERY\_WORKER\_CONCURRENCY` parameter separately for specific worker pools:

````
CELERY\_START\_WORKER\_MAIN=--autoscale=2,4 -Q celery.gamma.tasks.ingestion,celery.gamma.tasks.search.run,celery.gamma.tasks.agent.run  
CELERY\_START\_WORKER\_FAST=--autoscale=4,8 -Q celery.gamma.tasks.search.run,celery.gamma.tasks.agent.run

## ````
Apply new environment variable values

Configured settings are automatically applied during **BRIX AI** installation.

If you update parameters in the `.env` file after installation, run the following command to apply them:

````
./install.sh
````