[Get API key](https://vercel.com/d?to=%2F%5Bteam%5D%2F~%2Fai-gateway%2Fquick-start%3FshowCreateKeyModal%3Dauto%26utm_source%3Dai_gateway_landing_page&title=Get%20API%20key)

[Read the docs](https://vercel.com/docs/ai-gateway)

# The AI Gateway for developers

400+ models at provider speed with near-zero overhead. One API key, no markup. Text, image, video, and audio, including realtime voice over WebSockets.

```ts
import { streamText } from 'ai'

const result = streamText({
  model: 'spacexai/grok-4.7',
  prompt: 'Why is the sky blue?'
})
```

[Read docs](https://vercel.com/docs/ai-gateway/sdks-and-apis/ai-sdk)

SpaceXAI

OpenAI

Anthropic

Gemini

OSS

[And More](/ai-gateway/models)

0%

No markup on tokensPay provider prices,
never a cent more.

Invoicing is available with no payment processing fees. See the [AI Gateway pricing docs](https://vercel.com/docs/ai-gateway/pricing).

Limited time

## Ongoing promotions

Explore free and discounted models on AI Gateway. Promotional pricing applies automatically at request time. 27 live now.

[View all deals](/ai-gateway/models?promo=true)

- Tako

    ### Tako Search

    Free

- Convaiinnovations

    ### Laya

    Free

- Stealth

    ### Glyph Cluster

    Free

| Model | Promotion | Input price | Output price | Type |
| --- | --- | --- | --- | --- |
| [DeepSeek V4.1 FlashDeepSeek](/ai-gateway/models/deepseek-v4.1-flash) | [\-30%](/ai-gateway/models/deepseek-v4.1-flash) | [$0.07/M](/ai-gateway/models/deepseek-v4.1-flash) | [$0.60/M$0.42/M](/ai-gateway/models/deepseek-v4.1-flash) | [Text](/ai-gateway/models/deepseek-v4.1-flash) |
| [GLM 5.3Z.AI](/ai-gateway/models/glm-5.3) | [\-38%](/ai-gateway/models/glm-5.3) | [$0.06/M](/ai-gateway/models/glm-5.3) | [$4/M$2.50/M](/ai-gateway/models/glm-5.3) | [Text](/ai-gateway/models/glm-5.3) |
| [GLM 5.3 FlashZ.AI](/ai-gateway/models/glm-5.3-flash) | [\-50%](/ai-gateway/models/glm-5.3-flash) | [$0.15/M$0.08/M](/ai-gateway/models/glm-5.3-flash) | [$0.50/M$0.25/M](/ai-gateway/models/glm-5.3-flash) | [Text](/ai-gateway/models/glm-5.3-flash) |
| [BeamReflection](/ai-gateway/models/beam) | [Free](/ai-gateway/models/beam) | [$0](/ai-gateway/models/beam) | [$0](/ai-gateway/models/beam) | [Text](/ai-gateway/models/beam) |
| [Gemini 3.8 FlashGoogle](/ai-gateway/models/gemini-3.8-flash) | [\-50%](/ai-gateway/models/gemini-3.8-flash) | [$1.50/M$0.75/M](/ai-gateway/models/gemini-3.8-flash) | [$7.50/M$3.75/M](/ai-gateway/models/gemini-3.8-flash) | [Text](/ai-gateway/models/gemini-3.8-flash) |
| [DeepSeek V4.1 Flash 1017DeepSeek](/ai-gateway/models/deepseek-v4.1-flash-1017) | [\-51%](/ai-gateway/models/deepseek-v4.1-flash-1017) | [$0.09/M](/ai-gateway/models/deepseek-v4.1-flash-1017) | [$0.60/M$0.29/M](/ai-gateway/models/deepseek-v4.1-flash-1017) | [Text](/ai-gateway/models/deepseek-v4.1-flash-1017) |
| [GLM 5.2Z.AI](/ai-gateway/models/glm-5.2) | [\-25%](/ai-gateway/models/glm-5.2) | [$0.19/M](/ai-gateway/models/glm-5.2) | [$2.40/M$1.80/M](/ai-gateway/models/glm-5.2) | [Text](/ai-gateway/models/glm-5.2) |
| [Gemini 4 ArgonGoogle](/ai-gateway/models/gemini-4-argon) | [\-50%](/ai-gateway/models/gemini-4-argon) | [$4/M$2/M](/ai-gateway/models/gemini-4-argon) | [$20/M$10/M](/ai-gateway/models/gemini-4-argon) | [Text](/ai-gateway/models/gemini-4-argon) |

## Optimize routing for availability, cost, or latency

If a provider degrades, the Gateway fails over to the same model on another provider. Identical output, no downtime.

App

Provider degraded?

Claude Haiku 5.5Anthropic

Degraded

Claude Haiku 5.5Amazon Bedrock

## Routing, billing, and observability in one place

Providing the developer experience and infrastructure to build, scale, and secure a faster, more personalized web.

- **One API key, 400+ models:** Unified billing and observability across your entire AI stack, with text, image, video, and audio models.

    [Learn more](/ai-gateway/models)

- **Route on behavior, fallback anytime:** Automatic fallbacks during provider outages so your app stays up even when a model goes down.

    [Learn more](/docs/ai-gateway/models-and-providers/model-fallbacks)

- OpenAI$12.47

    Anthropic$8.22

    SpaceXAI$4.31

    Platform fee$0.00

    Total$25.00

    **No markup, just fair prices:** Pay exactly what providers charge with no platform fees.

    [Learn more](/docs/ai-gateway/pricing)

## Works with your existing AI stack

### AI Gateway base URL migration

```diff
- X_AI_API_KEY
- ANTHROPIC_API_KEY
- OPEN_AI_API_KEY
+ AI_GATEWAY_API_KEY
```

Move existing OpenAI, Anthropic, and AI SDK integrations to AI Gateway with a base URL swap.

### [AISDK](/ai-sdk)

The open-source AI toolkit designed to help developers build AI-powered applications and agents with React, Next.js, Vue, Svelte, Node.js, and more.

### [OpenAI Chat Completions](/docs/ai-gateway/sdks-and-apis/openai-chat-completions)

### [OpenAI Responses](/docs/ai-gateway/sdks-and-apis/responses)

### [Anthropic Messages](/docs/ai-gateway/sdks-and-apis/anthropic-messages-api)

### [Open Responses](/docs/ai-gateway/sdks-and-apis/openresponses)

- **Seamless migration:** Point your existing OpenAI or Anthropic SDK at AI Gateway. Same calls, no rewrites.

    [Learn more](/blog/cline-on-ai-gateway)

- **Bring your own keys:** Bring your own provider keys with no platform fee. Existing commitments flow through.

    [Learn more](/docs/ai-gateway/authentication-and-byok/byok)

- **Models on day zero:** Immediate launch partner with major labs. New models work the minute they ship.

## Recent ships

[View the changelog](/changelog)

- 17 OctoberChangelog

    ### AI Gateway logs now show session affinity

    Sam Chitgopekar, Jerilyn Zheng

    [Learn more](/changelog/ai-gateway-logs-now-show-session-affinity)

- 17 OctoberChangelog

    ### DeepSeek V4.1 Flash 1017 now available on AI Gateway

    Zachary Chen, Jerilyn Zheng

    [Learn more](/changelog/deepseek-v4-1-flash-1017-now-available-on-ai-gateway)

- 16 OctoberChangelog

    ### Elorian AI's Glimpse now available on AI Gateway

    Jerilyn Zheng, Rohan Taneja, and 1 other

    [Learn more](/changelog/elorian-ai-glimpse-now-available-on-ai-gateway)

> “Moving to the gateway is just so ergonomic. We get references to model names, and rely on Vercel to do the correct implementations and handle the edge cases.”

Rob CheungCo-founder

[How Zo Computer improved AI reliability 20×](/blog/how-zo-computer-improved-ai-reliability-20x-on-vercel)

- 20x

    Improvement in AI
    reliability after switching

- 30s

    To adopt a new model,
    down from an hour of code

- 25%

    Improvement in average
    latency on model calls

## Security and compliance

Route only to ZDR providers, no training or prompt logging, configurable per request or team-wide.

- **Zero Data Retention:** Enforced on every request across your team. Routes only to providers under a ZDR agreement.

    [Learn more](/docs/ai-gateway/capabilities/zdr)

- **No training on your data:** Route only to providers that will not train on customer data, configurable per request.

    [Learn more](/docs/ai-gateway/capabilities/disallow-prompt-training)

- **Provider allowlist:** Restrict your team to approved providers. Enforced on every request, no code changes.

    [Learn more](/docs/ai-gateway/capabilities/provider-allowlist)

## Take control

Manage usage across teams with budgets, quotas, and full request visibility.

Set controls

- **Budgets:** Cap spend with budgets at the team, project, and API key level.

[Learn more](/docs/ai-gateway/observability-and-spend/budgets)

- **API key management:** Create, view, and delete keys from the dashboard, CLI, or API.

[Learn more](/docs/ai-gateway/authentication-and-byok/api-keys)

- **Short-lived OIDC tokens:** Authenticate with expiring credentials. No static credentials to manage.

[Learn more](/docs/ai-gateway/authentication-and-byok#oidc-token-authentication)

See everything

- **Custom Reporting API:** Tag requests by user, customer, feature, or environment. Analyze spend in the dashboard or your own systems.

[Learn more](/docs/ai-gateway/observability-and-spend/custom-reporting)

- **Dashboard observability:** Usage, spend, requests, TTFT, and token counts at team, API key, and project scope.

[Learn more](/docs/ai-gateway/observability-and-spend/observability)

- **Request logs:** Search and filter every request, follow traffic live, and open one to see how it routed and what it cost.

[Learn more](/docs/ai-gateway/observability-and-spend/logs)

Live on AWS MarketplaceBuy with private offers, using your existing cloud commits.

[View the listing](https://aws.amazon.com/marketplace/search/results?searchTerms=vercel+ai+gateway)

## Every modality you need

Text, image, video, realtime, speech, transcription, embeddings, and reranking through one endpoint.

### Text

Access the latest from every major model lab and provider. Power your AI features all through a single endpoint.

### Image

Generate and edit with the latest image models, no extra setup.

### Video

New

Ship production-ready video across a wide range of models from a single prompt.

### Realtime

New

Build voice and live multimodal experiences with realtime models through a single endpoint.

### Speech

New

Turn text into natural, expressive speech with the latest text-to-speech models, all through one endpoint.

### Transcription

New

Transcribe audio to text with leading speech-to-text models, no extra setup.

### Embeddings

Vector embeddings for search, retrieval, and RAG pipelines, with every major provider available through one endpoint.

### Reranking

Improve retrieval relevance by reordering results before they hit your model.

OpenAI

Vercel provides a workflow to develop, deploy, and host websites, apps, and serverless functions. Teams can manage code from preview through production, while Vercel’s edge network and automatic scaling support delivery to users worldwide.

### Text

OpenAI

### Image

Google

### Video

New

SpaceXAI

### Realtime

New

OpenAI

### Speech

New

ElevenLabs

0:00

### Transcription

New

Deepgram

You can build and host many different types of applications from static sites with your favorite framework, multi-tenant applications or micro-frontends to AI-powered agents. Deploy globally in seconds, scale automatically with traffic, and ship every change with preview deployments, observability, and built-in security on every request.

### Embeddings

OpenAI

\[0.234, -0.198, 0.567, 0.012, -0.823, 0.445, -0.671, 0.298, 0.789, -0.234, 0.617, 0.082, -0.301, 0.519, -0.448, 0.176, 0.902, -0.057, 0.388, -0.741, 0.263, 0.014, -0.598, 0.831, -0.122, 0.476, 0.249, -0.687, 0.354, 0.911, -0.205, 0.066, 0.498, -0.379, 0.732, -0.461, 0.187, 0.853, -0.092, 0.541, 0.318, -0.226, 0.679, -0.518, 0.034, 0.793, -0.347, 0.612, 0.158, -0.806, 0.273, 0.469, -0.135, 0.587, 0.821, -0.044, 0.396, -0.752, 0.218, 0.503, -0.661, 0.129, 0.874, -0.317, 0.452, 0.085, -0.539, 0.706, -0.198, 0.361, 0.927, -0.475, 0.244, -0.683, 0.518, 0.039, -0.792, 0.155, 0.642, -0.288, 0.471, 0.836, -0.107, 0.523, -0.366, 0.018, 0.748, -0.491, 0.265, 0.882, -0.146, 0.397, 0.609, -0.728, 0.184, 0.456, -0.029, 0.713, -0.554, 0.298, 0.067, -0.421, 0.836, -0.193, 0.512, 0.347, -0.768, 0.124, 0.658, -0.385, 0.901, 0.071, -0.469, 0.234, 0.587, -0.812, 0.156, 0.473, -0.628, 0.319, 0.052, -0.741, 0.486, 0.207, -0.563, 0.894, -0.135, 0.428, 0.671, -0.298, 0.519, 0.084, -0.756, 0.347, 0.918, -0.412, 0.176, -0.689, 0.245, 0.561, -0.328, 0.073, 0.842, -0.197, 0.453, -0.726, 0.288, 0.617, 0.039, -0.504, 0.871, -0.265, 0.392, 0.158, -0.673, 0.527, 0.084, -0.439, 0.916, -0.221, 0.358, 0.495, -0.782, 0.146, 0.629, -0.317, 0.058, 0.847, -0.473, 0.196, 0.534, -0.628, 0.279, 0.913, -0.045, 0.461, 0.184, -0.752, 0.398, 0.625, -0.171, 0.043, 0.789, -0.526, 0.314, 0.867, -0.082, 0.471, -0.638, 0.219, 0.582, -0.395, 0.146, 0.704, -0.273, 0.519, 0.038, -0.846, 0.187, 0.493, -0.561, 0.328, 0.075, -0.412, 0.901, -0.246\]

### Reranking

Cohere

- 1Cache invalidation guide
- 2How streaming works
- 3Routing edge cases
- 4Provider failover patterns

## Works with the tools your team already uses

Route 11+ AI coding agents through AI Gateway with a base URL change. Get unified observability and spend tracking across every tool, no matter who built it.

[See all supported coding agents](/docs/ai-gateway/coding-agents)

Or skip the config files. The setup command detects the supported agents on your machine, provisions an API key, and writes their configuration for you.

### Terminal

```bash
npx vercel@latest ai-gateway setup
```

- ### [Claude Code](https://vercel.com/docs/ai-gateway/coding-agents/claude-code)

    Anthropic’s coding agent. Route it through AI Gateway’s Anthropic-compatible endpoint, then switch between Claude models mid-session. Works with Claude Code Max too.

- ### [OpenAI Codex](https://vercel.com/docs/ai-gateway/coding-agents/openai-codex)

    OpenAI’s coding agent. Route it through AI Gateway’s Responses API so usage joins the rest of your AI spend, and pick an OpenAI model per session.

- ### [Command Code](https://vercel.com/docs/ai-gateway/coding-agents/command-code)

    Terminal coding agent with bring your own key support. Add your AI Gateway key and a custom base URL, then switch between your configured models.

- ### [OpenCode](https://vercel.com/docs/ai-gateway/coding-agents/opencode)

    Open-source terminal coding agent with native AI Gateway support. Connect once, then switch between any model on the fly.

- ### [Blackbox AI](https://vercel.com/docs/ai-gateway/coding-agents/blackbox)

    Terminal CLI for AI code generation and debugging, with access to every model in the catalog.

- ### [Cline](https://vercel.com/docs/ai-gateway/coding-agents/cline)

    Autonomous coding agent for VS Code. Select Vercel AI Gateway as the provider for detailed token and cache metrics.

## Get started

This quickstart walks you through making your first text generation request with AI Gateway.

[Read the quickstart](https://vercel.com/docs/ai-gateway/getting-started/text)

Create a new directory and initialize a Node.js project.

### Terminal

```bash
mkdir ai-text-demo
cd ai-text-demo
pnpm init
```

Install the AI SDK and development dependencies.

### Terminal

```bash
npm install ai@latest dotenv @types/node tsx typescript
```

Go to the [AI Gateway API Keys page](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai-gateway%2Fapi-keys&title=AI+Gateway+API+Keys) in your Vercel dashboard and click **Create Key** to generate a new API Key. Create a `.env.local` file and save your API Key. Instead of using an API Key, you can use [OIDC tokens](/docs/ai-gateway/authentication-and-byok#oidc-token-authentication) to authenticate your requests.

### .env.local

```bash
AI_GATEWAY_API_KEY=your_ai_gateway_api_key
```

Create the `index.ts` file.

### index.ts

```ts
import { streamText } from 'ai';
import 'dotenv/config';

async function main() {
  const result = streamText({
    model: 'openai/gpt-5.5',
    prompt: 'Invent a new holiday and describe its traditions.',
  });

  for await (const textPart of result.textStream) {
    process.stdout.write(textPart);
  }

  console.log();
  console.log('Token usage:', await result.usage);
  console.log('Finish reason:', await result.finishReason);
}

main().catch(console.error);
```

You should see the AI model’s response stream to your terminal.

### Terminal

```bash
pnpm tsx index.ts
```

- ### [Provider and model routing with fallbacks](https://vercel.com/docs/ai-gateway/models-and-providers/provider-options)

- ### [AI SDK documentation](https://ai-sdk.dev/getting-started)

- ### [OpenAI Chat Completions API](https://vercel.com/docs/ai-gateway/sdks-and-apis/openai-chat-completions)

Set up your project

### Terminal

Install dependencies

### Terminal

Set up your API key

### .env.local

Create your script

Create the `index.ts` file.

### index.ts

```ts
import { streamText } from 'ai';
import 'dotenv/config';

async function main() {
  const result = streamText({
    model: 'openai/gpt-5.5',
    prompt: 'Invent a new holiday and describe its traditions.',
  });

  for await (const textPart of result.textStream) {
    process.stdout.write(textPart);
  }

  console.log();
  console.log('Token usage:', await result.usage);
  console.log('Finish reason:', await result.finishReason);
}

main().catch(console.error);
```

Run your script

### Terminal

```bash
pnpm tsx index.ts
```

Next steps

## Frequently asked questions

How is AI Gateway priced?

We offer tokens at list price from the upstream providers with no markup, including when you bring your own keys. Certain capabilities are available at higher plan tiers and metered separately. Invoicing is available with no payment processing fees. See the [pricing page](https://vercel.com/docs/ai-gateway/pricing) for details.

What's the difference between using AI Gateway and going direct to each provider?

AI Gateway gives you one integration, automatic failover, unified spend tracking, and one invoice across every major provider. Going direct means signing N contracts and stitching together N billing dashboards.

Will AI Gateway work with our existing AI stack?

Almost certainly. AI Gateway supports the [AI SDK](https://vercel.com/docs/ai-gateway/sdks-and-apis/ai-sdk), [OpenAI Chat Completions](https://vercel.com/docs/ai-gateway/sdks-and-apis/openai-chat-completions), [OpenAI Responses](https://vercel.com/docs/ai-gateway/sdks-and-apis/responses), [Anthropic Messages](https://vercel.com/docs/ai-gateway/sdks-and-apis/anthropic-messages-api), and an [OpenResponses](https://vercel.com/docs/ai-gateway/sdks-and-apis/openresponses)\-compatible endpoint. Migrating is typically a base URL swap with no code changes.

Which modalities does AI Gateway support?

[Text](https://vercel.com/docs/ai-gateway/getting-started/text), [image](https://vercel.com/docs/ai-gateway/capabilities/image-generation), [video](https://vercel.com/docs/ai-gateway/capabilities/video-generation), [embeddings](https://vercel.com/docs/ai-gateway/capabilities/embeddings), and [reranking](https://vercel.com/docs/ai-gateway/capabilities/reranking), all through the same endpoint. Browse the [full model catalog](https://vercel.com/ai-gateway/models) for specific models and providers.

How does AI Gateway handle our enterprise security and compliance requirements?

AI Gateway supports Zero Data Retention routing, a no-training guarantee, and team-wide provider allowlists. See the [security overview](https://vercel.com/docs/ai-gateway/capabilities) for full details.

What observability does AI Gateway provide out of the box?

A [dashboard](https://vercel.com/docs/ai-gateway/capabilities/observability) with usage, spend, request volume, TTFT, and token counts, broken down by model, provider, and project. For deeper analysis, the [Custom Reporting API](https://vercel.com/docs/ai-gateway/capabilities/custom-reporting) lets you pull the same data into your own tools.

Can we use our existing provider contracts and committed spend?

Yes, through [BYOK](https://vercel.com/docs/ai-gateway/authentication-and-byok/byok). Bring your own keys for almost every supported provider and your existing commitments flow through. We try BYOK first and only fall back to system credentials on failure.

Do I pay per request or get invoiced?

AI Gateway uses pre-purchased credits by default. Top up in the [dashboard](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai-gateway&title=AI+Gateway+Dashboard) and usage is drawn down per request. Enterprise customers can switch to a single consolidated invoice from Vercel covering every provider in their routing pool. For invoicing, [reach out to sales](https://vercel.com/contact/sales) for more details.

Can we purchase AI Gateway through AWS Marketplace?

Yes. AI Gateway is live on [AWS Marketplace](https://aws.amazon.com/marketplace/search/results?searchTerms=vercel+ai+gateway) and available to purchase via AWS private offers. Procure it directly through AWS Marketplace and apply the spend toward your existing AWS cloud commits, within your existing budgets and procurement processes.