Environment Variables
SeanceAI uses environment variables for configuration. These can be set in a.env file for local development or through your hosting platform’s dashboard for production deployments.
Required Variables
OPENROUTER_API_KEY
The OpenRouter API key is required for SeanceAI to communicate with AI models.Sign up for OpenRouter
Visit OpenRouter.ai and create a free account.
Generate an API key
Navigate to the API Keys section in your account dashboard and create a new key.
Optional Variables
PORT
The port number for the Flask application to listen on.- Default:
5000 - Usage: Automatically set by most hosting platforms (Railway, Fly.io, etc.)
- Example: Set to
8080or3000if port 5000 is already in use
FLASK_DEBUG
Enable or disable Flask debug mode.- Default:
false - Values:
trueorfalse - Usage: Set to
truefor local development to enable auto-reload and detailed error messages
Application Configuration
The following settings are configured inapp.py and can be modified if needed:
AI Model Configuration
Default Model
Fallback Models
Conversation Settings
Max History
Rate Limiting
- MAX_RETRIES: Number of retry attempts per model
- RETRY_DELAYS: Exponential backoff delays between retries
Gunicorn Configuration
For production deployments, Gunicorn settings are configured ingunicorn_config.py:
The
gevent worker class is required to support Server-Sent Events (SSE) for streaming responses.Model Selection
SeanceAI supports multiple AI models organized by tier:Swift Tier (Free)
Fast, responsive models that don’t require credits:- Gemma 3 12B - Default model
- Gemma 3 27B - Larger Gemma model
- Llama 3.3 70B - Meta’s flagship model
- Llama 3.1 405B - Largest free model
Balanced Tier
Good mix of speed and capability:- GPT-4o Mini - OpenAI’s efficient model
- Claude 3.5 Haiku - Fast Anthropic model
- DeepSeek V3 - Advanced reasoning
Advanced Tier
Most capable models for best results:- Claude Sonnet 4 - Latest Anthropic model
- GPT-4o - OpenAI’s flagship
- Gemini 2.5 Pro - Google’s advanced model
- Claude Opus 4 - Anthropic’s most capable model
Balanced and Advanced tier models require OpenRouter credits. The free tier models are sufficient for most conversations.
API Configuration
The OpenRouter API endpoint is configured as:- Authorization header: Bearer token with your API key
- HTTP-Referer: Your application’s URL
- X-Title: “SeanceAI - Talk to History”
Health Check Endpoint
SeanceAI includes a health check endpoint at/api/health that returns:
- Monitoring service health
- Verifying API key configuration
- Setting up uptime monitoring (see Deployment)
Example .env File
Here’s a complete example.env file for local development:
Next Steps
- Review the Installation Guide if you haven’t set up SeanceAI yet
- Deploy your configured instance with the Deployment Guide