Fix "The model … does not exist or you do not have access to it" (404 model_not_found)
openai.NotFoundError: Error code: 404 - {'error': {'message': 'The model `gpt-4-32k` does not exist or you do not have access to it.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}
- anthropic.NotFoundError: Error code: 404 - {'type': 'error', 'error': {'type': 'not_found_error', 'message': 'model: claude-3-5-sonnet-20241022'}}
- The model `text-davinci-003` has been deprecated, learn more here: https://platform.openai.com/docs/deprecations
- 404 models/gemini-1.5-pro is not found for API version v1beta, or is not supported for generateContent. Call ListModels to see the list of available models and their supported methods.
- Error: model "llama3" not found, try pulling it first
- DeploymentNotFound: The API deployment for this resource does not exist.
The API does not recognise the model name you sent, or your key (organization, project, workspace) is not allowed to use it. Typical causes: a typo, a retired model (gpt-4-32k, claude-3-5-sonnet-20241022) or a model reserved for some accounts. List the models your key can see with GET /v1/models and copy the exact ID.
What this error means
Every request has a model field. The provider looks that name up among the models available to the key’s organization or project; if it cannot find it, it returns HTTP 404. OpenAI returns code model_not_found with "does not exist or you do not have access to it": the message is deliberately the same for a non-existent name and for a model you are not allowed to use. Anthropic returns not_found_error with model: <id>, also identical in both cases. Gemini says "models/x is not found for API version". Unlike a 401, the key is valid: the problem is the model name or permissions. A retired model also returns 404 after its shutdown date, which is why code can break overnight.
Common causes
- Retired model: providers shut down old models on fixed dates, for example
gpt-4-32k,gpt-4-vision-previewandtext-davinci-003at OpenAI, Claude 3 and 3.5 (claude-3-opus-20240229,claude-3-5-sonnet-20241022) at Anthropic, the old Gemini 1.x at Google. - Misspelled ID:
gpt4oinstead ofgpt-4o,claude-sonnet-4.6instead ofclaude-sonnet-4-6, or a date appended by hand to an ID that has none. - No access for this account: some models require a verified organization or a usage tier, and an OpenAI project or an Anthropic workspace can restrict the list of allowed models.
- Wrong provider or wrong name format: Azure OpenAI expects the deployment name, not the model name, OpenRouter a prefix (
openai/…,anthropic/…), Amazon Bedrock theanthropic.prefix, Ollama a model already pulled. - Wrong key loaded: an environment variable from another organization or project (old
.env, a variable exported in the shell that takes precedence).
Step-by-step fix
-
List the models your key can see
The
/v1/modelsendpoint returns exactly the models the key can use. If your model is not there, it is not a code problem but a name or access problem.# OpenAI curl -s https://api.openai.com/v1/models \ -H "Authorization: Bearer $OPENAI_API_KEY" | grep '"id"' # Anthropic curl -s https://api.anthropic.com/v1/models \ -H "x-api-key: $ANTHROPIC_API_KEY" \ -H "anthropic-version: 2023-06-01" # Gemini curl -s https://generativelanguage.googleapis.com/v1beta/models \ -H "x-goog-api-key: $GEMINI_API_KEY" -
Copy the exact ID and move it out of the code
Copy the ID as it appears in the list and read it from an environment variable: replacing a retired model will no longer require a redeploy. The SDKs also expose the model list.
import os import anthropic from openai import OpenAI openai_client = OpenAI() print([m.id for m in openai_client.models.list()]) anthropic_client = anthropic.Anthropic() for model in anthropic_client.models.list(): print(model.id, model.display_name) MODEL = os.environ["LLM_MODEL"] -
Replace a retired model
Check your provider’s deprecations page ("Deprecations" at OpenAI, "Model deprecations" at Anthropic, "Gemini models" at Google) and pick the listed successor. Retest your prompts: a new model may answer differently.
-
Check the organization, project and key in use
In the OpenAI dashboard, look at the project limits (allowed models) and the organization verification status; in the Anthropic Console, the key’s workspace. Also check which variables are set, without printing their values (PowerShell:
Get-ChildItem Env:).env | grep -E 'OPENAI|ANTHROPIC|GEMINI' | cut -d= -f1 -
Azure, proxies and cloud: use the right name
With Azure OpenAI, the
modelparameter holds your deployment name. With an OpenAI-compatible proxy (OpenRouter, LiteLLM), use the proxy’s naming format. With Bedrock, the ID takes theanthropic.prefix.from openai import AzureOpenAI # reads AZURE_OPENAI_API_KEY and AZURE_OPENAI_ENDPOINT client = AzureOpenAI(api_version="2024-10-21") response = client.chat.completions.create( model="my-chat-deployment", # deployment name, not the model name messages=[{"role": "user", "content": "Hello"}], ) -
Ollama: pull the model first
Ollama does not download models automatically through the API. List the ones present, then pull the missing one with exactly the same name and tag.
ollama list ollama pull llama3.2
Did this fix work for you?
Confirm it in one click: it will rise for the next developers stuck on the same error.
Keep it from coming back
- Keep the model name in configuration (an environment variable), never hard-coded in several files.
- At startup or in CI, call
models.retrieve(MODEL)to fail immediately if the model is gone, instead of in the middle of a user request. - Do not retry a 404 automatically like a 429: handle
NotFoundErrorseparately, since retrying will not change anything.
Frequently asked questions
Why does the message say "or you do not have access to it"?
Providers do not reveal that a model exists to an account that cannot use it. A non-existent name and a model you are not allowed to use therefore return the same 404.
My key works with another model, why not this one?
The key is valid (otherwise it would be a 401), but model access depends on the organization, project, usage tier or account verification.
Should I use an alias or a dated ID?
A dated ID (snapshot) guarantees stable behavior but will be retired one day; an alias follows updates. Either way, watch deprecation announcements.
Useful tools for this error
HTTP status codes
All the common HTTP codes (401, 403, 404, 419, 429, 500, 502…): meaning, causes and what to do.
JSON validator
Validate, format and minify JSON, with the exact line and column of the error.
cURL converter
Paste a cURL command (DevTools “Copy as cURL”): get the fetch, axios, Node, PHP (Laravel Http or curl) or Python requests code.
More AI & LLMs errors
- Fix error 429 "Rate limit reached" on OpenAI, Claude and Gemini APIs
- Fix "maximum context length" and "prompt is too long" (context_length_exceeded)
- Fix "CUDA out of memory" in PyTorch
- Fix error 401 "Incorrect API key provided" / "invalid x-api-key"
- Fix "Torch not compiled with CUDA enabled" and torch.cuda.is_available() returning False
- Fix "could not connect to ollama" and connection refused on port 11434
- Fix "JSONDecodeError: Expecting value" when parsing an LLM response
- Fix "You are trying to access a gated repo" (401) on Hugging Face