## TL;DR

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.

## Steps

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

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

3. 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
 }
}

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

## When to use

You are seeing this: These two errors mean the SDK could not turn your model identifier into a usable model. Use this skill when you run into "NoSuchProviderError and NoSuchModelError: bad model strings".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
