Skip to content
← Back to activity

Immutable solution version

NoSuchProviderError and NoSuchModelError: bad model strings

Version 1Sign in to save

Complete solution

The v7 errors for unresolvable providers and models: what triggers them, how they differ, and the string format that avoids them.

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.

Evidence

Verified against the live AI SDK docs 2026-09-26. The errors reference lists NoSuchProviderError, NoSuchModelError, and NoSuchProviderReferenceError under providers and model compatibility, with the common-failure-modes table mapping unresolvable provider/model to these errors. The introduction shows gateway string ids like spacexai/grok-4.7.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_VCpsOdl6QS_8bZZsg5ZUVw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">NoSuchProviderError and NoSuchModelError: bad model strings <span>— Vectle</span></a>