Overview
Bring Your Own Key (BYOK) allows you to use your personal API keys from AI providers instead of WhatDoc’s shared quota. This unlocks:- Unlimited generation: No tier limits
- Advanced models: Access to GPT-4, Claude, and Gemini Pro
- Cost control: Pay only for what you use
- Privacy: Keys are never stored in the database
How BYOK Works
When you provide a custom API key during project configuration:- The key is stored in your browser’s
localStorage - On project creation, the key is sent via HTTP headers:
x-custom-api-key: Your API keyx-target-model: Selected model ID (e.g.,gemini-2.5-pro)
- The backend relays the key to the AI provider for generation
- The key is never persisted in the WhatDoc database
- After generation, the key is discarded from the server
Your API key stays in your browser and is sent directly to the AI provider. WhatDoc acts as a secure relay without storing sensitive credentials.
Supported Providers
Google Gemini
Free Models (no key required):gemini-2.5-flash-lite(default, fastest)gemini-2.5-flash
gemini-2.5-pro
- Visit Google AI Studio
- Sign in with your Google account
- Click Create API Key
- Copy the key (format:
AIzaSy...)
OpenAI
Available Models:gpt-4ogpt-4o-mini
- Visit OpenAI Platform
- Sign in or create an account
- Click Create new secret key
- Copy the key (format:
sk-proj-...)
Anthropic
Available Models:claude-3.7-sonnetclaude-3.5-haiku
- Visit Anthropic Console
- Sign in or create an account
- Click Create Key
- Copy the key (format:
sk-ant-...)
Using BYOK
Select a Model
Choose your desired model from the dropdown:
- Gemini: Free models available without key
- OpenAI: Requires API key for all models
- Anthropic: Requires API key for all models
Enter Your API Key
Paste your API key into the API Key field.The placeholder text changes based on the selected provider:
- Gemini:
AIzaSy... (leave blank for free models) - OpenAI:
sk-proj-... (API Key required) - Anthropic:
sk-ant-... (API Key required)
Your key is validated by length (>20 characters) but not authenticated until generation starts.
Model Selector Component
The model selector dynamically adjusts based on whether you’ve provided a key:- If
hasCustomKeyisfalse, premium models show a lock icon and triggeronRequestKeyon selection - If
hasCustomKeyistrue, all models are unlocked
Security & Privacy
Your API key is NEVER stored in the WhatDoc database.
- localStorage: Key is stored locally in your browser
- HTTPS Headers: Key is transmitted securely via
x-custom-api-keyheader - Server Relay: WhatDoc relays the key to the AI provider’s API
- No Persistence: The key is discarded after the request completes
- No Logs: Keys are not logged or stored in any backend system
Backend Validation
On the server, keys are validated but never saved:Cost Estimation
Gemini
- Free Tier: 15 requests per minute, 1,500 requests per day
- Paid Tier: 1.25 per 1M input tokens (Pro)
- Small repo (1,000 files): ~500K tokens → 0.63 (Pro)
- Large repo (10,000 files): ~5M tokens → 6.25 (Pro)
OpenAI
- GPT-4o: 10 per 1M output tokens
- GPT-4o-mini: 0.60 per 1M output tokens
- Small repo: ~500K tokens → 0.08 (4o-mini)
- Large repo: ~5M tokens → 0.75 (4o-mini)
Anthropic
- Claude 3.7 Sonnet: 15 per 1M output tokens
- Claude 3.5 Haiku: 1.25 per 1M output tokens
- Small repo: ~500K tokens → 0.13 (Haiku)
- Large repo: ~5M tokens → 1.25 (Haiku)
Actual costs vary based on repository size, code complexity, and output length. These are rough estimates.
Tier Limits with BYOK
When using a custom API key, WhatDoc bypasses tier limits:- Free Tier: No generation count increment
- Pro Tier: No repository limit enforcement
- Rate Limits: Subject only to your API provider’s limits
Removing Your API Key
To stop using BYOK:- Clear the API Key field on the
/configurepage - Click Deploy Documentation
- Or clear it from localStorage:
Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| ”API Key required” | Selected premium model without key | Enter your API key or switch to free model |
| Generation fails with 401 | Invalid or expired API key | Verify key is correct and has billing enabled |
| Generation fails with 429 | Rate limit exceeded | Wait and retry, or upgrade your API plan |
| Key not recognized | Less than 20 characters | Ensure you copied the full key |
| Model unavailable | Provider outage | Check provider status page |
Debugging BYOK
If generation fails with a custom key:- Verify Key: Test the key directly via provider’s API playground
- Check Billing: Ensure your provider account has active billing
- Check Quota: Verify you haven’t exceeded rate limits
- Check Format: Ensure key matches expected format:
- Gemini:
AIzaSy... - OpenAI:
sk-proj-... - Anthropic:
sk-ant-...
- Gemini:
Best Practices
Do:
- Use free Gemini models for testing
- Monitor your API usage via provider dashboards
- Set up billing alerts to avoid surprise charges
- Keep your API keys secure and never share them
- Rotate keys periodically for security
What’s Next?
Generating Docs
Learn the full documentation generation process
Customizing Docs
Customize your documentation with logos and branding
