Setting Up Your LLM API Key
SmartDocs works with any LLM provider. Here's how to get started with the most popular ones.
OpenAI (Recommended)
OpenAI is the easiest to set up and works great with gpt-4o-mini (fast and cheap).
1. Get an API Key
- Go to platform.openai.com/api-keys
- Sign up or log in
- Click "Create new secret key"
- Give it a name (e.g., "smartdocs")
- Copy the key (starts with
sk-proj-...)
๐ฐ Cost: gpt-4o-mini is ~$0.15 per 1M input tokens. A typical documentation query costs less than $0.001. Add $5 credit to get started.
2. Configure SmartDocs
SMARTDOCS_AI_PROVIDER=openai SMARTDOCS_API_KEY=sk-proj-your-key-here SMARTDOCS_MODEL=gpt-4o-mini
3. Available Models
| Model | Best for | Cost |
|---|---|---|
gpt-4o-mini | Fast, cheap, good enough | Very low |
gpt-4o | Best quality, complex questions | Moderate |
gpt-5-nano | Latest, reasoning-focused | Low |
Anthropic (Claude)
Claude is excellent for detailed, nuanced documentation answers.
1. Get an API Key
- Go to console.anthropic.com
- Sign up or log in
- Go to API Keys โ Create Key
- Copy the key (starts with
sk-ant-...)
๐ฐ Cost: Claude Sonnet 4 is ~$3 per 1M input tokens. Similar per-query cost to OpenAI.
2. Configure SmartDocs
SMARTDOCS_AI_PROVIDER=anthropic SMARTDOCS_API_KEY=sk-ant-your-key-here SMARTDOCS_MODEL=claude-sonnet-4-20250514
3. Available Models
| Model | Best for |
|---|---|
claude-sonnet-4-20250514 | Best balance of speed/quality |
claude-opus-4-20250514 | Maximum quality, complex reasoning |
Local with Ollama (Free, Private)
Run models entirely on your machine. No API key needed, no data leaves your computer.
1. Install Ollama
# macOS / Linux curl -fsSL https://ollama.com/install.sh | sh # Windows # Download from https://ollama.com/download
2. Pull a Model
ollama pull llama-3.2-3b # or for better quality: ollama pull qwen-2.5-7b
3. Start Ollama
ollama serve # Runs on http://localhost:11434
4. Configure SmartDocs
SMARTDOCS_AI_PROVIDER=openai-compatible SMARTDOCS_BASE_URL=http://localhost:11434/v1 SMARTDOCS_MODEL=llama-3.2-3b # No API key needed for local models
๐ก Tip: Local models are free and private but slower and less capable than cloud models. Start with OpenAI or Anthropic, switch to local when you're comfortable.
Other Providers
SmartDocs supports any OpenAI-compatible API. This includes:
- Groq โ Fast inference, free tier available
- Together AI โ Many open-source models
- Perplexity โ Search-augmented models
- OpenRouter โ Unified API for many providers
Configure them like this:
SMARTDOCS_AI_PROVIDER=openai-compatible SMARTDOCS_BASE_URL=https://api.groq.com/openai/v1 SMARTDOCS_API_KEY=gsk_your_key_here SMARTDOCS_MODEL=llama-3.2-3b
Security
- Your API key is stored in
.envand never sent to the browser - All LLM calls happen server-side in a Next.js API route
- Local models (Ollama) never leave your machine
- The
.envfile is gitignored โ don't commit your keys
Next: Configuration Guide โ full environment variable reference