new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

AI SDK · Providers · all subjects

ai gateway/setup

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

AI Gateway API key environment variable

The AI Gateway API key is configured via the environment variable AI_GATEWAY_API_KEY.

Importing gateway provider from AI SDK

The gateway provider can be imported in two ways: Option 1 imports from the 'ai' package (included by default). Option 2 installs and imports from '@ai-sdk/gateway' package separately. Both approaches allow calling gateway() with a model string like 'anthropic/claude-sonnet-4.5'.

AI Gateway provider is built into AI SDK

The Vercel AI Gateway provider is part of the AI SDK and does not require installation of additional provider modules or dependencies.

AI Gateway basic usage with plain model string

You can use AI Gateway directly by passing a model string in the format 'creator/model-name' to generateText, streamText, and other AI SDK functions. The AI SDK automatically uses AI Gateway when you pass a model string in this format. Example: const { text } = await generateText({ model: 'openai/gpt-5.4', prompt: 'Hello world' });

AI Gateway provider instance creation

Import the `gateway` provider instance from the 'ai' package (requires version 5.0.36 or later). You can also create a custom provider instance using `createGateway` from 'ai'.

AI Gateway custom provider instance options

When creating a custom AI Gateway provider instance with createGateway(), you can configure: baseURL (string, default: 'https://ai-gateway.vercel.sh/v4/ai'), apiKey (string, defaults to AI_GATEWAY_API_KEY env var, supports AI Gateway API keys and Vercel access tokens), teamIdOrSlug (string for multi-team Vercel access tokens), headers (Record<string,string> for custom headers), fetch (custom fetch implementation), metadataCacheRefreshMillis (number, defaults to 300,000ms).

AI Gateway Bring Your Own Key (BYOK) credentials

You can connect your own provider credentials to use with Vercel AI Gateway by adding provider credentials in your Vercel team's AI Gateway settings. No code changes are needed. For providers like Azure that support custom deployment names, you can configure model mappings to map gateway model slugs to your deployment names.

Give your agent this brain