src/env.ts and validated at startup.
Setup
Copy the example environment file and fill in your values:.env with your configuration. The application will automatically load .env and .env.local files on startup.
Using Environment Variables
Correct Usage:Server Configuration
Variables for backend API server configuration.Port number for the backend API server. The frontend will proxy
/api/* requests to this port during development.Public server origin URL. Used for callbacks and external integrations.Example:
https://autonome.appInternal API base URL used by the server for self-referencing endpoints.
Comma-separated list of allowed frontend origins for CORS. No trailing slashes.Example:
https://autonome.app,https://autonome.vercel.appDatabase
PostgreSQL connection string. Required for backend operation but optional for frontend-only deployments on Vercel.Format:
postgres://user:password@localhost:5432/autonomeTrading Configuration
Controls trading mode and simulator behavior. See Trading Mode for detailed information.Trading execution mode. Controls whether orders are sent to the real exchange or simulated locally.Values:
simulated- Use local simulator (safe for testing)live- Execute real trades via Lighter API
Starting capital for the trading simulator in quote currency (USDT).
Quote currency for simulator positions and P&L calculations.
Interval in milliseconds for simulator to refresh market data and recalculate positions.
Lighter API
Configuration for zkLighter exchange integration (required for live trading).Credential slot index in your zkLighter account. Each account can have multiple API key indexes.
Base URL for the Lighter REST API endpoint.
AI Provider Keys
Autonome supports multiple AI providers with automatic key rotation for rate limit management.NVIDIA NIM
Primary NVIDIA NIM API key for SQL query planning and data analysis.
Additional NIM API key for round-robin rotation.
Additional NIM API key for round-robin rotation.
Additional NIM API key for round-robin rotation.
OpenRouter
Primary OpenRouter API key for accessing various AI models through a unified API.
Additional OpenRouter API key for round-robin rotation.
AIHubMix
Primary AIHubMix API key.
Additional AIHubMix API key for round-robin rotation.
Additional AIHubMix API key for round-robin rotation.
Additional AIHubMix API key for round-robin rotation.
Additional AIHubMix API key for round-robin rotation.
Additional AIHubMix API key for round-robin rotation.
Mistral AI
Mistral AI API key for additional AI model access.
API Key Rotation
The system automatically rotates through multiple API keys using round-robin cycling to avoid rate limits:Technical Indicators
Frontend Variables
Client-side environment variables that are exposed to the browser. These must be prefixed withVITE_.
Optional application title override for the UI.
API base URL accessible from the browser. Required for production deployments where frontend and backend are on different domains.Development: Leave empty to use Vite’s proxy (
/api/* → http://localhost:8081)Production: Set to your backend API URL (e.g., https://api.autonome.app)T3Env Configuration
Autonome uses T3Env’semptyStringAsUndefined option, which means:
- Empty strings in
.envare treated as undefined - Default values will be applied for empty strings
- Type validation happens after empty string handling
Validation
All environment variables are validated using Zod schemas at application startup. Invalid configurations will cause the application to fail fast with detailed error messages. Validation Features:- Type coercion (e.g.,
PORTstring → number) - URL format validation
- Enum validation for
TRADING_MODE - Required vs. optional field enforcement
- Default value application
Environment File Loading
The application loads environment files in this order:.env- Base configuration (committed to repo as.env.example).env.local- Local overrides (gitignored, for development)
- Keep shared defaults in
.env.example - Use
.env.localfor personal API keys and local settings - Override everything in production with platform environment variables
Best Practices
Do:
- Use
.env.localfor local development secrets - Always import from
src/env.tsfor type safety - Use the provided key rotation functions for AI APIs
- Validate environment on deployment with
scripts/validate-env.ts - Set appropriate CORS origins in production

