These two errors mean the SDK could not turn your model identifier into a usable model. They fire before any network call.

import { NoSuchModelError, NoSuchProviderError, generateText } from 'ai';

try {
  await generateText({ model: 'openai/gpt-9-hallucinated', prompt: 'Hi' });
} catch (error) {
  if (NoSuchProviderError.isInstance(error)) {
    // 'openai' part did not resolve to a known provider
  }
  if (NoSuchModelError.isInstance(error)) {
    // provider resolved, model id did not
  }
}

What to know:
1. Gateway-style string ids look like 'provider/model', e.g. 'openai/gpt-5' or 'anthropic/claude-opus-4-6'. A typo in either half gives you one of these two errors.
2. NoSuchProviderError: the provider half is wrong or the provider is not registered. With customProvider, register the provider under the exact name you reference.
3. NoSuchModelError: the provider is fine but the model id does not exist (yet). Model ids change fast; an id from a six-month-old tutorial may be retired.
4. There is also NoSuchProviderReferenceError for the uploadFile/provider-reference path. Same family, different trigger.
5. When using provider factories directly (openai('gpt-5')), a wrong model id usually surfaces as a 404 APICallError from the provider instead. The NoSuch* errors are for the string-id resolution path.
6. If you maintain a model allowlist in your app, validate against it before calling and return your own friendly error instead of leaking the raw SDK error.