Swadhin Biswas

[email protected]
2026-02-28 02:34:46 +0600 committed NaN years ago
465de9b
commit 465de9b
1 file changed
+196 -0
Showing 1 changed file+196-0
β–Όopengrammar/GROQ_SETUP.md
+196-0
1
+# πŸš€ Quick Start with Groq API
2
+
3
+## Step 1: Get Your Free Groq API Key
4
+
5
+1. Visit: https://console.groq.com
6
+2. Sign up / Log in
7
+3. Go to **API Keys** section
8
+4. Click **Create API Key**
9
+5. Copy your API key (starts with `gsk_`)
10
+
11
+**Free Tier Limits:**
12
+- 100 requests/day
13
+- Fast inference (LPU technology)
14
+- Access to Llama 3.1 70B, Mixtral, Gemma, etc.
15
+
16
+---
17
+
18
+## Step 2: Configure Backend
19
+
20
+1. **Edit `.env` file:**
21
+ ```bash
22
+ cd opengrammar/backend
23
+ nano .env # or use your favorite editor
24
+ ```
25
+
26
+2. **Add your Groq API key:**
27
+ ```env
28
+ GROQ_API_KEY=gsk_your_actual_api_key_here
29
+ ```
30
+
31
+3. **Save the file**
32
+
33
+---
34
+
35
+## Step 3: Test Groq Integration
36
+
37
+### Option A: Test with Test Script
38
+
39
+```bash
40
+cd opengrammar/backend
41
+node test-groq.js
42
+```
43
+
44
+**Expected Output:**
45
+```
46
+πŸ§ͺ Testing Groq Grammar Check API...
47
+
48
+Input text: me and him went to the store and buyed some milks
49
+
50
+Sending request to Groq...
51
+
52
+βœ… Success! Response:
53
+{
54
+ "issues": [
55
+ {
56
+ "type": "grammar",
57
+ "original": "me and him",
58
+ "suggestion": "he and I",
59
+ "reason": "Subject pronoun error"
60
+ },
61
+ {
62
+ "type": "spelling",
63
+ "original": "buyed",
64
+ "suggestion": "bought",
65
+ "reason": "Irregular verb form"
66
+ }
67
+ ]
68
+}
69
+
70
+βœ… Found 2 issues:
71
+...
72
+```
73
+
74
+### Option B: Start Backend Server
75
+
76
+```bash
77
+npm run dev
78
+```
79
+
80
+Server will start on `http://localhost:8787`
81
+
82
+---
83
+
84
+## Step 4: Configure Extension
85
+
86
+1. **Click extension icon** in Chrome
87
+
88
+2. **Select Provider:** Groq
89
+
90
+3. **Enter API Key:** (same key from Step 1)
91
+
92
+4. **Select Model:** `llama-3.1-70b-versatile` (recommended)
93
+
94
+5. **Verify Connection:** Green dot should appear
95
+
96
+---
97
+
98
+## Step 5: Test Grammar Checking
99
+
100
+1. **Open any text box** (Gmail, Google Docs, etc.)
101
+
102
+2. **Type text with errors:**
103
+ ```
104
+ me and him went to store and buyed milks
105
+ ```
106
+
107
+3. **Wait 1 second** - Grammar highlights should appear
108
+
109
+4. **Click highlight** to see suggestions
110
+
111
+5. **Click "Apply"** to fix the error
112
+
113
+---
114
+
115
+## 🎯 Recommended Groq Models
116
+
117
+| Model | Speed | Quality | Best For |
118
+|-------|-------|---------|----------|
119
+| **llama-3.1-70b-versatile** | ⚑⚑⚑ | ⭐⭐⭐⭐⭐ | General grammar checking |
120
+| **llama-3.1-8b-instant** | ⚑⚑⚑⚑ | ⭐⭐⭐⭐ | Fast, simple checks |
121
+| **mixtral-8x7b-32768** | ⚑⚑ | ⭐⭐⭐⭐⭐ | Complex writing |
122
+| **gemma2-9b-it** | ⚑⚑⚑ | ⭐⭐⭐⭐ | Balanced performance |
123
+
124
+---
125
+
126
+## πŸ”§ Troubleshooting
127
+
128
+### Error: "Invalid API key"
129
+- Check your API key in `.env` file
130
+- Make sure there are no spaces
131
+- Key should start with `gsk_`
132
+
133
+### Error: "Rate limit exceeded"
134
+- Groq free tier: 100 requests/day
135
+- Wait 24 hours or upgrade plan
136
+
137
+### Backend won't start
138
+```bash
139
+# Check if Groq SDK is installed
140
+npm install
141
+
142
+# Check TypeScript
143
+npx tsc --noEmit
144
+
145
+# Restart server
146
+npm run dev
147
+```
148
+
149
+### No grammar highlights
150
+- Verify backend is running: `curl http://localhost:8787/health`
151
+- Check extension settings β†’ Provider should be "Groq"
152
+- Check browser console for errors (F12)
153
+
154
+---
155
+
156
+## πŸ“Š API Usage
157
+
158
+### Check Usage Dashboard
159
+Visit: https://console.groq.com/usage
160
+
161
+### Monitor in Real-Time
162
+```bash
163
+# Backend logs
164
+npm run dev
165
+
166
+# Watch for API calls
167
+# Look for: "LLM Analysis Error (groq):" in console
168
+```
169
+
170
+---
171
+
172
+## πŸ’‘ Tips
173
+
174
+1. **Use `.env` for testing** - Don't commit API keys to git
175
+2. **Start with llama-3.1-70b** - Best balance of speed/quality
176
+3. **Test with test-groq.js first** - Easier to debug
177
+4. **Monitor usage** - Free tier resets daily
178
+5. **Upgrade when ready** - Paid plans available
179
+
180
+---
181
+
182
+## πŸŽ‰ You're Ready!
183
+
184
+Your OpenGrammar backend is now powered by **Groq's blazing-fast LPU inference**!
185
+
186
+**Next Steps:**
187
+1. Test with real text in browser
188
+2. Try different Groq models
189
+3. Compare with other providers (OpenAI, Ollama)
190
+4. Deploy to production when ready
191
+
192
+---
193
+
194
+**Need Help?**
195
+- Groq Docs: https://console.groq.com/docs
196
+- OpenGrammar Docs: `TESTING_GUIDE.md`, `SELF_HOSTING.md`
0
197