OpenAI Error: model_not_found — Model Not Found
import openai
try:
response = openai.chat.completions.create(
model="gpt-4-turbo-preview-2024", # ← deprecated alias
messages=[{"role": "user", "content": "Hello"}],
)
except openai.NotFoundError as e:
# e.status_code == 404
# e.code == 'model_not_found'
# e.message: "The model `gpt-4-turbo-preview-2024` does not exist or you do not have access to it."
...
model_not_found is OpenAI’s catch-all 404 for any model identifier that doesn’t resolve to something your API key can call. The error message is intentionally ambiguous — “does not exist or you do not have access” — because OpenAI doesn’t want to confirm the existence of gated models to unauthorised callers. That ambiguity is the source of most debugging time spent on this error.
The fastest path to clarity is client.models.list(). If the model is in the response, you have access — recheck spelling, casing, and which endpoint you’re calling. If it isn’t, check OpenAI’s deprecation page (the model may have been retired) and your account’s usage tier (the model may be gated). Combine those two checks and you’ll resolve 90%+ of model_not_found errors in under a minute.
Why this happens
- Typo or wrong casing in model name. Model IDs are case-sensitive and exact. `GPT-4o` won't match `gpt-4o`. `gpt4o` (no hyphen) won't match. `gpt-4-turbo` is now an alias to a specific snapshot, but `gpt-4-turbo-preview` is deprecated. A single character off and the API returns 404.
- Deprecated or retired model. OpenAI deprecates older models on a rolling schedule. `text-davinci-003`, `gpt-3.5-turbo-0301`, `gpt-4-32k`, and the original `gpt-4-vision-preview` have all been retired. Calls to retired models return `model_not_found`. The deprecation page lists current dates.
- Tier-gated model and your org isn't qualified. Newer flagship models often gate by usage tier. `o1` historically required tier 5 ($1k+ paid). Some experimental models are limited to tier 1+ paid customers. Free-tier orgs can't see `gpt-4o` at all in some periods. The error is the same `model_not_found` even though the issue is access, not existence.
- Wrong API endpoint for the model type. Calling `/v1/chat/completions` with an embedding model (`text-embedding-3-large`) returns `model_not_found` even though the model exists — it just doesn't serve chat. Embedding models go to `/v1/embeddings`, image models to `/v1/images/generations`, audio to `/v1/audio/*`.
- Fine-tuned model from another org or project. Fine-tuned model IDs (`ft:gpt-4o-mini-2024-07-18:org-abc:custom-name:abc123`) are scoped to the org/project that created them. Calling them from a different org returns `model_not_found`. Project-scoped fine-tunes are also invisible to other projects in the same org.
How to fix it
Fixes are ordered by likelihood. Start with the first one that matches your context.
1. List your available models programmatically
`client.models.list()` returns every model your API key can access. Filter by capability and pick the right one. This is also the fastest way to see if a tier-gated model is available to your org.
from openai import OpenAI
client = OpenAI()
models = client.models.list()
chat_models = [m.id for m in models.data if m.id.startswith(('gpt-', 'o1', 'o3'))]
print('Available chat models:', sorted(chat_models))
# Defensive caller:
def pick_model(preferred, fallback="gpt-4o-mini"):
available = {m.id for m in client.models.list().data}
return preferred if preferred in available else fallback
2. Use canonical model aliases, not snapshot IDs
Use the family alias (`gpt-4o`, `gpt-4o-mini`, `o1`) rather than dated snapshots (`gpt-4o-2024-08-06`) unless you specifically need pinning. Aliases auto-route to the current production version. Snapshots are retired on a fixed schedule and start returning `model_not_found` — usually with 6+ months notice in the deprecation policy.
3. Check usage tier and request access if needed
Visit platform.openai.com/account/limits to see your current tier and which models are available at that tier. Tier upgrades happen automatically after $50/$100/$250/$1k+ paid + a 7-day cooling period. There's no manual exception process — only paying more works.
4. Match the model to the correct endpoint
Embeddings → `/v1/embeddings` only. Image generation → `/v1/images/generations`. Audio transcription → `/v1/audio/transcriptions`. Realtime → WebSocket `/v1/realtime`. The model_not_found error message often hints at this; the SDK reference docs list each model's supported endpoint.
# WRONG: chat completion with an embedding model
# client.chat.completions.create(model="text-embedding-3-large", ...)
# RIGHT: embeddings endpoint
from openai import OpenAI
client = OpenAI()
emb = client.embeddings.create(
model="text-embedding-3-large",
input="Hello world",
)
5. Verify fine-tuned model ID and project scope
Fine-tunes appear in Dashboard → Fine-tuning. Copy the full model ID exactly. If your code runs under a different project than the one that owns the fine-tune, either move the fine-tune to the right project or switch the API key to the owning project's scope.
Detection and monitoring in production
Treat `model_not_found` as a critical config error, not a transient one. Alert on first occurrence per deploy — it usually means a deploy shipped with an outdated model name or a tier change broke access. Log `error.code` and the requested model name together so you can spot pattern (typo on one model vs deprecation across the board).
Related errors
- openairate_limit_exceededYour account has exceeded its per-minute request (RPM) or per-minute token (TPM) limit for the model you're calling. Limits are tier-based and per-model.
- openaiinsufficient_quotaYour OpenAI organisation has run out of paid credit, hit its monthly hard limit, or hasn't added a payment method yet. Despite the 429 status, this is a billing problem — not a rate-limit problem — and retrying won't help.
- openaicontext_length_exceededThe total tokens (prompt + max_tokens for completion) exceeds the model's context window. For example, sending 130,000 input tokens to `gpt-4o` (128k window) or asking for 5,000 completion tokens when the prompt is already 125k.
- anthropicrate_limit_errorYou exceeded one of Anthropic's per-minute caps for the model and tier — RPM (requests/min), ITPM (input tokens/min), or OTPM (output tokens/min). Anthropic enforces all three independently and you can hit any one without breaching the others.
- anthropicauthentication_errorThe `x-api-key` header you sent doesn't match an active Anthropic API key — usually because the env var isn't loaded, the key was rotated or revoked, you're using a Workspace key in the wrong workspace, or a wrong-provider key (Bedrock or Vertex) was sent to the direct Anthropic API.
Frequently asked questions
Why does the error say 'does not exist or you do not have access'? +
What's the difference between `gpt-4o` and `gpt-4o-2024-08-06`? +
Can I see when a model is going to be deprecated? +
Does `model_not_found` count toward rate limits or billing? +
Why can I use `gpt-4o` in the playground but not via API? +
How do I find a fine-tuned model's exact ID? +
Are some models region-restricted? +
Can I alias deprecated models to their replacements automatically? +
When to escalate to OpenAI support
Open a support ticket only if (a) `models.list()` shows the model but calls return 404, indicating a routing bug on OpenAI's side, or (b) you've been promised access (enterprise contract, beta program) but don't see the model in your list 24+ hours after the activation email. For tier upgrades or generally-available models, support can't override the gates.