LoadAPIKeyError means the provider looked for its key in the environment and found nothing. The message names the variable it wanted.

import { openai } from '@ai-sdk/openai';

// throws LoadAPIKeyError at call time if OPENAI_API_KEY is unset
const { text } = await generateText({ model: openai('gpt-5'), prompt: 'Hi' });

What to know:
1. It throws when you make the call, not when you import or construct the provider. A file that imports fine can still fail at runtime.
2. Read the message: it tells you the exact env var name. Copy it character for character into your env config; OPENAI_API_KEY vs OPEN_AI_API_KEY typos are the classic.
3. In Next.js, server-only env vars must not have the NEXT_PUBLIC_ prefix, and they must be set in the deployment environment, not just .env.local. Vercel preview vs production env mismatch is the top cause.
4. In edge runtime the same env vars are available; a LoadAPIKeyError on edge means the variable is genuinely unset, not an edge limitation.
5. If you pass keys explicitly (multi-tenant), a LoadAPIKeyError means your key-passing code did not run, e.g. the factory was constructed without the apiKey option.
6. Never "fix" this by hardcoding the key in source. Put it in the environment and keep the file out of version control.