otherapi_key

Vercel AI Gateway

Access Vercel AI Gateway's model discovery, inference, generation, and usage APIs through a unified AI model gateway.

Verdict

Vercel AI Gateway routes LLM requests through a unified API that handles fallbacks, token counting, and multi-provider compatibility. @mention it to send prompts to OpenAI, Anthropic, or other models without switching endpoints, estimate costs before you run a query, or compact long conversation threads into replayable context. Teams managing multiple model providers get the most value — you write one prompt and the gateway picks the best available model. Trade-off: you need a Vercel account and API key; some advanced provider features may not surface through the abstraction layer.

Common use cases

  • Route prompts to cheapest available model
  • Estimate token cost before running query
  • Compact long chat threads into context
  • Fallback to backup model when primary fails
  • Generate embeddings across multiple providers

Integration

Vendor
Vercel AI Gateway
Category
other
Auth
API_KEY
Tools
22
Composio slug
vercel_ai_gateway

Tools

  • Compact Response

    Compact a long OpenAI Responses conversation into replayable context through Vercel AI Gateway. This endpoint only supports models routed to OpenAI and does not fail over to other providers; model compatibility is checked by the provider ra

  • Count Message Tokens

    Estimate input tokens for Anthropic-format messages, system content, and tools before sending a model request through Vercel AI Gateway.

  • Create Anthropic Message

    Create one non-streaming Anthropic Messages-compatible result through Vercel AI Gateway, with multimodal content, tools, extended thinking, and routing controls.

  • Create Chat Completion

    Create one non-streaming OpenAI Chat Completions-compatible result through Vercel AI Gateway, with multimodal messages, tools, structured output, fallback models, and routing controls.

  • Create Embeddings

    Generate OpenAI-compatible vector embeddings through Vercel AI Gateway for text or token inputs, with optional dimensions and routing controls.

  • Edit Images

    Create edited images from up to 16 HTTPS or base64 data-URL source images and a text instruction. Uses the non-streaming JSON image-edit route only.

  • Evaluate State

    Evaluate one shared state against one or more typed choice, score, or boolean questions using an AI Gateway evaluation model. Returns structured answers, token usage, and gateway metadata rather than generated prose.

  • Evaluate with TypeSafe API

    Evaluate one shared state through AI Gateway's TypeSafe-compatible System One API. Use this compatibility action for TypeSafe noul, choice, and score request shapes; use Evaluate State for new integrations.

  • Generate Images

    Generate one or more images from a text prompt through an image-only Vercel AI Gateway model. Returns a completed non-streaming JSON response.

  • Generate Response

    Generate one non-streaming OpenAI Responses-compatible result through AI Gateway, with optional instructions, tools, structured output, reasoning, and routing controls. Inspect status because a successful HTTP response may still be incomple

  • Generate Speech

    Generate spoken audio from text through a Vercel AI Gateway speech model. Returns completed base64 audio in JSON; streaming output is not supported.

  • Get Credit Balance

    Return the connected team's remaining AI Gateway credit balance and lifetime credit usage in USD.

  • Get Generation

    Look up cost, token usage, provider routing, latency, and finish details for one completed Vercel AI Gateway generation.

  • Get Model

    Return detailed capabilities, modalities, limits, tags, and pricing for one exact Gateway model ID.

  • Get Model Endpoints

    Compare provider endpoints serving one Vercel AI Gateway model, including limits, pricing, caching, availability, throughput, and latency.

  • Get Spend Report

    Query aggregated Vercel AI Gateway spend and token usage. This endpoint requires a Pro or Enterprise plan, and each query costs $5 per 1,000 queries.

  • List Model Catalog

    List AI Gateway model-to-provider routes and capability tags, with bounded local filtering by model text, provider, or tag.

  • List TypeSafe Models

    List evaluation models available through AI Gateway's TypeSafe-compatible API, including each accepted model name, description, and release date.

  • Rerank Object Documents

    Rank structured object documents by relevance through the Cohere v1 route, using selected rank fields and optionally returning each source document.

  • Rerank Text Documents

    Rerank string documents through the current Cohere v2 compatibility endpoint. Unlike the v1 action, this action accepts text strings only and does not support object documents, rank_fields, or return_documents.

  • Search Models

    Search the AI Gateway model catalog by text, model type, and tags, returning capability and pricing metadata for matching models.

  • Transcribe Audio

    Transcribe base64-encoded recorded audio through a Vercel AI Gateway transcription model. Returns one completed JSON transcript, not a live stream.

Setup

Setup guide

  1. 1Open your Switchy workspace and navigate to Settings > Integrations. Click Add Integration and select Vercel AI Gateway from the list. You'll be prompted to paste your Vercel AI Gateway API key — generate one from your Vercel dashboard under Settings > Tokens. Grant read and write access to the gateway endpoints. Click Connect and wait for the green confirmation. To test, open any Project and type '@Vercel AI Gateway count the tokens in this message' — you should see a token estimate returned in seconds. From there, use @Vercel AI Gateway in any prompt to route requests through your configured models, check token counts before expensive calls, or compact long threads when context windows fill up.

What teammates see: by default, memories from Vercel AI Gateway are scoped to the Project (PROJECT visibility) - you can mark any memory PRIVATE or share it ORG-wide.

Works well with

Top models

Compatibility data appears once enough Projects have used this MCP together with a given model.

How Switchy teams use it

Not enough Projects yet to publish anonymised usage stats (we require ≥ 50 Projects per week).

Starter prompts

Count Tokens First

@Vercel AI Gateway count the tokens in this message: 'Summarize the last six months of customer feedback from our support tickets, highlight recurring themes, and draft three actionable recommendations for the product team.'

Route with Fallback

@Vercel AI Gateway create a chat completion for 'Write a 200-word product announcement for our new API rate-limiting feature' using gpt-4 with gpt-3.5-turbo as fallback.

Compact Long Thread

@Vercel AI Gateway compact the last 40 messages in this thread into replayable context so we can continue the discussion without hitting token limits.

Generate Embeddings

@Vercel AI Gateway generate embeddings for these three product descriptions: 'Real-time collaboration tool', 'Async video messaging app', 'AI-powered meeting notes'.

Evaluate Choices

@Vercel AI Gateway evaluate these two headline options — 'Ship faster with AI' vs 'AI that actually works' — against clarity, urgency, and brand fit using a score question for each dimension.

Example outputs

Illustrative - representative of the model's voice and quality, not literal recordings.

Prompt

@vercel-ai-gateway create a chat completion using gpt-4o with fallback to claude-3-5-sonnet, asking for a product roadmap summary in JSON format

Output

The gateway routed your request to gpt-4o and returned a structured JSON object containing quarterly milestones, feature priorities, and resource allocation. The response included gateway metadata showing 1,247 input tokens, 423 output tokens, 89ms latency, and confirmed the primary model succeeded without triggering the fallback. The JSON schema you specified was validated and the output conforms to your roadmap structure.

Notes

This example highlights the gateway's model fallback and structured output capabilities. You need valid API keys for both OpenAI and Anthropic configured in your gateway settings. The fallback only activates if the primary model fails or times out—successful requests never hit the secondary provider, so you won't see cost savings from automatic provider switching during normal operation.

Prompt

@vercel-ai-gateway count tokens for this Anthropic message before I send it: system prompt about code review standards, 3 user messages with code diffs, and 2 tool definitions

Output

The token estimator returned 4,832 input tokens for your message structure: 1,205 tokens for the system prompt, 2,914 tokens across the three user messages (including the code diffs), 487 tokens for the two tool definitions, and 226 tokens of formatting overhead. This estimate helps you stay within Claude's context window and predict costs before making the actual API call.

Notes

Token counting is estimation-only and may differ slightly from the actual tokens charged by Anthropic after the request completes. This tool is most valuable for cost forecasting and context-window planning when building complex multi-turn conversations with large system prompts or many tool definitions. The estimate does not include output tokens, which depend on the model's response length.

Prompt

@vercel-ai-gateway compact this 47-message OpenAI conversation into replayable context, preserving the key decisions and code examples but reducing token overhead

Output

The compaction endpoint processed your 47-message thread (originally 18,934 tokens) and returned a condensed 6-message conversation totaling 4,217 tokens—a 78% reduction. The compacted version preserves function call results, the final code implementation, and three critical decision points, while removing redundant clarifications and intermediate iterations. You can replay this compacted context in future requests to maintain conversation continuity at lower cost.

Notes

Compaction only works with OpenAI-routed models and cannot fall back to other providers. The algorithm prioritizes recent messages and function call pairs, but you lose some conversational nuance—review the compacted output before relying on it for high-stakes decisions. Compaction itself consumes tokens and incurs API costs, so use it when the token savings in subsequent requests justify the upfront expense.

Use-case deep-dives

Multi-model cost control for product experiments

When your team runs parallel model tests without blowing budget

A 6-person product team ships three feature variants each sprint, each calling a different LLM for summarization or classification. Without gateway routing, you hard-code provider keys in every branch and lose visibility when one model costs 4x another. Vercel AI Gateway wins here because the fallback and routing controls let you set a primary model (GPT-4o-mini) with a cheaper backup (Claude Haiku) in one config, and the token-counting tool shows cost before you commit. The 22 tools cover OpenAI and Anthropic formats, so you're not rewriting prompts per provider. If your team ships fewer than two experiments a month or sticks to one model forever, the gateway is overkill—just call the provider direct. For teams iterating fast on model choice, this keeps experiments cheap and observable.

Customer support answer evaluation at scale

How a 3-agent support team scores AI draft quality in real time

A small support team uses an LLM to draft ticket replies, but agents need to know if the draft is safe to send or needs a rewrite. The Evaluate State tool runs a structured check (is the tone empathetic? does it answer the question?) against each draft before the agent sees it, returning boolean or score answers instead of freeform text. This scenario works because the team sends 40-60 tickets a day—enough volume to justify the gateway's eval overhead, but small enough that the API-key auth and single-model routing stay simple. If you're only evaluating 5 drafts a week, the setup cost outweighs the win; just have the agent read it. For teams in the 30-100 ticket/day range, the eval tool turns gut-check into data and cuts send-regret by half.

Image generation pipeline for marketing creative

When a 2-person growth team needs repeatable image edits without designer bottleneck

A startup's growth lead and copywriter ship 8-12 ad variants a week, each needing a hero image tweaked from a base template (swap background, adjust lighting, overlay text). The Edit Images tool takes up to 16 source images and a text instruction, returning edited results through the gateway's non-streaming route. This beats hiring a designer for every variant because the instruction format is consistent and the gateway handles provider failover if one image API is slow. The catch: this only works for edits, not net-new generation, and the 16-image limit means you can't batch a month's creative in one call. If your team ships fewer than 5 image variants a week or needs complex multi-layer composition, you still need a designer. For high-frequency, low-complexity edits, the gateway keeps the two-person team unblocked.

Frequently asked

What does the Vercel AI Gateway MCP do in Switchy?

It routes your AI model requests through Vercel's gateway layer instead of calling OpenAI, Anthropic, or other providers directly. You get fallback routing, token counting, prompt caching, and usage analytics without changing your prompts. Switchy sends requests to the gateway; the gateway handles provider selection and returns the response.

Do I need a Vercel account to use this MCP?

Yes. You need an active Vercel AI Gateway subscription and an API key from your Vercel dashboard. The key authenticates every request Switchy makes through the gateway. Without it, none of the 22 tools will work. Your Vercel plan tier determines rate limits and available models.

Can this MCP generate images or only text completions?

It handles both. The Create Chat Completion and Create Anthropic Message tools return text and structured outputs. The Edit Images tool processes up to 16 source images with text instructions and returns edited results. Embeddings generation is also supported. Streaming responses are not available through this MCP.

Why use the gateway instead of calling OpenAI directly?

The gateway adds automatic fallback if your primary model is down, built-in token counting before you send expensive requests, and centralised usage tracking across providers. You also get prompt caching that persists across sessions. Trade-off: you add one more dependency and latency hop between Switchy and the model.

Who on the team should connect this integration?

Whoever manages your Vercel account and can generate API keys. That person should also understand your model routing preferences and cost controls, because the gateway configuration lives in Vercel's dashboard. Once connected, any Switchy workspace member can invoke the tools without needing separate Vercel access.

More other MCPs

See all other MCPs →

Data last verified 61 hours ago.Sources aggregated hourly to weekly. See docs/architecture/model-directory.md.