agentsclimarketplace

Vercel ai gateway

Skill phucbm/skills/skills/ai/vercel-ai-gateway

Set up Vercel AI Gateway (@ai-sdk/gateway) for multi-provider AI access. Use when adding the gateway, switching AI providers, handling reasoning/thinking models, or mocking AI in tests.From its SKILL.md

Install
npx -y skills add phucbm/skills --skill vercel-ai-gateway

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.7 KB, 602 tokens by cl100k_base, as published. Nobody here has run it

Vercel AI Gateway

@ai-sdk/gateway is a proxy layer that routes requests to multiple AI providers (OpenAI, Anthropic, Google, xAI, GROQ) under a single API key.

Your app → Vercel AI Gateway (cloud proxy) → OpenAI / Anthropic / Google / xAI

Vercel hosts the proxy — you connect provider accounts in their dashboard. On Vercel deployments: OIDC auto-auth, no key needed. Locally: set AI_GATEWAY_API_KEY.

Install

pnpm add @ai-sdk/gateway ai

Basic usage

import { gateway } from "@ai-sdk/gateway";

gateway.languageModel("google/gemini-2.5-flash-lite")
gateway.languageModel("anthropic/claude-haiku-4.5")
gateway.languageModel("openai/gpt-4o")

Model IDs follow <provider>/<model-name> format.

Reasoning / thinking models

Apply extractReasoningMiddleware to models that emit <thinking> tags:

import { gateway } from "@ai-sdk/gateway";
import { extractReasoningMiddleware, wrapLanguageModel } from "ai";

const THINKING_SUFFIX_REGEX = /-thinking$/;

export function getLanguageModel(modelId: string) {
  const isReasoning = modelId.includes("reasoning") || modelId.endsWith("-thinking");
  if (isReasoning) {
    return wrapLanguageModel({
      model: gateway.languageModel(modelId.replace(THINKING_SUFFIX_REGEX, "")),
      middleware: extractReasoningMiddleware({ tagName: "thinking" }),
    });
  }
  return gateway.languageModel(modelId);
}

Test mock with customProvider

Swap real models for mocks via an env flag (e.g. PLAYWRIGHT=True):

import { customProvider } from "ai";

export const myProvider = isTestEnvironment
  ? customProvider({
      languageModels: {
        "chat-model": mockChatModel,
        "title-model": mockTitleModel,
      },
    })
  : null;

export function getLanguageModel(modelId: string) {
  if (isTestEnvironment && myProvider) return myProvider.languageModel(modelId);
  return gateway.languageModel(modelId);
}

Env

AI_GATEWAY_API_KEY=    # not needed on Vercel (OIDC auto-auth)

References

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,861. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.