Settings

Settings

Background

Grai uses Django and Postgres as part of it's core stack. It supports scheduled worker management with celery and cacheing through redis. It also offers both a REST API and GraphQL API.

Configuration

Most aspects of the server are fully configurable. If there are any attributes you need greater control over PR's are welcome.

ℹ️

The default settings for ALLOWED_HOSTS, CORS_ALLOWED_ORIGINS, CSRF_TRUSTED_ORIGINS, and CORS_ALLOW_ALL_ORIGINS are all modified by DEBUG to be maximally permissive. It will allow all hosts, all origins, and all combinations of frontend host, backend host and scheme.

environment variablerequireddefault valuedescription
SECRET_KEYYesA crypotographic key used to prevent various exploits like CSRF attacks. This should be kept secret at all times. This will usually look like a 50 character random string of numbers and symbols.
DEBUGNoFalseRun in debug mode
TEMPLATE_DEBUGNoFalseRun templating in debug mode
SERVER_HOSTNolocalhosthost for the current deployment
SERVER_PORTNo8000port for the current deployment
SERVER_URLNohttp://{SERVER_HOST}:{SERVER_PORT}URL of the server deployment
FRONTEND_HOSTNolocalhosthost for the deployed frontend
FRONTEND_PORTNo3000port for the deployed frontend
FRONTEND_URLNohttp://{FRONTEND_HOST}:{FRONTEND_PORT}URL of the frontenddeployment
DISABLE_HTTPNoFalsedisables access through http
ALLOWED_HOSTSNoSERVER_HOST, 127.0.0.1, [::1]Django configuration for allowed hosts
CORS_ALLOWED_ORIGINSNohttp://{FRONTEND_HOST}, http://{FRONTEND_HOST}:{FRONTEND_PORT}, https://{FRONTEND_HOST}, https://{FRONTEND_HOST}:{FRONTEND_PORT}CORS Allowed Origins
CSRF_TRUSTED_ORIGINSNoSERVER_HOST, 127.0.0.1, [::1]host for the current deployment
CORS_ALLOW_ALL_ORIGINSNoFalseDjango CORS allow all setting

Database Configuration

environment variablerequireddefault valuedescription
DB_ENGINENopsqlextra.backendThe database engine to use
DB_NAMENograiThe name of the database to use
DB_USERNograiThe user to connect to the database with
DB_PASSWORDNograiThe password to connect to the database with
DB_HOSTNolocalhostThe host of the database
DB_PORTNo5432The port of the database

Redis Configuration

environment variablerequireddefault valuedescription
REDIS_HOSTNolocalhostThe host of the redis server
REDIS_PORTNo6379The port of the redis server
REDIS_CHANNEL_HOSTNo{REDIS_HOST}The host of the redis server used for backend websockets
REDIS_CHANNEL_PORTNo{REDIS_PORT}The port of the redis server used for backend websockets
REDIS_GRAPH_CACHE_HOSTNo{REDIS_HOST}The host of the redis server used for graph cache
REDIS_GRAPH_CACHE_PORTNo{REDIS_PORT}The port of the redis server used for graph cache

Email Configuration

environment variablerequireddefault valuedescription
EMAIL_BACKENDNodjango.core.mail.backends.console.EmailBackendYour preferred email backend (opens in a new tab)
EMAIL_FROMNoNoneThe email address your emails should be sent from
AWS_ACCESS_KEY_IDNoNoneAWS access key id required for amazon SES
AWS_SECRET_ACCESS_KEYNoNoneAWS secret access key required for amazon SES
AWS_SES_REGION_NAMENoNoneAWS region required for amazon SES
AWS_SES_REGION_ENDPOINTNoemail.us-west-2.amazonaws.comThe email address your emails should be sent from

AI Configuration

environment variablerequireddefault valuedescription
OPENAI_API_KEYNoNoneYour openai api key
OPENAI_ORG_IDNoNoneYour openai organization id
OPENAI_PREFERRED_MODELNogpt-3.5-turboThe preferred model to use for openai api requests. This is configurable manage cost controls but newer models provide better results

Celery Configuration

environment variablerequireddefault valuedescription
CELERY_BROKERNoredis://{REDIS_HOST}:{REDIS_PORT}/0The backend url for celery
CELERY_BACKENDNoredis://{REDIS_HOST}:{REDIS_PORT}/0The backend url for celery

Miscellaneous

environment variablerequireddefault valuedescription
SENTRY_DSNNoConfigure error reporting with Sentry
SENTRY_SAMPLE_RATENo0.2The sample rate for Sentry
POSTHOG_HOSTNohttps://app.posthog.com (opens in a new tab)The posthog url
POSTHOG_PROJECT_API_KEYNoConfigure logging through posthog
DISABLE_POSTHOGNoFalseDisables all posthog logging
DISABLE_TELEMETRYNoFalseDisables all telemetry
DEFAULT_FILE_STORAGENodjango.core.files.storage.FileSystemStorageThe default file storage backend used by Django
AWS_STORAGE_BUCKET_NAMENoNoneAWS bucket storage
GITHUB_APP_IDNoNone
GITHUB_PRIVATE_KEYNoNone