The ultimate development companion for building reliable LLM applications
Real-time monitoring, error simulation, and seamless API inspection in action
LLM Doctor is a sophisticated monitoring and testing tool designed for developers building applications with Large Language Model APIs. It provides a complete OpenAI-compatible server with real-time monitoring, error simulation, and passthrough capabilities.
- 🔍 Debug with Confidence: See exactly what your app sends and receives
- 💥 Test Error Handling: Simulate realistic API errors before they hit production
- 📊 Performance Insights: Track tokens, timing, and throughput in real-time
- 🔄 Seamless Integration: Drop-in replacement for OpenAI API endpoints
- 🎨 Beautiful TUI: Professional terminal interface for monitoring
Simulate real-world LLM API errors to test your application's resilience:
- Safety Content Filter (Microsoft/Azure style)
- Rate Limit Exceeded (429 errors)
- Model Overloaded (503 errors)
- Request Timeout (504 errors)
- Context Length Exceeded (token limit errors)
- Invalid Request (400 validation errors)
- Authentication Errors (401 errors)
Access via keyboard shortcut m for instant error injection.
Professional terminal UI with 5 specialized panels:
- 📝 Request History - All API calls with status indicators
- 💬 Messages - Request payloads with expandable messages
- 🤖 Response - Complete response content and metadata
- 🔧 Tools - Full tool definitions (non-truncated JSON!)
- 📋 Headers - HTTP headers for debugging
Toggle between fake responses and real OpenAI API:
- Instant switching with
pkey - Perfect for integration testing
- Preserves all monitoring capabilities
- Token counting (prompt, completion, total)
- Request/response timing
- Requests per minute
- Success/error rates
- Live performance metrics
Full support for:
- ✅ Chat Completions (
/v1/chat/completions) - ✅ Text Completions (
/v1/completions) - ✅ Embeddings (
/v1/embeddings) - ✅ Streaming responses (SSE)
- ✅ Tool/Function calling
- ✅ Models listing (
/v1/models)
No installation required! Run directly with npx:
# Start with default settings
npx llm-doctor
# With custom port
npx llm-doctor --port 3000
# With OpenAI API key for passthrough mode
npx llm-doctor --api-key sk-...
# All options
npx llm-doctor --port 8080 --host localhost --api-key sk-...npm install -g llm-doctor
# Then run anywhere
llm-doctor
llm-doctor --port 3000# Clone the repository
git clone https://github.com/Scriptor-Group/llm-doctor.git
cd llm-doctor
# Install dependencies
npm install
# Start the server
npm start
# Or with development mode (auto-reload)
npm run devllm-doctor [options]
Options:
-p, --port <port> Port to listen on (default: 8032)
-h, --host <host> Host to bind to (default: 0.0.0.0)
-k, --api-key <key> OpenAI API key for passthrough mode
--help Show help message
Examples:
llm-doctor
llm-doctor --port 3000
llm-doctor --api-key sk-...
npx llm-doctor --port 8080 --api-key sk-...The server will start on http://localhost:8032 by default
Point your LLM application to LLM Doctor instead of OpenAI:
// Before
const openai = new OpenAI({
baseURL: "https://api.openai.com/v1",
});
// After - with LLM Doctor
const openai = new OpenAI({
baseURL: "http://localhost:8000/v1",
});| Key | Action |
|---|---|
Tab |
Switch between panels |
↑ / ↓ |
Navigate requests/scroll content |
Enter |
Select request to view details |
Space |
Toggle message expansion |
m |
Open error simulation menu |
k |
Set OpenAI API key (in-app) |
p |
Toggle passthrough mode (Fake ↔ Real API) |
f |
Fullscreen current panel |
Esc |
Exit fullscreen |
r |
Refresh display |
q |
Quit (press twice) |
Ctrl+C |
Force quit |
- Press
mto open the error menu - Select the error type you want to simulate
- Make API requests - they'll return the simulated error
- Select "None" to disable error simulation
Perfect for testing:
- Retry logic
- Error handling
- User-facing error messages
- Graceful degradation
- Circuit breakers
Enable real OpenAI API forwarding in three ways:
1. CLI argument (recommended for testing):
npx llm-doctor --api-key sk-...2. In-app (recommended for security):
- Press
kin the UI - Enter your API key (hidden with *)
- Key stored in memory only, never saved to disk
3. Environment variable:
# Create .env file
echo "OPENAI_API_KEY=sk-..." > .env
# Start server
npm startPress p in the UI to toggle passthrough mode on/off. All requests are forwarded to real OpenAI API while maintaining full monitoring!
Test your LLM application against various API responses without burning tokens:
// Your test suite
describe("LLM Error Handling", () => {
it("handles rate limits gracefully", async () => {
// Manually trigger rate limit in LLM Doctor (press 'm', select 'Rate Limit')
const response = await callYourLLMFunction();
expect(response.error).toBeDefined();
expect(response.retryAfter).toBe(60);
});
});- Inspect exact request/response payloads
- Verify token counts match expectations
- Check tool calling parameters
- Debug streaming issues
- Monitor requests per minute under load
- Track average response times
- Measure token consumption
- Identify bottlenecks
- Understand OpenAI API structure
- Learn about different error types
- Experiment with parameters safely
- Study streaming protocols
Contributions are welcome! This is an open-source project under a non-commercial license.
- Fork the repository
- Create a feature branch
- Follow existing code style (TypeScript strict mode)
- Maintain separation of concerns
- Add types for all new code
- Test your changes
- Submit a pull request
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
You are free to:
- ✅ Use for personal projects
- ✅ Use for educational purposes
- ✅ Modify and adapt the code
- ✅ Share with others
Under the following terms:
- 📝 Attribution - Give appropriate credit
- 🚫 NonCommercial - Not for commercial use
- 🔄 ShareAlike - Share adaptations under the same license
For commercial licensing, please contact the author.
See LICENSE for full details.
Built with:
- Express - Web framework
- Blessed - Terminal UI
- TypeScript - Type safety
Inspired by the need for better LLM development tools.
Développé avec ❤️ par les équipes de Devana
Made with ❤️ for the LLM developer community
⭐ Star this repo if you find it useful!
