Skip to main content

Environment variables

The API server reads configuration from environment variables. Set them in a .env file referenced by agentflow.json or as process environment variables.

Setting variables

Via .env file

In agentflow.json:

{
"agent": "graph.react:app",
"env": ".env"
}

In .env:

GOOGLE_API_KEY=your-key
JWT_SECRET_KEY=your-secret
MODE=production

At the process level

MODE=production agentflow api --no-reload

Application variables

VariableDefaultDescription
APP_NAMEMyAppApplication name shown in logs
APP_VERSION0.1.0Application version
MODEdevelopmentdevelopment or production
LOG_LEVELINFOLogging level: DEBUG, INFO, WARNING, ERROR
IS_DEBUGtrueEnable debug mode (disable in production)

Security variables

VariableDefaultDescription
SECURITY_HEADERS_ENABLEDtrueAdd security headers to all responses
HSTS_ENABLEDtrueAdd Strict-Transport-Security header
HSTS_MAX_AGE31536000HSTS max age in seconds
FRAME_OPTIONSDENYX-Frame-Options value
REFERRER_POLICYstrict-origin-when-cross-originReferrer-Policy value

CORS variables

VariableDefaultDescription
ORIGINS*Comma-separated allowed origins. Set to specific domains in production
ALLOWED_HOST*Allowed Host header values
Production CORS

Setting ORIGINS=* in production allows any website to make requests to your API. Always restrict to specific domains in production:

ORIGINS=https://yourapp.com,https://api.yourapp.com

Authentication variables

VariableDescriptionRequired for
JWT_SECRET_KEYSecret key for JWT signing and verificationauth: "jwt"
JWT_ALGORITHMJWT algorithm (default: HS256)auth: "jwt"

Redis variables

VariableDescriptionRequired for
REDIS_URLRedis connection URLPgCheckpointer

Example: redis://localhost:6379/0


Request limits

VariableDefaultDescription
MAX_REQUEST_SIZE10485760 (10MB)Maximum request body size in bytes

API path variables

VariableDefaultDescription
ROOT_PATH/Root path prefix (useful for reverse proxy sub-paths)
DOCS_PATH/docsSwagger UI path (set to empty to disable)
REDOCS_PATH/redocsReDoc path (set to empty to disable)
Disable docs in production

Consider disabling API docs in production by clearing DOCS_PATH and REDOCS_PATH:

DOCS_PATH=
REDOCS_PATH=

Error tracking

VariableDescription
SENTRY_DSNSentry DSN for error tracking (optional)

LLM provider variables

Set these based on the provider you use on your Agent. They are read at client creation time.

OpenAI (provider="openai")

VariableDescription
OPENAI_API_KEYAPI key from https://platform.openai.com

Google Gemini (provider="google")

The Google provider supports two backends: the Gemini API (default) and Vertex AI. See Using Vertex AI.

Gemini API (Google AI Studio):

VariableDescription
GEMINI_API_KEYAPI key from https://aistudio.google.com (preferred)
GOOGLE_API_KEYFallback name for the Gemini API key

Vertex AI (enable with use_vertex_ai=True on the agent or GOOGLE_GENAI_USE_VERTEXAI=true):

VariableDefaultDescription
GOOGLE_GENAI_USE_VERTEXAISet to true to route the Google provider through Vertex AI process-wide
GOOGLE_CLOUD_PROJECTRequired. GCP project ID with the Vertex AI API enabled
GOOGLE_CLOUD_LOCATIONus-central1GCP region for Vertex AI calls
GOOGLE_APPLICATION_CREDENTIALSPath to a service-account JSON key (Application Default Credentials)
Vertex AI authentication

Vertex AI authenticates via Application Default Credentials, not an API key. In local development point GOOGLE_APPLICATION_CREDENTIALS at a service-account key file. On GCP runtimes (Cloud Run, GKE, Compute Engine) the attached service account is picked up automatically.