Troubleshooting How-To Guides
Fix the errors, crashes, and gotchas people hit with AI tools. Each guide isolates one problem and the exact steps to clear it.
API Errors & Auth
How to Fix an OpenAI 401 'Invalid API Key' Error
Track down why the OpenAI API rejects your key and get a valid request flowing again.
How to Fix OpenAI 429 Rate Limit Errors With Backoff
Stop your app from crashing on 429s by adding exponential backoff and reading the retry headers.
How to Fix Anthropic Claude API 401 Authentication Errors
Resolve authentication_error responses from the Claude API by fixing the header and key format.
How to Fix Google Gemini 'API Key Not Valid' Errors
Get Gemini API requests working by enabling the API, fixing key restrictions, and using the right endpoint.
How to Fix an API Key That Loads as Undefined
Solve the classic 'undefined API key' bug by loading your .env file correctly in Node and Python.
How to Handle Anthropic 529 'Overloaded' Errors
Keep your Claude integration stable when the API returns 529 overloaded_error by retrying gracefully.
How to Fix Rate Limit Errors from an AI API
Diagnose a 429 rate-limit error and add backoff, batching, and concurrency control so your calls stop getting throttled.
How to Fix CORS Errors When Calling an AI API From the Browser
Stop CORS failures and protect your key by routing AI API calls through a small backend proxy.
How to Fix 'Model Not Found' and Deprecated Model Errors
Resolve model_not_found errors caused by typos, retired models, or access your account lacks.
How to Rotate a Leaked API Key Without Downtime
Respond to a committed or exposed API key safely by rotating it and purging it from history.
How to Fix SSL Certificate Errors When Calling AI APIs
Resolve SSL certificate verify failed errors the safe way instead of disabling verification.
Tokens & Context
How to count tokens before sending a prompt to Claude
Use the count_tokens endpoint to measure a prompt accurately so you never guess at size or cost.
How to Fix 'Context Length Exceeded' Token Limit Errors
Resolve maximum context length errors by counting tokens, trimming input, and chunking long documents.
How to fix a context length exceeded error in the Claude API
Diagnose and resolve a request that overflows the model context window by counting tokens and trimming the prompt.
How to fix a Claude response that gets cut off mid-sentence
Detect a max_tokens cutoff, raise the limit, and switch to streaming so long outputs finish cleanly.
How to reduce Claude hallucinations by grounding answers in your documents
Cut fabricated facts by feeding source documents into the prompt and turning on citations so every claim is traceable.
How to keep a long Claude conversation under the context limit
Turn on server-side compaction so a multi-turn chat summarizes its own history before it overflows the window.
How to stop Claude from calling tools when it should not
Fix overtriggering by softening aggressive prompt language and tuning effort instead of adding more guardrails.
How to handle a Claude Fable 5 refusal with a fallback model
Detect the refusal stop reason and opt into a server-side fallback so a declined request is re-served by another model.
Cost & Reliability
How to choose the right Claude model for cost and quality
Match Haiku, Sonnet, Opus, or Fable to your task so you neither overpay nor underpower the job.
How to cut Claude API costs with prompt caching
Cache a large stable prefix so repeated requests pay roughly a tenth of the input price for the cached part.
How to halve Claude costs for bulk jobs with the Batch API
Send non-urgent work through the Message Batches API to get 50 percent off standard token prices.
How to cap spend on a Claude agent with a task budget
Give an agentic loop a token budget so the model paces itself and finishes gracefully instead of running away.
How to Debug an MCP Server That Will Not Connect
Work through the common reasons a Model Context Protocol server shows as failed and get it back to connected.
How to Ask an Agent to Explain a Bug Before Fixing It
Make the agent state the root cause first so you can confirm the diagnosis before it writes a fix that masks the real problem.
How to Roll Back a Bad Deploy Quickly
Get a broken release reverted in seconds by promoting the last good deploy instead of debugging in production.
How to Fix Cursor Not Indexing Your Codebase
Diagnose why Cursor's codebase answers feel blind and force a clean re-index so it sees your whole project again.