AI Assistant
Built-in AI that understands your API
Bytedocs includes a built-in AI assistant that has complete context of your API and can answer questions, provide code examples, and help debug integration issues.
Supported AI Providers
Bytedocs supports multiple AI providers:
| Provider | Models | Best For |
|---|---|---|
| OpenAI | GPT-4, GPT-4o-mini, GPT-3.5-turbo | Best overall quality |
| Google Gemini | gemini-1.5-flash, gemini-1.5-pro | Fast responses, free tier |
| Anthropic Claude | claude-3-sonnet, claude-3-haiku | Technical accuracy |
| OpenRouter | 100+ models | Access to all models |
Setup
1. Get API Key
Choose your provider and get an API key:
- OpenAI: platform.openai.com/api-keys
- Google Gemini: aistudio.google.com/app/apikey
- Anthropic: console.anthropic.com
- OpenRouter: openrouter.ai/keys
2. Configure
Environment Variables:
Go Configuration:
Laravel Configuration:
3. Use the Assistant
Visit /docs and click the chat icon in the bottom-right corner.
How It Works
Complete API Context
When you ask a question, the AI receives:
- Full OpenAPI Specification: All endpoints, schemas, parameters
- Validation Rules: Required fields, data types, constraints
- Example Values: Real example requests and responses
- Your Question: What you're asking about
Example Context
What You Can Ask
API Usage Questions
"How do I create a user?"
Integration Help
"How do I authenticate with this API?"
Code Examples
"Show me Python code to get all users"
Debugging Help
"Why am I getting a 400 error when creating a user?"
Endpoint Discovery
"What endpoints are available for user management?"
Model Selection Guide
GPT-4o-mini (Recommended)
- Cost: $0.15/1M input tokens, $0.60/1M output tokens
- Speed: Fast
- Quality: Excellent for API questions
- Best for: Most use cases
GPT-4
- Cost: $30/1M input tokens, $60/1M output tokens
- Speed: Moderate
- Quality: Best available
- Best for: Complex queries, code generation
Gemini 1.5 Flash (Free Tier Available)
- Cost: Free tier: 15 RPM, paid: $0.07/1M tokens
- Speed: Very fast
- Quality: Good
- Best for: High volume, budget-conscious
Claude 3 Haiku
- Cost: $0.25/1M input tokens, $1.25/1M output tokens
- Speed: Very fast
- Quality: Good technical accuracy
- Best for: Technical documentation
OpenRouter
- Cost: Varies by model
- Speed: Varies
- Quality: Access to 100+ models
- Best for: Flexibility, trying different models
Configuration Options
Temperature
Controls response randomness:
Max Tokens
Limits response length:
Max Completion Tokens
Limits only the AI's response (excluding prompt):
Cost Management
Estimate Costs
Approximate costs per question:
| Model | Cost per Question |
|---|---|
| GPT-4o-mini | $0.001 - $0.002 |
| GPT-4 | $0.05 - $0.10 |
| Gemini Flash | Free (15 RPM) |
| Claude Haiku | $0.002 - $0.004 |
Optimization Tips
- Use smaller models for simple questions (GPT-4o-mini, Gemini Flash)
- Limit max tokens to reduce costs
- Use free tiers when available (Gemini)
- Cache common questions (future feature)
- Monitor usage via provider dashboards
Security & Privacy
What Gets Sent
✅ Sent to AI:
- Your question
- API specification (routes, schemas)
- Validation rules
- Example values
❌ NOT Sent:
- Actual API data
- User information
- Secrets or credentials
- Handler implementation code
- Database queries
Best Practices
- Use environment variables for API keys
- Restrict documentation access if using sensitive API schemas
- Monitor AI provider usage for unexpected activity
- Consider self-hosted models for highly sensitive APIs
Troubleshooting
AI Not Responding
Check:
- API key is correct
- Provider is reachable
- Rate limits not exceeded
- Model name is correct
Debug:
"Rate limit exceeded"
Solution:
- Wait a few minutes
- Upgrade your plan
- Switch to different provider
- Reduce max_tokens
Poor Quality Responses
Try:
- Use a better model (GPT-4 vs GPT-4o-mini)
- Adjust temperature (lower for factual, higher for creative)
- Rephrase your question
- Provide more context in your question
"Cannot answer non-API questions"
Expected Behavior: The AI is instructed to only answer API-related questions.
To override (if needed):
API Endpoint
The AI chat is accessible via:
Response:
What's Next?
- Scenarios - Create test scenarios
- Interactive Testing - Test your API
- Configuration - Advanced configuration