One string per model

Name models as provider/model strings through AI Gateway.

AI SDK docsai-sdk.dev
The AI SDK automatically uses the AI Gateway when you pass a model string in the creator/model-name format.
Providers · AI GatewayRead docs ↗

From ai-sdk, “AI Gateway: The Fastest Way to Start”.

The provider goes down

Pick a model, then press Send.

Provider packageBad
0 msIdle
    openai('gpt-5.5')
    Gateway + fallbacksGood
    0 msIdle
      'openai/gpt-5.5'

      import { streamText } from 'ai';
      import type { GatewayProviderOptions } from '@ai-sdk/gateway';
      
      const result = streamText({
        model: 'openai/gpt-5.5', // a string: no provider package
        prompt,
        providerOptions: {
          gateway: {
            models: ['anthropic/claude-sonnet-5', 'google/gemini-3.8-flash'],
          } satisfies GatewayProviderOptions,
        },
      });
      # .env.local (on Vercel, OIDC works without a key)
      AI_GATEWAY_API_KEY=...
      
      # Current model IDs. Never from memory.
      curl -s https://ai-gateway.vercel.sh/v1/models | jq -r '.data[].id'

      Why it matters, pros and cons

      Why it matters

      One key reaches every provider. Switching or falling back is a string, not a new package.

      Pros

      • No provider packages or per-provider keys.
      • Fallback models answer during an outage.
      • Swap models in config, not in imports.

      Cons

      • Adds a hop and a dependency on Vercel.
      • Provider-only features may need providerOptions.
      • Model IDs retire; fetch the list, don't guess.