ai-doctor
v2.0.4
Published
Fix OpenAI 429 errors, timeouts, streaming issues, retry loops, and token cost spikes across OpenAI, Claude, Gemini, LangChain, OpenClaw, and other LLM stacks.
Maintainers
Readme
AI Doctor - Fix OpenAI 429 Errors, Timeouts & Streaming Issues
Works across OpenAI, Claude, Gemini, OpenClaw, LangChain, and other LLM stacks.
Fix common LLM API errors like 429 rate limits, timeouts, streaming hangs, retry loops, and runaway token costs.
AI Doctor scans your codebase and shows exactly what is breaking - then helps you fix it automatically.
Works with
Providers
- OpenAI API
- Anthropic Claude API
- Google Gemini API
- Grok
- OpenRouter
- Together AI
- Fireworks AI
- Replicate
- DeepSeek, Mistral, Cohere (OpenAI-compatible)
Frameworks & SDKs
- OpenClaw
- LangChain
- Vercel AI SDK
- LlamaIndex
- Custom OpenAI-compatible clients
- Node.js / JavaScript backends
Quick start
npx ai-doctorTakes ~30 seconds. No config needed.
What AI Doctor detects & fixes
Rate limits (429 errors)
- Fix OpenAI 429 RESOURCE_EXHAUSTED
- Fix LangChain / OpenClaw retry issues
- Add exponential backoff + jitter
- Handle Retry-After correctly
Timeouts & hanging requests
- Fix context deadline exceeded
- Fix Vercel AI SDK timeout issues
- Prevent stuck API calls
- Add safe timeout guards
Streaming issues (SSE problems)
- Fix OpenAI / Claude streaming hangs
- Fix incomplete responses
- Fix SSE not flushing correctly
- Detect broken streaming pipelines
Retry problems
- Fix retry storms in LangChain / custom code
- Add retry limits
- Prevent infinite loops
Cost issues
- Prevent runaway token usage
- Fix missing or incorrect max_tokens
- Reduce unexpected cost spikes
Debugging & traceability
- Add request IDs
- Fix missing correlation IDs
- Improve logging for production debugging
Common errors this helps with
- 429 RESOURCE_EXHAUSTED
- context deadline exceeded
- socket hang up
- ECONNRESET
- 504 Gateway Timeout
- streaming response stuck / incomplete
- OpenAI timeout errors
- Claude streaming issues
- Gemini API failures
- LangChain retry bugs
- OpenClaw streaming / retry issues
Why use AI Doctor?
Most AI apps break in the same ways:
- Bad retry logic -> 429 errors + rate limits
- No timeouts -> requests hang forever
- Broken streaming -> partial responses
- No token limits -> runaway costs
- No tracing -> hard to debug production issues
AI Doctor finds all of this automatically.
Commands
npx ai-doctor # Scan + interactive fix
npx ai-doctor --fix # Auto-fix issues
npx ai-doctor --ci # Report only (CI mode)Install
npm install -g ai-doctorDocumentation
https://github.com/michaelbrinkworth/ai-patch-doctor
Keywords
- openai 429 error fix
- openai timeout fix
- openai streaming issue
- langchain 429 error
- vercel ai sdk timeout
- openclaw streaming issue
- anthropic api error fix
- gemini api timeout
- llm retry logic
- llm debugging tool
- llm cost control
- ai api errors
- llm observability cli
MIT License - Fix your AI API issues in minutes.
