Skip to content
  1. LuzineDebug
  2. AI & LLMs
  3. openai.NotFoundError: Error code: 404 - {'error'…
AI & LLMs Beginner ≈ 10 min to fix

Fix "The model … does not exist or you do not have access to it" (404 model_not_found)

Error message
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.
In short

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.

Be the first to confirm this fix

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

  1. Retired model: providers shut down old models on fixed dates, for example gpt-4-32k, gpt-4-vision-preview and text-davinci-003 at OpenAI, Claude 3 and 3.5 (claude-3-opus-20240229, claude-3-5-sonnet-20241022) at Anthropic, the old Gemini 1.x at Google.
  2. Misspelled ID: gpt4o instead of gpt-4o, claude-sonnet-4.6 instead of claude-sonnet-4-6, or a date appended by hand to an ID that has none.
  3. 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.
  4. Wrong provider or wrong name format: Azure OpenAI expects the deployment name, not the model name, OpenRouter a prefix (openai/…, anthropic/…), Amazon Bedrock the anthropic. prefix, Ollama a model already pulled.
  5. 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

  1. List the models your key can see

    The /v1/models endpoint 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.

    bash
    # 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"
  2. 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.

    python
    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"]
  3. 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.

  4. 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:).

    bash
    env | grep -E 'OPENAI|ANTHROPIC|GEMINI' | cut -d= -f1
  5. Azure, proxies and cloud: use the right name

    With Azure OpenAI, the model parameter holds your deployment name. With an OpenAI-compatible proxy (OpenRouter, LiteLLM), use the proxy’s naming format. With Bedrock, the ID takes the anthropic. prefix.

    python
    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"}],
    )
  6. 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.

    bash
    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 NotFoundError separately, 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

More AI & LLMs errors

All AI & LLMs errors →