<!-- Source: https://docs.squirro.com/en/latest/technical/admin/configuration/config-files/genai.html -->
# genai.ini

As `genai` is a containerized service, the configuration does not rely on providing a `genai.ini` file. Instead, the configuration is provided through environment variables that are made available to the container.

> **Notes for administrators**
>
> - A `/etc/squirro/genai.ini` file exists in most Squirro deployments, but it should not be used to configure the service.
> - Version 3.13.0 includes breaking changes that may require adjustments if you are upgrading from an earlier version. [Learn more](../../../../getting/release/3-13/3.13.0-release-notes.md#breaking)

Environment variables allow you to customize how the GenAI Docker image behaves and connects to external services. Some of these variables are mandatory. If they are not set or are misconfigured, the service may fail to start or function correctly.

| Variable Name | Type | Required | Description | Example Value |
| --- | --- | --- | --- | --- |
| SQ_DATABASE_URL | string | Yes | Database URL for the GenAI service (supports pymysql, psycopg2 and sqlite connectors). | `mysql+pymysql:///genai.db` |
| SQ_TOPIC_API_ENDPOINT | string | Yes | Endpoint for the Squirro topic API. | `https://my-instance.squirro.cloud/api/topic` |
| SQ_USER_API_ENDPOINT | string | Yes | Endpoint for the Squirro user API. | `https://my-instance.squirro.cloud/api/user` |
| SQ_USER_SERVICE_CLIENT_ID | string | Yes | Value of the genai.client_id configuration in the [clients] section of the Squirro platform user.ini. Required to run query processing. | `myclientid` |
| SQ_USER_SERVICE_CLIENT_SECRET | string | Yes | Value of the genai.client_secret configuration in the [clients] section of the Squirro platform user.ini. Required to run query processing. | `myclientsecret` |
| SQ_CLUSTER | string | Yes (for remote clusters) | Fallback Squirro cluster URL, used if it is not specified in the request. Default value is http://localhost. | `https://my-instance.squirro.cloud/` |
| SQ_SECURITY_WORKSPACES | boolean | Yes | Value of the workspaces configuration in the [security] section of Squirro platform common.ini. Should have the same value across all Squirro services. | `false` |
| SQ_DECRYPT_COMMAND | string | No | Path to the command that resolves the `CK_CMD` variables in the Squirro config files. | `/opt/squirro/container/squirro_container_ck_cmd.sh` |
| SQ_LOG_LEVEL | string | No | Log level for the `genai` service. | `INFO` |
| SQ_CA_FILE | string | No | Path to file containing certificates that should be added to the container. | `/etc/certs/selfsigned_ca.pem` |
| SQ_DATABASE_SSL_CA | string | No | Path to file containing certificates that should be added to the database connection (alternative to setting the file in `SQ_DATABASE_URL`; injects value into SQLAlchemy `connect_args`). | `/etc/certs/selfsigned_ca.pem` |
| SQ_REDIS_CACHE_HOST | string | No | Redis server host used for caching (if not specified, some caching may not be performed). | `127.0.0.1` |
| SQ_REDIS_CACHE_PORT | int | No | (see above) | `6380` |
| SQ_REDIS_CACHE_PASSWORD | string | No | (see above) | `redis-password` |
| SQ_REDIS_CACHE_DB | int | No | (see above) | `7` |
| SQUIRRO_REFRESH_TOKEN | string | No | Fallback refresh token, used if it is not specified in the request. | `myrefreshtoken` |
| SQUIRRO_PROJECT_ID | string | No | Fallback project ID, used if it is not specified in the request. | `myprojectid` |
| SQUIRRO_SEARCH_MODE | string | No | Fallback search mode, used if it is not specified in the request. | `hybrid`, `dense_only` or `sparse_only`. |
| SQ_OPENAI_API_KEY, OPENAI_API_KEY | string | No | Fallback API key for OpenAI LLM API, used if it is not specified in the request. | `sk-secret-key` |
| SQ_AZURE_API_KEY, AZURE_API_KEY | string | No | Fallback API key for Azure LLM API, used if it is not specified in the request. | `azure-secret-key` |
| SQ_ANYSCALE_API_KEY | string | No | Fallback API key for Anyscale LLM API, used if it is not specified in the request. | `anyscale-secret-key` |
| SQ_LLAMA_API_KEY | string | No | Fallback API key for LLAMA LLM API, used if it is not specified in the request. | `llama-secret-key` |
| SQ_GOOGLE_API_KEY, GOOGLE_API_KEY | string | No | Fallback API key for Google LLM (Gemini) API, used if it is not specified in the request. | `google-secret-key` |
| SQ_CEREBRAS_API_KEY | string | No | Fallback API key for Cerebras LLM API, used if it is not specified in the request. | `cerebras-secret-key` |
| SQ_BRAVE_API_KEY | string | No | Fallback API key for Brave-related tools, used if it is not specified in the request. | `brave-secret-key` |
| OPENAI_MODEL | string | No | Fallback OpenAI model, used if it is not specified in the request. | `gpt-4o` |
| SQ_DISABLE_AUTHENTICATION | string | No | **For testing pruposes only -** If set to `true`, the service does not require authentication (a `true` value is **NOT FOR PRODUCTION ENVIRONMENTS**). | `false` |
| SQ_ROOT_PATH | string | No | `root_path` provided to FastAPI, for [serving behind a proxy](https://fastapi.tiangolo.com/advanced/behind-a-proxy/) | `/api/v1` |
| SQ_GENAI_AUTO_POPULATE_DEFAULT_AGENTS | string | No | If set to `true`, the service automatically populates the default agents in the database. | `true` (default) |
| SQ_GENAI_TELEMETRY_ENABLED | string | No | Global switch to disable telemetry system for debugging and monitoring query execution patterns. Set to `false` to disable. Requires per-request activation via `?telemetry=true` query parameter. | `true` |
| SQ_LLM_RATE_LIMIT_ERROR_MESSAGE | string | No | Error message to return when the rate limit is exceeded. | `Rate limit exceeded` |
| SQ_GENERIC_ERROR_MESSAGE | string | No | Error message to return when an error occurs. | `An error occurred` |
| DEFAULT_PERSONA | string | No | Overrides the default persona. | `You are a specialized financial AI assistant.` |
| DEFAULT_USER_PROMPT_EXTRA | string | No | Overrides the default user prompt instructions that define behavioral rules and constraints for agents. | `Always provide sources and cite regulations.` |
| DEFAULT_ASSISTANT_LANG_INSTRUCTION | string | No | Overrides the default language instructions for agent responses. | `You must formulate your answer in English.` |
| DEFAULT_RETRIEVAL_LANG_INSTRUCTION | string | No | Overrides the default language instructions for retrieval queries. | `You must formulate your retrieval query in English.` |

## Setting Environment Variables

Set environment variables for the GenAI service by creating a `docker-override.env` file in the `/etc/squirro/genai.d/` directory. That approach ensures that environment variables are preserved and continue to work as expected after updates or upgrades of Squirro components.

**Steps:**

1. Create the `docker-override.env` file if it does not already exist.

   ```bash
   sudo touch /etc/squirro/genai.d/docker-override.env
   ```
2. Add environment variables to the file in the format `VARIABLE_NAME=VALUE` without spaces around the equal sign.

   ```bash
   DEFAULT_PERSONA="You are a specialized financial AI assistant with expertise in market analysis."
   ```
3. Ensure the file is owned by the `sqgenai` user.

   ```bash
   sudo chown sqgenai:squirro /etc/squirro/genai.d/docker-override.env
   ```
4. Restart the GenAI service.

   ```bash
   sudo systemctl restart sqgenaid
   ```
