π€ AI Provider Setup Guide
Configure AI providers for advanced grammar checking and tone rewriting.
π Overview
OpenGrammar supports 6 AI providers, giving you flexibility in cost, quality, and privacy.
| Provider | Speed | Quality | Cost | Best For |
|---|---|---|---|---|
| Groq | β‘β‘β‘ | ββββ | Free tier | Fast & free |
| OpenAI | β‘β‘ | βββββ | $$ | Best quality |
| OpenRouter | β‘β‘ | βββββ | Varies | Model variety |
| Together AI | β‘β‘ | ββββ | $ | Open-source |
| Ollama | β‘β‘β‘ | βββ | Free | Privacy, offline |
| Custom | - | - | - | Your own API |
π― Quick Setup
Step 1: Choose Your Provider
For Free Usage:
- Provider: Groq
- Free tier: 100 requests/day
- Quality: Excellent (Llama 3.1 70B)
For Best Quality:
- Provider: OpenAI
- Model: GPT-4o-mini
- Cost: ~$0.15 per 1K requests
For Privacy:
- Provider: Ollama (Local)
- 100% offline
- Free (your hardware)
Step 2: Get API Key
Follow the guide for your chosen provider below.
Step 3: Configure Extension
- Click OpenGrammar icon
- Click Settings (gear icon)
- Select Provider from dropdown
- Enter API Key
- Select Model
- Click Save
β‘ Groq (Recommended - Free)
Overview
- Free Tier: 100 requests/day
- Speed: Fastest (LPU technology)
- Quality: Excellent (Llama 3.1 70B)
- Setup Time: 2 minutes
Step 1: Create Account
- Visit Groq Console
- Click Sign Up
- Complete registration
Step 2: Get API Key
- Go to API Keys in left sidebar
- Click Create API Key
- Give it a name (e.g., "OpenGrammar")
- Copy the key (starts with
gsk_) - β οΈ Save it now - you can't see it again!
Step 3: Configure in Extension
- Click OpenGrammar icon β Settings
- Provider: Groq
- API Key:
gsk_xxx(paste your key) - Model: llama-3.1-70b-versatile
- Click Save
Available Models
| Model | Speed | Quality | Best For |
|---|---|---|---|
llama-3.1-70b-versatile |
β‘β‘β‘ | βββββ | Recommended |
llama-3.1-8b-instant |
β‘β‘β‘β‘ | ββββ | Fast checks |
gemma2-9b-it |
β‘β‘β‘ | ββββ | Balanced |
mixtral-8x7b-32768 |
β‘β‘ | βββββ | Complex writing |
Testing
# Test Groq API
curl https://api.groq.com/openai/v1/chat/completions \
-H "Authorization: Bearer gsk_xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "llama-3.1-70b-versatile",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Troubleshooting
- Error: Invalid API key - Check key starts with
gsk_ - Error: Rate limit - Free tier is 100/day, wait 24 hours
- Error: Model not found - Use exact model name
π’ OpenAI (Best Quality)
Overview
- Quality: Best available
- Speed: Good
- Cost: $0.15 per 1K requests (GPT-4o-mini)
- Setup Time: 5 minutes
Step 1: Create Account
- Visit OpenAI Platform
- Click Sign Up
- Complete registration
- Add phone number (required)
Step 2: Add Credits
- Go to Settings β Billing
- Click Add payment method
- Add minimum $5 credit (recommended)
Step 3: Get API Key
- Go to API Keys section
- Click Create new secret key
- Give it a name (e.g., "OpenGrammar")
- Copy the key (starts with
sk-) - β οΈ Save it now - can't see it again!
Step 4: Configure in Extension
- Click OpenGrammar icon β Settings
- Provider: OpenAI
- API Key:
sk-xxx(paste your key) - Model: gpt-4o-mini (recommended)
- Click Save
Available Models
| Model | Speed | Quality | Cost/1K | Best For |
|---|---|---|---|---|
gpt-4o-mini |
β‘β‘ | βββββ | $0.15 | Recommended |
gpt-4o |
β‘ | ββββββ | $2.50 | Premium quality |
gpt-3.5-turbo |
β‘β‘β‘ | ββββ | $0.05 | Budget option |
Cost Estimates
- Light user (50 checks/day): ~$0.25/month
- Medium user (200 checks/day): ~$1/month
- Heavy user (1000 checks/day): ~$5/month
Testing
# Test OpenAI API
curl https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer sk-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Fix: me and him went"}]
}'
π OpenRouter (100+ Models)
Overview
- Models: 100+ (Claude, Llama, Mistral, etc.)
- Cost: Pay-per-use, varies by model
- Speed: Good
- Setup Time: 5 minutes
Step 1: Create Account
- Visit OpenRouter
- Click Sign In
- Sign in with Google or GitHub
Step 2: Get API Key
- Go to Keys section
- Click Create Key
- Give it a name
- Copy the key
Step 3: Add Credits
- Go to Credits section
- Add minimum $5 credit
- Choose payment method
Step 4: Configure in Extension
- Click OpenGrammar icon β Settings
- Provider: OpenRouter
- API Key: (paste your key)
- Model: anthropic/claude-3.5-sonnet (recommended)
- Click Save
Popular Models
| Model | Provider | Quality | Cost/1K | Best For |
|---|---|---|---|---|
anthropic/claude-3.5-sonnet |
Anthropic | ββββββ | $3.00 | Best overall |
meta-llama/llama-3.1-70b |
Meta | βββββ | $0.40 | Great value |
mistralai/mistral-large |
Mistral | βββββ | $2.00 | European AI |
google/gemini-pro |
βββββ | $0.25 | Google quality |
Testing
# Test OpenRouter API
curl https://openrouter.ai/api/v1/chat/completions \
-H "Authorization: Bearer xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-3.5-sonnet",
"messages": [{"role": "user", "content": "Hello!"}]
}'
π· Together AI (Open-Source)
Overview
- Models: Open-source (Llama, Mistral, etc.)
- Cost: Very cheap ($0.01-0.10 per 1K)
- Speed: Fast
- Setup Time: 5 minutes
Step 1: Create Account
- Visit Together AI
- Click Sign Up
- Complete registration
Step 2: Get API Key
- Go to Settings β API Keys
- Click Create API Key
- Copy the key
Step 3: Add Credits
- Go to Billing section
- Add credits (minimum $5)
- Get $25 free credit on signup
Step 4: Configure in Extension
- Click OpenGrammar icon β Settings
- Provider: Together AI
- API Key: (paste your key)
- Model: meta-llama/Meta-Llama-3.1-70B-Instruct
- Click Save
Available Models
| Model | Quality | Cost/1K | Best For |
|---|---|---|---|
meta-llama/Meta-Llama-3.1-70B-Instruct |
βββββ | $0.40 | Recommended |
mistralai/Mixtral-8x7B-Instruct |
βββββ | $0.60 | Complex tasks |
Qwen/Qwen2.5-72B-Instruct |
βββββ | $0.40 | Alternative |
π¦ Ollama (Local - Offline)
Overview
- Privacy: 100% local, offline
- Cost: Free (your hardware)
- Speed: Depends on hardware
- Setup Time: 15 minutes
Prerequisites
- 4GB+ RAM (for smaller models)
- 8GB+ RAM (for larger models)
- NVIDIA GPU (optional, for acceleration)
Step 1: Install Ollama
Linux:
curl -fsSL https://ollama.com/install.sh | sh
macOS:
brew install ollama
Windows:
- Download from ollama.com
- Run installer
Step 2: Start Ollama Service
# Start Ollama (runs in background)
ollama serve
Step 3: Pull Models
# Small & fast (recommended for grammar)
ollama pull qwen2.5:0.5b # 400MB, very fast
ollama pull qwen2.5:1.5b # 1GB, balanced
# Medium quality
ollama pull phi4-mini:3.8b # 2.5GB, great quality
ollama pull llama3.2:3b # 2GB, good balance
# High quality (requires GPU)
ollama pull llama3.2:7b # 4GB, requires 8GB+ RAM
ollama pull mistral:7b # 4GB, requires 8GB+ RAM
Step 4: Test Ollama
# Test the model
ollama run qwen2.5:1.5b "Fix this: me and him went to store"
Expected output:
"He and I went to the store."
Step 5: Configure in Extension
- Click OpenGrammar icon β Settings
- Provider: Ollama (Local)
- Base URL:
http://localhost:11434/v1 - Model:
qwen2.5:1.5b(or your chosen model) - API Key: (leave empty - not needed)
- Click Save
Model Recommendations
| Use Case | Model | RAM | Speed | Quality |
|---|---|---|---|---|
| Basic grammar | qwen2.5:0.5b | 1GB | β‘β‘β‘β‘β‘ | βββ |
| Better accuracy | qwen2.5:1.5b | 2GB | β‘β‘β‘β‘ | ββββ |
| Professional writing | phi4-mini:3.8b | 4GB | β‘β‘β‘ | βββββ |
| Best quality | llama3.2:7b | 8GB | β‘β‘ | βββββ |
GPU Acceleration (NVIDIA)
# Install NVIDIA Container Toolkit
sudo apt-get install -y nvidia-container-toolkit
# Configure Docker
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
# Ollama will automatically use GPU
ollama run llama3.2:7b
Troubleshooting
- Error: Connection refused - Make sure Ollama is running:
ollama serve - Error: Model not found - Pull the model:
ollama pull qwen2.5:1.5b - Slow performance - Use smaller model or enable GPU
π§ Custom Provider
Overview
Use your own API endpoint or any OpenAI-compatible API.
Configuration
- Click OpenGrammar icon β Settings
- Provider: Custom
- Base URL:
https://your-api.com/v1 - API Key: (your API key)
- Model: (your model name)
- Click Save
Example: LocalAI
# Run LocalAI with Docker
docker run -p 8080:8080 localai/localai
# Configure in extension
Provider: Custom
Base URL: http://localhost:8080/v1
Model: llama-3.1-70b
Example: LM Studio
# LM Studio runs locally
# Configure in extension
Provider: Custom
Base URL: http://localhost:1234/v1
Model: local-model
π Provider Comparison
Speed Comparison
Groq (Llama-70B) ββββββββββββββββββββ 200ms
OpenAI (GPT-4o-mini) ββββββββββ 1s
Together (Llama-70B) ββββββββββββ 800ms
OpenRouter (Claude) ββββββββββββββββββ 2s
Ollama (Qwen-1.5B) ββββββββββββββ 500ms (local)
Quality Comparison
OpenAI (GPT-4o) ββββββββββββββββββββ 96%
OpenRouter (Claude) ββββββββββββββββββββ 96%
OpenAI (GPT-4o-mini) ββββββββββββββββββ 95%
Groq (Llama-70B) ββββββββββββββββ 92%
Ollama (Phi-4-mini) ββββββββββββββ 88%
Ollama (Qwen-1.5B) ββββββββββββ 82%
Cost Comparison (per 1K requests)
Ollama (Local) $0.00 (free)
Groq (Free tier) $0.00 (100/day free)
Together (Llama-70B) $0.40
OpenAI (GPT-4o-mini) $0.15
OpenRouter (Claude) $3.00
π― Provider Selection Guide
Choose Groq If:
- β You want free usage
- β You need fast responses
- β You're okay with 100 requests/day limit
- β You want good quality
Choose OpenAI If:
- β You want the best quality
- β You don't mind paying
- β You need reliability
- β You want GPT-4 level intelligence
Choose OpenRouter If:
- β You want model variety
- β You want to try Claude
- β You want flexibility
- β You need specific models
Choose Together AI If:
- β You want cheap open-source
- β You like Llama models
- β You want good value
- β You need fast inference
Choose Ollama If:
- β Privacy is your priority
- β You have good hardware
- β You want offline access
- β You don't want API costs
π Switching Providers
You can switch providers anytime:
- Click OpenGrammar icon
- Click Settings
- Change Provider dropdown
- Enter new API key (if required)
- Select new Model
- Click Save
Your settings are saved automatically.
π Related Documentation
- Backend Deployment - Deploy your backend
- Docker Self-Hosting - Run locally
- Troubleshooting - Common issues
Your AI provider is now configured! Start writing better! β¨