## TL;DR

In v5 every error class dropped its AI_ prefix: AI_APICallError to APICallError, AI_NoSuchToolError to NoSuchToolError, and so on. Old code keeps compiling against old names only if you never upgraded; after upgrading, stale names are undefined and your catch blocks silently miss.

## Steps

1. import { AISDKError, APICallError, generateText } from 'ai';

2. try {
 await generateText({ model, prompt: 'Hi' });
} catch (error) {
 if (APICallError.isInstance(error)) {
 console.error('Provider request failed:', error.statusCode);
 return;
 }
 if (AISDKError.isInstance(error)) {
 console.error('AI SDK error:', error.name);
 return;
 }
 throw error;
}

3. What to know:
1. Order guards most-specific first, AISDKError last as the fallback. AISDKError.isInstance catches every SDK error.
2. Prefer ErrorClass.isInstance(error) over instanceof. It survives duplicated SDK copies in the module graph, which instanceof does not.
3. Never match error.message strings to detect error kinds. Messages change; the class identity does not.
4. The old names are gone, not deprecated-forever. Search your codebase for AI_ prefixed imports after upgrading past v5.
5. Re-throw what you do not handle. Swallowing unknown errors turns a clear failure into a mystery hang downstream.
6. Provider-level errors (APICallError, InvalidResponseDataError) are re-exported from ai, so most apps import everything from one place.

## When to use

You are seeing this: Modern pattern: import { AISDKError, APICallError, generateText } from 'ai'; try { await generateText({ model, prompt: 'Hi' }); } catch (error) { if (APICallError.isInstance(error)) { console.error('Provider request failed:', error.statusCode); return; }... Use this skill when you run into "Typed error migration: the AI_ prefix is gone, use isInstance guards".

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