API Keys Setup
OpenSNS supports multiple AI providers. This guide covers how to get and configure API keys.
Supported Providers
Section titled “Supported Providers”| Provider | Features | Pricing |
|---|---|---|
| OpenAI | GPT-4 for text generation | Pay-per-use |
| Fal.ai | Fast image/video generation | Pay-per-use |
| Ollama | Local LLM (free) | Free (self-hosted) |
| ComfyUI | Local image generation | Free (self-hosted) |
Getting API Keys
Section titled “Getting API Keys”- Go to platform.openai.com
- Sign in or create an account
- Navigate to API Keys section
- Click “Create new secret key”
- Copy the key (starts with
sk-)
- Go to fal.ai
- Sign in with GitHub or Google
- Go to Dashboard → API Keys
- Create a new key
- Copy the key
Firecrawl improves web scraping for complex sites:
- Go to firecrawl.dev
- Sign up for an account
- Copy your API key from the dashboard
Configuring Keys
Section titled “Configuring Keys”Option 1: Environment Variables (Global)
Section titled “Option 1: Environment Variables (Global)”Set keys in backend/.env for all users:
OPENAI_API_KEY=sk-your-openai-keyFAL_KEY=your-fal-keyOption 2: Settings UI (Per-User)
Section titled “Option 2: Settings UI (Per-User)”Each user can configure their own keys:
- Log in to OpenSNS
- Go to Settings
- Enter your API keys
- Click Save Settings
Key Security
Section titled “Key Security”OpenSNS encrypts all stored API keys using Fernet (AES-128):
- Keys are encrypted before storage
- Only the key owner can use them
- Keys are never exposed in API responses
- UI shows only “configured” status, never the actual key
Testing Connection
Section titled “Testing Connection”After configuring keys, test they work:
- Go to Settings
- Click Test Connection
- Shows status for each configured provider
Using Local Providers
Section titled “Using Local Providers”For privacy or cost savings, use local AI:
Ollama (Free LLM)
Section titled “Ollama (Free LLM)”# Install Ollamacurl -fsSL https://ollama.ai/install.sh | sh
# Pull a modelollama pull llama2
# Configure OpenSNSOLLAMA_URL=http://localhost:11434DEFAULT_LLM_ENGINE=ollamaComfyUI (Free Images)
Section titled “ComfyUI (Free Images)”- Install ComfyUI
- Start the server
- Configure:
COMFYUI_URL=http://localhost:8188DEFAULT_IMAGE_ENGINE=comfyuiFallback Mode
Section titled “Fallback Mode”Without API keys, OpenSNS uses “fallback mode”:
- Text generation returns placeholder copy
- Images use product images from scraping
- Videos use source images
This is useful for testing the workflow without incurring costs.
API Documentation
Section titled “API Documentation”Once you have OpenSNS running locally, interactive API documentation is available:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
These are auto-generated from the FastAPI backend and always up-to-date.