Skip to content

Commit 3e56c74

Browse files
committed
docs: add API key permissions/scopes documentation (#1841)
1 parent cb3c536 commit 3e56c74

File tree

2 files changed

+352
-0
lines changed

2 files changed

+352
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ The desktop app provides the same full functionality as the web version with add
207207

208208
Bolt.diy features a modern, intuitive settings interface for managing AI providers and API keys. The settings are organized into dedicated panels for easy navigation and configuration.
209209

210+
> 📖 **For detailed API key permissions and security best practices**, see [docs/api-keys.md](docs/api-keys.md)
211+
210212
### Accessing Provider Settings
211213

212214
1. **Open Settings**: Click the settings icon (⚙️) in the sidebar to access the settings panel

docs/api-keys.md

Lines changed: 350 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,350 @@
1+
# API Key Permissions & Scopes
2+
3+
This document provides detailed information about all API keys used in bolt.diy, their minimal required permissions, and security best practices. Understanding these requirements helps you maintain better security while ensuring all features work correctly.
4+
5+
## Table of Contents
6+
7+
- [AI Provider API Keys](#ai-provider-api-keys)
8+
- [Cloud Service Integrations](#cloud-service-integrations)
9+
- [Version Control Integrations](#version-control-integrations)
10+
- [Security Best Practices](#security-best-practices)
11+
- [Troubleshooting](#troubleshooting)
12+
13+
---
14+
15+
## AI Provider API Keys
16+
17+
These keys are used for AI model inference and chat functionality. All AI providers require API access for text generation.
18+
19+
### OpenAI
20+
- **Environment Variable:** `OPENAI_API_KEY`
21+
- **Get Key:** https://platform.openai.com/api-keys
22+
- **Required Permissions:** Standard API access (no special scopes)
23+
- **Usage in bolt.diy:** Text generation, code completion, chat responses
24+
- **Rate Limits:** Varies by plan (see OpenAI documentation)
25+
- **Security Notes:** Keep this key private; it provides access to paid API usage
26+
27+
### Anthropic Claude
28+
- **Environment Variable:** `ANTHROPIC_API_KEY`
29+
- **Get Key:** https://console.anthropic.com/
30+
- **Required Permissions:** Standard API access
31+
- **Usage in bolt.diy:** Alternative AI model for text generation and chat
32+
- **Rate Limits:** Based on your Anthropic plan
33+
- **Security Notes:** Anthropic keys have built-in safety mechanisms
34+
35+
### Google Gemini
36+
- **Environment Variable:** `GOOGLE_GENERATIVE_AI_API_KEY`
37+
- **Get Key:** https://makersuite.google.com/app/apikey
38+
- **Required Permissions:** Generative AI API access
39+
- **Usage in bolt.diy:** Google's AI models for text generation
40+
- **Rate Limits:** Free tier available with limitations
41+
- **Security Notes:** Supports both free and paid tiers
42+
43+
### Groq (Fast Inference)
44+
- **Environment Variable:** `GROQ_API_KEY`
45+
- **Get Key:** https://console.groq.com/keys
46+
- **Required Permissions:** Standard API access
47+
- **Usage in bolt.diy:** High-speed inference for supported models
48+
- **Rate Limits:** Generous free tier available
49+
- **Security Notes:** Optimized for speed; great for development
50+
51+
### Hugging Face
52+
- **Environment Variable:** `HuggingFace_API_KEY`
53+
- **Get Key:** https://huggingface.co/settings/tokens
54+
- **Required Permissions:**
55+
- **Read access** to models and datasets
56+
- **Inference API** access (if using hosted models)
57+
- **Usage in bolt.diy:** Access to open-source models and inference endpoints
58+
- **Rate Limits:** Varies by model and subscription
59+
- **Security Notes:** Choose "Read" scope for minimal access
60+
61+
### Perplexity AI
62+
- **Environment Variable:** `PERPLEXITY_API_KEY`
63+
- **Get Key:** https://www.perplexity.ai/settings/api
64+
- **Required Permissions:** Standard API access
65+
- **Usage in bolt.diy:** Search-augmented language models
66+
- **Rate Limits:** Based on subscription plan
67+
- **Security Notes:** Provides real-time web search capabilities
68+
69+
### DeepSeek
70+
- **Environment Variable:** `DEEPSEEK_API_KEY`
71+
- **Get Key:** https://platform.deepseek.com/api_keys
72+
- **Required Permissions:** Standard API access
73+
- **Usage in bolt.diy:** Cost-effective coding and reasoning models
74+
- **Rate Limits:** Competitive pricing with good free tier
75+
- **Security Notes:** Specialized for code generation tasks
76+
77+
### Mistral AI
78+
- **Environment Variable:** `MISTRAL_API_KEY`
79+
- **Get Key:** https://console.mistral.ai/api-keys/
80+
- **Required Permissions:** Standard API access
81+
- **Usage in bolt.diy:** European AI provider with strong performance
82+
- **Rate Limits:** Various tiers available
83+
- **Security Notes:** GDPR-compliant European provider
84+
85+
### Together AI
86+
- **Environment Variable:** `TOGETHER_API_KEY`
87+
- **Get Key:** https://api.together.xyz/settings/api-keys
88+
- **Required Permissions:** Standard API access
89+
- **Usage in bolt.diy:** Access to various open-source models
90+
- **Rate Limits:** Pay-per-use pricing model
91+
- **Security Notes:** Supports many open-source models
92+
93+
### X.AI (Grok)
94+
- **Environment Variable:** `XAI_API_KEY`
95+
- **Get Key:** https://console.x.ai/
96+
- **Required Permissions:** Standard API access
97+
- **Usage in bolt.diy:** Access to Grok models
98+
- **Rate Limits:** Based on X.AI pricing plans
99+
- **Security Notes:** Relatively new provider; monitor usage
100+
101+
### Moonshot AI (Kimi)
102+
- **Environment Variable:** `MOONSHOT_API_KEY`
103+
- **Get Key:** https://platform.moonshot.ai/console/api-keys
104+
- **Required Permissions:** Standard API access
105+
- **Usage in bolt.diy:** Chinese AI provider with long context models
106+
- **Rate Limits:** Varies by plan
107+
- **Security Notes:** Specialized in long-context applications
108+
109+
### Cohere
110+
- **Environment Variable:** `COHERE_API_KEY`
111+
- **Get Key:** https://dashboard.cohere.ai/api-keys
112+
- **Required Permissions:** Standard API access
113+
- **Usage in bolt.diy:** Enterprise-focused language models
114+
- **Rate Limits:** Generous free tier for development
115+
- **Security Notes:** Strong enterprise security features
116+
117+
### Hyperbolic
118+
- **Environment Variable:** `HYPERBOLIC_API_KEY`
119+
- **Get Key:** https://app.hyperbolic.xyz/settings
120+
- **Required Permissions:** Standard API access
121+
- **Usage in bolt.diy:** Fast inference for various models
122+
- **Rate Limits:** Competitive pricing model
123+
- **Security Notes:** Focus on performance optimization
124+
125+
### OpenRouter
126+
- **Environment Variable:** `OPEN_ROUTER_API_KEY`
127+
- **Get Key:** https://openrouter.ai/keys
128+
- **Required Permissions:** Standard API access
129+
- **Usage in bolt.diy:** Meta-routing service for multiple AI providers
130+
- **Rate Limits:** Depends on underlying provider
131+
- **Security Notes:** Single key for multiple providers; monitor costs
132+
133+
---
134+
135+
## Cloud Service Integrations
136+
137+
These keys enable deployment and hosting features in bolt.diy.
138+
139+
### Vercel
140+
- **Environment Variable:** `VITE_VERCEL_ACCESS_TOKEN`
141+
- **Get Token:** https://vercel.com/account/tokens
142+
- **Required Permissions:**
143+
- **Deploy** - Create and manage deployments
144+
- **Project Management** - Create, read, update projects
145+
- **Domain Management** - Manage custom domains (optional)
146+
- **Usage in bolt.diy:** Deploy projects to Vercel hosting
147+
- **Security Notes:** Scope tokens to specific teams/projects when possible
148+
149+
### Netlify
150+
- **Environment Variable:** `VITE_NETLIFY_ACCESS_TOKEN`
151+
- **Get Token:** https://app.netlify.com/user/applications
152+
- **Required Permissions:**
153+
- **Site Management** - Create and deploy sites
154+
- **Build Hooks** - Trigger rebuilds
155+
- **Form Handling** - Access form submissions (if used)
156+
- **Usage in bolt.diy:** Deploy static sites and JAMstack applications
157+
- **Security Notes:** Regularly rotate tokens and monitor usage
158+
159+
### Supabase
160+
- **Environment Variables:**
161+
- `VITE_SUPABASE_URL` - Your project URL
162+
- `VITE_SUPABASE_ANON_KEY` - Public anonymous key
163+
- `VITE_SUPABASE_ACCESS_TOKEN` - Management token
164+
- **Get Keys:** https://supabase.com/dashboard → Your Project → Settings → API
165+
- **Required Permissions:**
166+
- **Anonymous Key:** Public access (safe to expose)
167+
- **Access Token:** Full project management access
168+
- **Usage in bolt.diy:** Database operations and backend services
169+
- **Security Notes:** Only the anon key should be public; keep access token private
170+
171+
---
172+
173+
## Version Control Integrations
174+
175+
These keys enable repository management and code synchronization features.
176+
177+
### GitHub
178+
- **Environment Variables:**
179+
- `VITE_GITHUB_ACCESS_TOKEN` - Main access token
180+
- `GITHUB_TOKEN` - Alternative token name
181+
- `GITHUB_API_KEY` - For GitHub Models API
182+
- **Get Token:** https://github.com/settings/tokens
183+
- **Required Permissions:**
184+
185+
**For Classic Personal Access Tokens:**
186+
-**repo** - Full repository access (private and public)
187+
-**read:user** - Read user profile information
188+
-**user:email** - Access user email addresses
189+
190+
**For Fine-grained Personal Access Tokens:**
191+
-**Contents** - Read/Write access to repository contents
192+
-**Metadata** - Read repository metadata
193+
-**Pull requests** - Create and manage pull requests
194+
-**Issues** - Create and manage issues (if using templates)
195+
196+
- **Usage in bolt.diy:**
197+
- Import/clone repositories
198+
- Create branches and commits
199+
- Push code changes
200+
- Access GitHub Models API (AI)
201+
- **Security Notes:** Use fine-grained tokens when possible; scope to specific repositories
202+
203+
### GitLab
204+
- **Environment Variables:**
205+
- `VITE_GITLAB_ACCESS_TOKEN` - Access token
206+
- `VITE_GITLAB_URL` - GitLab instance URL (default: https://gitlab.com)
207+
- `VITE_GITLAB_TOKEN_TYPE` - Token type (default: personal-access-token)
208+
- **Get Token:** https://gitlab.com/-/profile/personal_access_tokens
209+
- **Required Permissions:**
210+
-**api** - Full API access (includes project creation)
211+
-**read_repository** - Clone and read repositories
212+
-**write_repository** - Push commits and update branches
213+
- **Usage in bolt.diy:**
214+
- Import GitLab projects
215+
- Create new GitLab projects
216+
- Manage branches and commits
217+
- Access private repositories
218+
- **Security Notes:** Set appropriate expiration dates; monitor project access
219+
220+
---
221+
222+
## Local Development Options
223+
224+
### Ollama (Local Models)
225+
- **Environment Variable:** `OLLAMA_API_BASE_URL`
226+
- **Default Value:** `http://127.0.0.1:11434`
227+
- **Required Permissions:** None (local installation)
228+
- **Usage in bolt.diy:** Run AI models locally without API costs
229+
- **Security Notes:** Uses IPv4 (127.0.0.1) to avoid IPv6 issues
230+
- **Setup:** Install Ollama locally and pull desired models
231+
232+
### LM Studio (Local Models)
233+
- **Environment Variable:** `LMSTUDIO_API_BASE_URL`
234+
- **Default Value:** `http://127.0.0.1:1234`
235+
- **Required Permissions:** None (local installation)
236+
- **Usage in bolt.diy:** Alternative local model hosting
237+
- **Security Notes:** Enable CORS in LM Studio settings
238+
- **Setup:** Download LM Studio and load compatible models
239+
240+
---
241+
242+
## Security Best Practices
243+
244+
### 🔐 API Key Management
245+
246+
1. **Never commit API keys to version control**
247+
- Use `.env.local` for local development
248+
- Add `.env.local` to `.gitignore` (already included)
249+
- Use environment variables in production
250+
251+
2. **Use minimal required permissions**
252+
- Follow the principle of least privilege
253+
- Regularly audit and rotate keys
254+
- Monitor usage and costs
255+
256+
3. **Secure storage**
257+
- Use secure environment variable management in production
258+
- Consider using secret management services
259+
- Never log or expose keys in error messages
260+
261+
### 🚨 Key Rotation
262+
263+
- **Rotate keys regularly** (every 90 days recommended)
264+
- **Monitor for unusual usage patterns**
265+
- **Revoke compromised keys immediately**
266+
- **Update documentation when changing providers**
267+
268+
### 📊 Usage Monitoring
269+
270+
1. **Set up billing alerts** for paid services
271+
2. **Monitor API usage patterns** for anomalies
272+
3. **Track rate limit violations**
273+
4. **Review access logs regularly**
274+
275+
### 🔍 Testing & Validation
276+
277+
- **Test with minimal permissions first**
278+
- **Use development/staging keys when available**
279+
- **Validate key permissions before production use**
280+
- **Document any permission escalations needed**
281+
282+
---
283+
284+
## Troubleshooting
285+
286+
### Common Issues
287+
288+
#### ❌ "Invalid API Key" Errors
289+
- Verify the key is correctly set in `.env.local`
290+
- Check for extra spaces or characters
291+
- Ensure the key hasn't expired
292+
- Verify you're using the correct environment variable name
293+
294+
#### ❌ "Permission Denied" Errors
295+
- Review required permissions for the specific service
296+
- Check if your account has the necessary plan/subscription
297+
- Verify token scopes match requirements
298+
- Contact provider support if permissions seem correct
299+
300+
#### ❌ Rate Limit Errors
301+
- Check your current usage against plan limits
302+
- Implement proper rate limiting in your application
303+
- Consider upgrading your plan or using multiple providers
304+
- Add exponential backoff retry logic
305+
306+
#### ❌ CORS Issues (Local Development)
307+
- Verify base URLs use `127.0.0.1` instead of `localhost`
308+
- Enable CORS in local model servers (LM Studio, Ollama)
309+
- Check that ports match your local setup
310+
311+
### Getting Help
312+
313+
1. **Check provider documentation** for specific permission requirements
314+
2. **Review bolt.diy GitHub issues** for similar problems
315+
3. **Test with minimal configurations** to isolate issues
316+
4. **Use provider support channels** for key-specific problems
317+
318+
---
319+
320+
## Environment Setup
321+
322+
### Quick Start
323+
324+
1. **Copy the example file:**
325+
```bash
326+
cp .env.example .env.local
327+
```
328+
329+
2. **Add your API keys** to `.env.local`
330+
331+
3. **Start with one provider** to test configuration
332+
333+
4. **Restart your development server:**
334+
```bash
335+
pnpm run dev
336+
```
337+
338+
5. **Verify connections** in Settings → Providers tab
339+
340+
### Production Deployment
341+
342+
- Use your platform's environment variable system
343+
- Never expose API keys in client-side code (except `VITE_` prefixed public keys)
344+
- Use secure secret management for sensitive keys
345+
- Set up monitoring and alerting for key usage
346+
347+
---
348+
349+
*Last updated: September 2025*
350+
*For the latest information, check the [bolt.diy repository](https://github.com/stackblitz-labs/bolt.diy)*

0 commit comments

Comments
 (0)