Skip to content

Latest commit

 

History

History
201 lines (158 loc) · 5.04 KB

File metadata and controls

201 lines (158 loc) · 5.04 KB

Environment Setup Guide

Quick Setup

  1. Copy the template:

    cp .env.template .env
  2. Add your API keys to .env

  3. Start the server:

    ./run.sh

Getting API Keys

OpenAI API Key

  1. Go to: https://platform.openai.com/api-keys
  2. Sign in or create an account
  3. Click "Create new secret key"
  4. Copy the key (starts with sk-proj- or sk-)
  5. Add to .env:
    OPENAI_API_KEY=sk-proj-your-actual-key-here

Example formats:

  • New: sk-proj-Ab12Cd34Ef56Gh78Ij90Kl12Mn34Op56Qr78St90Uv12Wx34
  • Legacy: sk-Ab12Cd34Ef56Gh78Ij90Kl12Mn34Op56Qr78

Anthropic API Key (Claude)

  1. Go to: https://console.anthropic.com/settings/keys
  2. Sign in or create an account
  3. Click "Create Key"
  4. Copy the key (starts with sk-ant-api03-)
  5. Add to .env:
    ANTHROPIC_API_KEY=sk-ant-api03-your-actual-key-here

Example format:

sk-ant-api03-Ab12Cd34Ef56Gh78Ij90Kl12Mn34Op56Qr78St90Uv12Wx34Yz56Ab78Cd90Ef12Gh34Ij56Kl78Mn90Op12Qr34St56Uv78Wx90

Google AI API Key (Gemini)

  1. Go to: https://makersuite.google.com/app/apikey
  2. Sign in with your Google account
  3. Click "Create API Key"
  4. Copy the key (starts with AIzaSy)
  5. Add to .env:
    GOOGLE_API_KEY=AIzaSyYour-Actual-Key-Here

Example format:

AIzaSyAb12CdEf34GhIj56KlMn78OpQr90StUv12WxYz34

Configuration Options

Provider Settings

DEFAULT_PROVIDER: Which LLM provider to use when not specified in requests

  • Options: openai, anthropic, google
  • Default: openai

DEFAULT_MODEL: Which model to use when not specified in requests

  • OpenAI options:

    • gpt-4o - Latest GPT-4 Optimized (recommended)
    • gpt-4o-mini - Faster, cheaper GPT-4 (recommended for most use cases)
    • gpt-4-turbo - Previous generation GPT-4
    • gpt-3.5-turbo - Older, cheaper option
  • Anthropic options:

    • claude-3-5-sonnet-20241022 - Latest Claude 3.5 (recommended)
    • claude-3-opus-20240229 - Most capable, slower
    • claude-3-haiku-20240307 - Fastest, cheapest
  • Google options:

    • gemini-1.5-pro - Most capable Gemini (recommended)
    • gemini-1.5-flash - Faster, cheaper
    • gemini-pro - Previous generation

Cache Settings

CACHE_MAX_SIZE: Maximum number of cached responses

  • Default: 1000
  • Increase for more caching, decrease for less memory usage

CACHE_TTL_SECONDS: How long to keep cached responses

  • Default: 3600 (1 hour)
  • Common values:
    • 300 - 5 minutes
    • 1800 - 30 minutes
    • 3600 - 1 hour
    • 86400 - 24 hours

Server Settings

HOST: Network interface to bind to

  • 0.0.0.0 - Listen on all interfaces (default, recommended)
  • 127.0.0.1 - Listen only on localhost (more secure for local dev)

PORT: Port number for the server

  • Default: 8000
  • Change if port is already in use

ENVIRONMENT: Deployment environment

  • development - Development mode (default, enables hot reload)
  • staging - Staging environment
  • production - Production mode

Example Configurations

Minimal Setup (OpenAI only)

OPENAI_API_KEY=sk-proj-your-key-here

Multi-Provider Setup

OPENAI_API_KEY=sk-proj-your-openai-key
ANTHROPIC_API_KEY=sk-ant-api03-your-anthropic-key
GOOGLE_API_KEY=AIzaSy-your-google-key
DEFAULT_PROVIDER=anthropic
DEFAULT_MODEL=claude-3-5-sonnet-20241022

Production Setup

OPENAI_API_KEY=sk-proj-your-key-here
DEFAULT_PROVIDER=openai
DEFAULT_MODEL=gpt-4o-mini
CACHE_MAX_SIZE=5000
CACHE_TTL_SECONDS=7200
HOST=0.0.0.0
PORT=8000
ENVIRONMENT=production

Development Setup (Fast & Cheap)

OPENAI_API_KEY=sk-proj-your-key-here
DEFAULT_MODEL=gpt-4o-mini
CACHE_MAX_SIZE=500
CACHE_TTL_SECONDS=300
ENVIRONMENT=development

Troubleshooting

"API key not configured"

  • Make sure .env file exists in the project root
  • Check that the API key variable name is correct (all caps, with underscores)
  • Verify there are no extra spaces around the = sign
  • Ensure the key starts with the correct prefix

"Invalid API key"

  • Double-check you copied the entire key
  • Make sure the key hasn't been revoked
  • Verify you're using the correct provider's key

Server won't start

  • Check if port 8000 is already in use: lsof -i :8000
  • Try changing the PORT in .env
  • Make sure virtual environment is activated

Cache not working

Security Best Practices

DO:

  • Keep .env file private (it's in .gitignore)
  • Use different API keys for development and production
  • Rotate API keys regularly
  • Set spending limits on provider dashboards

DON'T:

  • Commit .env to version control
  • Share API keys in chat/email
  • Use production keys in development
  • Expose API keys in client-side code

Need Help?