In this categoryTroubleshooting ยท 27
- How to Fix an OpenAI 401 'Invalid API Key' ErrorStart
- How to Fix OpenAI 429 Rate Limit Errors With Backoff
- How to Fix Anthropic Claude API 401 Authentication Errors
- How to Fix Google Gemini 'API Key Not Valid' Errors
- How to Fix an API Key That Loads as Undefined
- How to Handle Anthropic 529 'Overloaded' Errors
- How to Fix Rate Limit Errors from an AI API
- How to Fix CORS Errors When Calling an AI API From the Browser
- How to Fix 'Model Not Found' and Deprecated Model Errors
- How to Rotate a Leaked API Key Without Downtime
- How to Fix SSL Certificate Errors When Calling AI APIs
- How to count tokens before sending a prompt to Claude
- How to Fix 'Context Length Exceeded' Token Limit Errors
- How to fix a context length exceeded error in the Claude API
- How to fix a Claude response that gets cut off mid-sentence
- How to reduce Claude hallucinations by grounding answers in your documents
- How to keep a long Claude conversation under the context limit
- How to stop Claude from calling tools when it should not
- How to handle a Claude Fable 5 refusal with a fallback model
- How to choose the right Claude model for cost and quality
- How to cut Claude API costs with prompt caching
- How to halve Claude costs for bulk jobs with the Batch API
- How to cap spend on a Claude agent with a task budget
- How to Debug an MCP Server That Will Not Connect
- How to Ask an Agent to Explain a Bug Before Fixing It
- How to Roll Back a Bad Deploy Quickly
- How to Fix Cursor Not Indexing Your Codebase
How to Fix SSL Certificate Errors When Calling AI APIs
Resolve SSL certificate verify failed errors the safe way instead of disabling verification.
A 'certificate verify failed' error blocks your request before it even reaches the AI provider. It usually means your machine cannot validate the provider's HTTPS certificate, often due to missing root certificates, a corporate proxy, or an outdated system. The wrong fix is disabling verification, which exposes your key to interception. Here is the safe path.
- Python or Node with an HTTP client
- Admin access to install certificates if needed
- Knowledge of whether you are behind a corporate proxy
Step 1: Read the full error
The error names the underlying cause. CERTIFICATE_VERIFY_FAILED with 'unable to get local issuer certificate' points at missing root certs. A 'self signed certificate in certificate chain' usually points at a proxy injecting its own certificate.
Step 2: Install or update root certificates
On macOS, the Python installer ships a script that installs the certifi root bundle. On Linux, update the system ca-certificates package. This is the fix for the missing local issuer case.
# macOS, adjust the version to your Python
/Applications/Python\ 3.12/Install\ Certificates.command
# Debian or Ubuntu
sudo apt-get update && sudo apt-get install --reinstall ca-certificates
# upgrade the Python bundle
pip install --upgrade certifiStep 3: Point your client at a trusted bundle
If you are behind a corporate proxy that injects its own root certificate, get that root cert from your IT team and tell your client to trust it. Set the bundle path with an environment variable rather than turning verification off.
# point requests and many clients at a combined trust bundle
REQUESTS_CA_BUNDLE=/etc/ssl/certs/company-bundle.pem
SSL_CERT_FILE=/etc/ssl/certs/company-bundle.pem
NODE_EXTRA_CA_CERTS=/etc/ssl/certs/company-bundle.pemStep 4: Confirm the fix
Run a small request again. A clean 200 means the trust chain is now complete and your key travels over a verified connection.
Result
After running the certificate installer and adding the corporate proxy CA to a trust bundle, the SSL error cleared and requests succeeded with verification fully on. The key stayed protected the whole time, which would not have been true if verification had simply been disabled.
Watch related tutorials
1:42:18
28:14
41:09
9:47
8:23
52:31New guides in your inbox
Fresh step-by-step how-to guides as we publish them. One email a week, no more.