Once the stream has started, provider failures do not throw. They arrive as { type: 'error' } parts on result.stream, wrapping a StreamProviderError.

import { StreamProviderError, streamText } from 'ai';

const { stream } = streamText({ model, prompt: 'Write a long story.' });

for await (const part of stream) {
  if (part.type === 'error') {
    const error = part.error;
    if (StreamProviderError.isInstance(error)) {
      console.error(error.message, {
        type: error.type, code: error.code,
        statusCode: error.statusCode, isRetryable: error.isRetryable,
      });
    }
  }
}

What to know:
1. Your try/catch around streamText will NOT catch these. If you only try/catch, mid-stream provider errors vanish silently and the UI just stops.
2. Check error.isRetryable to decide whether to retry the turn or show a permanent failure.
3. On the useChat path, these errors are masked by default before reaching the client (secure-by-default). Use onError in toUIMessageStream to forward a safe message, and log the full error server-side.
4. Common mid-stream causes: rate limit hit halfway through a long generation, provider-side timeout, content filter trip on later tokens.
5. If the UI freezes mid-response with no error shown, you are almost certainly dropping 'error' parts. Add the handler above and the cause appears.
6. For non-streaming generateText, the same failure throws as APICallError instead. The error-part path is specific to streams.