- LuzineDebug
- AI & LLMs
AI & LLMs errors: causes and fixes
Errors from AI APIs (OpenAI, Anthropic Claude, Gemini) and machine learning (PyTorch, CUDA): rate limits, context too long, GPU memory, invalid keys.
Fix error 429 "Rate limit reached" on OpenAI, Claude and Gemini APIs
The provider rejects the request because you are over a rate limit: requests per minute (RPM) or tokens per minute (TPM). Wait for…
Intermediate 20 min This model's maximum context length is 128000 tokens. However, your messages resulted in 1…Fix "maximum context length" and "prompt is too long" (context_length_exceeded)
The request sent to the model holds more tokens than its context window accepts. Count tokens before the call, trim the conversati…
Intermediate 30 min torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 2.00 GiB. GPU 0 has a total…Fix "CUDA out of memory" in PyTorch
The graphics card’s memory (VRAM) is full: PyTorch could not allocate the requested block. Lower the batch size, switch to reduced…
Intermediate 20 min openai.AuthenticationError: Error code: 401 - Incorrect API key provided: sk-proj-****abcdFix error 401 "Incorrect API key provided" / "invalid x-api-key"
The API does not recognize the key it received: it is missing, mistyped, revoked or sent in the wrong header. Check that the envir…
Beginner 10 min AssertionError: Torch not compiled with CUDA enabledFix "Torch not compiled with CUDA enabled" and torch.cuda.is_available() returning False
The installed PyTorch is a CPU-only build, or no usable NVIDIA driver is detected. Check torch.__version__ (a +cpu suffix confirms…
Intermediate 20 min Error: could not connect to ollama app, is it running?Fix "could not connect to ollama" and connection refused on port 11434
The client (the ollama command, your script or your app) cannot reach the Ollama server on 127.0.0.1:11434. Start the server (Olla…
Beginner 10 min json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)Fix "JSONDecodeError: Expecting value" when parsing an LLM response
The text returned by the model is not pure JSON: it starts with a json block, a sentence such as “Here is the JSON”, or it is empt…
Intermediate 20 min OSError: You are trying to access a gated repo. Make sure to have access to it at https://…Fix "You are trying to access a gated repo" (401) on Hugging Face
The model is gated: you must accept its license on its Hugging Face page, then authenticate with a token. Request access on the mo…
Beginner 10 min