---
title: Vercel AI Gateway vs Datadog AI Gateway
description: Compare Vercel AI Gateway and Datadog AI Gateway as LLM gateways, including providers, routing, access control, spend limits, guardrails, and observability.
keywords: ["Vercel AI Gateway","Datadog AI Gateway","LLM gateway","model routing","AI spend controls"]
url: "https://vercel.com/kb/guide/vercel-ai-gateway-vs-datadog-ai-gateway"
published: 2026-12-01
last_updated: 2026-12-01
authors: Ben Sabic
related_resources:
  - title: "Migrate from Cloudflare AI Gateway to Vercel AI Gateway"
    url: "/kb/guide/cloudflare-aig-to-vercel-aig"
    description: "Swap Cloudflare's base URL and cf-aig-* headers for Vercel's, map each model to a creator/model slug, and move caching, rate limits, and guardrails into your app."
  - title: "Migrate from Netlify AI Gateway to Vercel AI Gateway"
    url: "/kb/guide/netlify-aig-to-vercel-aig"
    description: "Replace Netlify's injected provider keys and base URLs with a Vercel AI Gateway credential, map each model to a creator/model slug, and move Gemini SDK calls to a supported API."
  - title: "Migrate from Neon AI Gateway to Vercel AI Gateway"
    url: "/kb/guide/neon-aig-to-vercel-aig"
    description: "Swap Neon's per-branch base URL and credential for Vercel's, map each short model ID to a creator/model slug, and replace the Gemini endpoint, rate limits, and daily spend cap."
install_vercel_plugin: npx plugins add vercel/vercel-plugin
search_with_vercel_cli: npx vercel@latest kb search "<query>"
read_with_vercel_cli: "npx vercel@latest kb inspect vercel-ai-gateway-vs-datadog-ai-gateway"
---

[Vercel AI Gateway](https://vercel.com/docs/ai-gateway) and [Datadog AI Gateway](https://docs.datadoghq.com/ai_gateway/) are LLM gateways for applications and coding agents. Vercel provides a model catalog you can use with its provider keys or your own. Datadog connects your provider accounts and brings gateway requests into Agent Observability. Both support routing and spend controls.

Choose Vercel AI Gateway for models without separate provider accounts, routing set per request, AI SDK integration, or zero data retention controls. Choose Datadog AI Gateway for individual access policies, AI Guard checks, or configurable rate limits alongside Datadog observability.

## How Vercel AI Gateway and Datadog AI Gateway compare

Datadog AI Gateway is in Preview, described at launch as Limited Availability for all Datadog customer organizations. Subscription providers, rate limits, and guardrails require separate enablement through your Customer Success Manager.

### Providers, models, and APIs

Vercel's public catalog uses `creator/model-name` IDs. Teams with purchased credits and a positive balance can also register publicly reachable HTTPS endpoints through [Private Inference](https://vercel.com/docs/ai-gateway/security-and-compliance/private-inference) and call them as `private/<slug>`. Datadog models come from connected provider accounts and use a provider slug you choose.

Both gateways accept OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages requests. Configure your client's base URL, credential, and model ID for the gateway you use.

| Concern               | Vercel AI Gateway                                                                                                                                                                                                              | Datadog AI Gateway                                                                                                                                                |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Model source          | Public catalog of 400+ models in the [model list](https://vercel.com/ai-gateway/models), plus your own endpoints through Private Inference                                                                                     | Models discovered from each [provider](https://docs.datadoghq.com/ai_gateway/providers/) you connect, plus any you add manually                                   |
| Provider credentials  | Vercel's provider keys, or your own through [BYOK](https://vercel.com/docs/ai-gateway/authentication-and-byok/byok)                                                                                                            | For API-funded traffic, your provider credentials in Datadog integration accounts. Preview subscription providers use individual Claude or ChatGPT subscriptions. |
| Provider types        | Catalog providers and your own compatible HTTPS endpoints. Several catalog providers can serve one model.                                                                                                                      | OpenAI, Anthropic, Azure OpenAI, Amazon Bedrock, Vertex AI, Azure AI Foundry, Baseten, Fireworks AI, Together AI, TypeSafe, and Custom Provider                   |
| Model ID              | `creator/model-name` for catalog models; `private/<slug>` for private models                                                                                                                                                   | `<PROVIDER_SLUG>/<MODEL_ID>`, or `router/<RULE_SLUG>` for a routing rule                                                                                          |
| Other request formats | The [AI SDK](https://vercel.com/docs/ai-gateway/sdks-and-apis/ai-sdk), OpenResponses, OpenAI-compatible Decisions, Cohere Rerank, and TypeSafe, listed under [SDKs and APIs](https://vercel.com/docs/ai-gateway/sdks-and-apis) | Gemini `generateContent`, Gemini `rawPredict`, Decisions, and System One, listed under [request formats](https://docs.datadoghq.com/ai_gateway/requests/)         |
| Gemini models         | Through the AI SDK and the OpenAI-compatible APIs. The native Gemini format isn't accepted.                                                                                                                                    | Through Vertex AI providers. The Gemini API isn't supported as a provider.                                                                                        |
| Coding agents         | [`vercel ai-gateway setup`](https://vercel.com/docs/ai-gateway/coding-agents) configures supported agents, including Claude Code and Codex                                                                                     | [Trajectory](https://docs.datadoghq.com/ai_gateway/applications), Datadog's open source CLI, connects Claude Code and Codex                                       |

Both gateways use different base URLs for OpenAI and Anthropic clients. Use the endpoint for your client format; the [SDK examples](#core-sdk-calls) include the OpenAI configuration.

Datadog's provider selector shows the integrations available to your organization. For another backend, connect a [Custom Provider](https://docs.datadoghq.com/ai_gateway/providers/) over HTTPS using OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, or System One requests.

With Vercel AI Gateway, an OpenAI SDK client can call models from other creators because the request format doesn't select the provider.

Datadog translates supported formats but implements only part of each API. Translation cannot resolve `previous_response_id` or server-stored conversations. Test parameters and tools before switching models.

### Routing and fallbacks

Vercel AI Gateway picks a provider for each request and accepts routing options in the request itself. Datadog AI Gateway sends a direct model request to the provider named in the model ID. Other routing goes through [routing rules](https://docs.datadoghq.com/ai_gateway/routing/) that you configure in Datadog and call as `router/<RULE_SLUG>`.

| Concern                 | Vercel AI Gateway                                                                                                                                                                                                                                                           | Datadog AI Gateway                                                                                                                                          |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Default routing         | Providers ordered by each model's default priority and by recent uptime and latency, with failover to other providers that serve the model                                                                                                                                  | The provider in the model ID, or the destinations in a routing rule                                                                                         |
| Provider preference     | In [`providerOptions.gateway`](https://vercel.com/docs/ai-gateway/models-and-providers/provider-options), `order` prefers providers and keeps failover, `only` restricts routing to the listed providers, and `sort` ranks them by cost, time to first token, or throughput | Each destination uses one provider account, or any configured provider that serves the model, tried in slug order                                           |
| Model fallbacks         | The [`models`](https://vercel.com/docs/ai-gateway/models-and-providers/model-fallbacks) [array](https://vercel.com/docs/ai-gateway/models-and-providers/model-fallbacks), tried in order when every provider for the primary model fails                                    | Fallback steps in priority order for unavailable destinations or HTTP 401, 402, 403, 408, 429, or 5xx responses. Stateful pinned sessions cannot fall back. |
| Traffic splits          | In your application code                                                                                                                                                                                                                                                    | Weighted steps divide sessions between destinations by relative weight                                                                                      |
| Stable model aliases    | Virtual models with a `vmc/<slug>` ID, and Custom Routing, in Beta, with a `router/<slug>` ID                                                                                                                                                                               | `router/<RULE_SLUG>`                                                                                                                                        |
| Conversation stickiness | [Session affinity](https://vercel.com/docs/ai-gateway/models-and-providers/session-affinity) keeps a conversation on the provider that holds its prompt cache                                                                                                               | Session pinning keeps a routing rule's session on one destination. The pin expires 4 hours after the session's last successful response.                    |

The two products use the name "routing rule" for different things. On Vercel AI Gateway, a [routing rule](https://vercel.com/docs/ai-gateway/models-and-providers/routing-rules) rewrites requests for one model to another model, or denies a model, for the whole team. On Datadog AI Gateway, a routing rule is a named alias with a first step and optional fallback steps.

Datadog can try another destination when a budget in Block mode or a rate limit in Enforce mode blocks a request. Fallback applies before the response starts; a stream that fails partway is not retried elsewhere.

Stateful sessions remain pinned to one destination and cannot fall back, even after errors or budget and rate-limit refusals. On Vercel AI Gateway, exceeding a budget returns HTTP 402 without fallback.

### Authentication and access control

Vercel AI Gateway accepts API keys and Vercel OIDC tokens, with model restrictions configured for the team. Datadog access tokens identify callers whose model permissions come from policies for users, teams, or service accounts.

| Concern                 | Vercel AI Gateway                                                                                                                                                                                                                                                 | Datadog AI Gateway                                                                                                                                                                                                                                                                   |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Request credential      | [AI Gateway API key](https://vercel.com/docs/ai-gateway/authentication-and-byok/api-keys) or Vercel [OIDC token](https://vercel.com/docs/ai-gateway/authentication-and-byok/oidc), sent as a bearer token                                                         | For API-funded traffic, a Datadog personal, service, or Workload Identity Federation token as a bearer token. Both the principal and credential scope must allow `ai_gateway_usage`. [Subscription agents](#subscription-providers-for-claude-code-and-codex) use different headers. |
| Without a stored secret | On Vercel deployments, the AI SDK sends the project's OIDC token when `AI_GATEWAY_API_KEY` isn't set                                                                                                                                                              | For workloads in AWS, Workload Identity Federation exchanges the AWS role for a short-lived Datadog token                                                                                                                                                                            |
| Who can call a model    | Team-wide [model](https://vercel.com/docs/ai-gateway/security-and-compliance/model-allowlist) and [provider](https://vercel.com/docs/ai-gateway/security-and-compliance/provider-allowlist) allowlists on Pro and Enterprise, and routing rules that deny a model | [Access policies](https://docs.datadoghq.com/ai_gateway/access_control/) that give users, Datadog teams, and service accounts Viewer, Runner, or Editor access to providers, models, and routing rules                                                                               |
| Default                 | Allowlists are opt-in                                                                                                                                                                                                                                             | Access is denied unless a policy grants it. Models on a new provider return HTTP 403 with `no_permitted_target` until a policy covers them.                                                                                                                                          |

On Datadog AI Gateway, Runner and Editor access let a caller use a policy's models, and Viewer access doesn't. Check two defaults before rollout. New policies are open to everyone in the organization until you set their access, and Datadog's Standard role includes the `ai_gateway_usage` permission.

On Vercel AI Gateway, you separate workloads by credential. Give each application or environment its own API key, scope it to a project when its spend should count toward that project, and set a budget on it.

### Spend controls and rate limits

Both gateways check budgets before a request runs and can reject further requests with HTTP 402. The request that crosses the threshold completes, so spend can exceed the limit. Datadog also supports configurable rate limits in Preview.

| Concern             | Vercel AI Gateway                                                                                                                                          | Datadog AI Gateway                                                                                                                                                                                   |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Budget scope        | Team, project, API key, or Vercel team member, set under [budgets](https://vercel.com/docs/ai-gateway/observability-and-spend/budgets)                     | All traffic, or a user, team, model, provider, or custom tag, as one shared allowance or one for each value, set under [spend controls](https://docs.datadoghq.com/ai_gateway/spend_controls/)       |
| At the limit        | HTTP 402 with `quota_for_entity_exceeded`                                                                                                                  | Block mode returns HTTP 402 until the window resets. Alert-only mode lets requests continue and alerts through a Datadog monitor.                                                                    |
| Spend it counts     | Model usage billed through Vercel's keys and fees for BYOK without fallback. Provider-side BYOK charges are excluded by default.                           | The estimated cost of requests to your provider accounts. Subscription provider traffic and operations not metered by tokens aren't counted.                                                         |
| Rate limits you set | None. Vercel sets [rate limits](https://vercel.com/docs/ai-gateway/rate-limits) for each tier, and the paid tier removes the free tier's per-model limits. | Requests, input tokens, or output tokens per minute. The API also supports spend limits and longer rolling windows, with longer windows requiring separate Preview enablement for your organization. |
| Over a rate limit   | HTTP 429 with `rate_limit_exceeded`                                                                                                                        | Alert mode, the default, lets requests continue. Enforce mode returns HTTP 429 with `gateway_rate_limit`.                                                                                            |

Vercel AI Gateway checks every applicable budget. An entity without its own budget adds no separate cap, but other budgets still apply. Exhausting a budget rejects all requests in its scope, including BYOK requests.

Datadog's budgets and rate limits can fail open. If AI Gateway can't complete a budget or rate limit check, it allows the request. Datadog recommends treating both as operational guardrails, starting budgets in Alert-only mode, and using provider-side spend caps, where available, as a backstop.

For a request-rate limit on Vercel, protect your model endpoint with [WAF rate limiting](https://vercel.com/docs/vercel-firewall/vercel-waf/rate-limiting) or limit requests in your application.

### Guardrails and data handling

Datadog AI Gateway can evaluate prompts against an AI Guard policy and block the ones the policy denies. Vercel AI Gateway has no built-in guardrails, so content checks run in your application. Its data controls decide which providers can receive a request and what they may do with the data.

| Concern                   | Vercel AI Gateway                                                                                                                                                                                                                              | Datadog AI Gateway                                                                                                                                                       |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Content guardrails        | None built in. Run checks around the model call, for example with a [decision model](https://vercel.com/docs/ai-gateway/getting-started/decision).                                                                                             | [Guardrails](https://docs.datadoghq.com/ai_gateway/security/) attach an AI Guard policy to all traffic or to one routing rule, in Monitor only or Block unsafe mode      |
| Sensitive data in prompts | No built-in scanning or redaction                                                                                                                                                                                                              | An AI Guard policy can scan for sensitive data. For guardrails created in the AI Gateway UI, Block unsafe blocks findings. The gateway doesn't redact forwarded content. |
| What the gateway keeps    | AI Gateway deletes prompts and responses after the request completes. Logs hold request metadata.                                                                                                                                              | Metadata only, the default, records no prompt or response content. Full capture adds prompt, response, reasoning, and tool content to the span.                          |
| Provider data handling    | [Zero data retention](https://vercel.com/docs/ai-gateway/security-and-compliance/zdr) (ZDR) routing, [disallow prompt training](https://vercel.com/docs/ai-gateway/security-and-compliance/disallow-prompt-training), and a provider allowlist | Your organization reviews the data processing terms of the providers it configures                                                                                       |

Datadog's guardrails cover part of the traffic. In Block unsafe mode, AI Guard evaluates supported prompt text before the model call for Chat Completions, Responses, and Messages requests, and evaluates output for successful, buffered Chat Completions responses. AI Guard doesn't evaluate streamed output, native Gemini requests, or tool definitions, calls, and results. Monitor only evaluates prompts asynchronously and doesn't block.

When an evaluator timeout, network error, or server error prevents evaluation, a Block unsafe guardrail created in the AI Gateway UI refuses the request, and Monitor only lets it through. Refused requests return HTTP 422 on OpenAI-compatible APIs and HTTP 400 on native Anthropic requests.

With Full capture, anyone in your organization who can view Agent Observability traces can read the captured prompts and responses, unless you place those spans in a Restricted Dataset.

### Observability

Vercel AI Gateway shows usage and spend in its dashboard and can export request traces. Datadog records supported inference requests in Agent Observability, where spans can join the calling application's trace. Early rejections, such as authentication failures or malformed bodies, may not appear.

| Concern               | Vercel AI Gateway                                                                                                                                                                                                                                 | Datadog AI Gateway                                                                                                         |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| Where requests appear | [Observability](https://vercel.com/docs/ai-gateway/observability-and-spend/observability) charts and [Logs](https://vercel.com/docs/ai-gateway/observability-and-spend/logs) in the Vercel dashboard, and `vercel ai-gateway requests` in the CLI | The AI Gateway [Overview](https://docs.datadoghq.com/ai_gateway/observability/) page and Agent Observability traces        |
| Request record        | Status, model, provider, token usage, cost, duration, authentication, and every routing attempt                                                                                                                                                   | Model, provider, status, latency, token usage, and cost, plus the request's tag values and the caller's email              |
| Prompts and responses | Not logged                                                                                                                                                                                                                                        | Recorded with Full capture                                                                                                 |
| Usage attribution     | `user` and `tags` in `providerOptions.gateway`, queried with [Custom Reporting](https://vercel.com/docs/ai-gateway/observability-and-spend/custom-reporting) on Pro and Enterprise                                                                | The authenticated credential identifies the caller. Request headers add a team, an application name, and custom tags.      |
| Traces                | [Trace Drains](https://vercel.com/docs/ai-gateway/observability-and-spend/trace-drains), on Pro and Enterprise, export OpenTelemetry traces to your observability tool according to your sampling rules                                           | Accepts Datadog trace propagation and W3C Trace Context, and can nest its span under the caller's Agent Observability span |

By default, Datadog AI Gateway traces appear under the application `datadog-ai-gateway`, and the `x-dd-tag-ml_app` request header names your own. When a request can reach more than one model, Datadog produces one trace with a workflow span, and the routing decision, the model call, and each fallback attempt appear as its children.

Vercel's Logs and traces leave out prompt and completion content, so write prompts to your own store if your team needs to read them back.

### Regions

Vercel AI Gateway's default endpoint is `ai-gateway.vercel.sh`. [Regional Hosting](https://vercel.com/docs/ai-gateway/security-and-compliance/regional-hosting), which is in beta, adds the `eu.ai-gateway.vercel.sh` and `us.ai-gateway.vercel.sh` endpoints to control where AI Gateway receives requests, at 5% of inference cost on Pro and Enterprise. [Regional inference](https://vercel.com/docs/ai-gateway/security-and-compliance/regional-inference) is a separate setting that pins the region where the provider runs inference, where the provider supports it.

Datadog AI Gateway's host depends on your Datadog site, and the product isn't supported on the government sites `app.ddog-gov.com` and `us2.ddog-gov.com`. For Amazon Bedrock and Vertex AI providers, you select the Region or Location used for inference when you connect the provider. Datadog's AI Gateway docs describe no other control over where requests are processed.

### Core SDK calls

Use the OpenAI TypeScript SDK to send Chat Completions requests through either gateway. Install the client:

**pnpm**

```bash
pnpm i openai
```

**npm**

```bash
npm i openai
```

**yarn**

```bash
yarn add openai
```

**bun**

```bash
bun add openai
```

Save the Vercel client as `vercel-client.mts` or the Datadog client as `datadog-client.mts`. Put the selected client's credential in `.env.local` and keep that file out of version control. Each run sends a billable model request.

- Vercel AI Gateway takes an AI Gateway API key in `AI_GATEWAY_API_KEY`. [Get started](#get-started-with-vercel-ai-gateway) covers creating one.
  
- Datadog AI Gateway takes a Datadog personal access token or service access token in `DD_AI_GATEWAY_TOKEN`. The token must allow `ai_gateway_usage`, and an access policy must allow the model.
  

**Vercel AI Gateway**

```typescript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.AI_GATEWAY_API_KEY,
  baseURL: 'https://ai-gateway.vercel.sh/v1',
});

const response = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-5",
  messages: [{ "role": "user", "content": "Why is the sky blue?" }],
});

console.log(response.choices[0]?.message.content);
```

**Datadog AI Gateway**

```typescript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.DD_AI_GATEWAY_TOKEN,
  baseURL: 'https://ai-gateway.<YOUR_DATADOG_SITE>/ai/v1',
});

const response = await client.chat.completions.create({
  model: "<PROVIDER_SLUG>/<MODEL_ID>",
  messages: [{ "role": "user", "content": "Why is the sky blue?" }],
});

console.log(response.choices[0]?.message.content);
```

For Datadog, copy the full base URL from its [Get Started page](https://docs.datadoghq.com/ai_gateway/getting_started/) after selecting your site. Replace `<PROVIDER_SLUG>/<MODEL_ID>` with a model returned by `GET /ai/v1/models` for your credential.

On Datadog AI Gateway, a bare model name fails with `model_not_found` unless the request also sets the `x-ai-gateway-provider` header.

With Node.js 22.18 or later, run `node --env-file=.env.local vercel-client.mts`. For the Datadog client, use `datadog-client.mts` as the filename.

The AI SDK is the recommended client for TypeScript applications on Vercel AI Gateway, and the example under [Get started](#get-started-with-vercel-ai-gateway) uses it.

### Python SDK calls

Use the OpenAI Python SDK to send Responses API requests through either gateway. Install the client:

```bash
pip install openai
```

Save the Vercel client as `quickstart.py` or the Datadog client as `gateway_example.py`. Export the required variables first; Python does not load `.env.local` automatically. Each run sends a billable model request.

**Vercel AI Gateway**

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv('AI_GATEWAY_API_KEY'),
    base_url='https://ai-gateway.vercel.sh/v1',
)

response = client.responses.create(
    model='anthropic/claude-opus-5',
    input='Explain quantum computing in one paragraph.',
)

print(response.output_text)
```

**Datadog AI Gateway**

```python
import os

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["DD_AI_GATEWAY_TOKEN"],
    base_url="https://ai-gateway.<YOUR_DATADOG_SITE>/ai/v1",
    default_headers={"x-dd-tag-ml_app": "my-application"},
)

response = client.responses.create(
    model=os.environ["DD_AI_GATEWAY_MODEL"],
    input="Reply with exactly: Gateway connected.",
)
print(response.output_text)
```

For Vercel, set `AI_GATEWAY_API_KEY` to your AI Gateway key. For Datadog, set `DD_AI_GATEWAY_TOKEN` to your access token and `DD_AI_GATEWAY_MODEL` to a model ID returned for that credential. Replace the Datadog base URL with your site's full endpoint, as in the [TypeScript setup](#core-sdk-calls).

Datadog's `x-dd-tag-ml_app` header names the application in Agent Observability. Run the file you saved with `python3 quickstart.py` or `python3 gateway_example.py`.

## Where Vercel AI Gateway goes deeper

The feature examples use the AI SDK. Complete [authentication and installation](#get-started-with-vercel-ai-gateway) first, then save each file under its displayed filename. Run it with Node.js and load `.env.local`, for example: `node --env-file=.env.local request-byok.mts`.

### Catalog models on Vercel's provider keys

Use Vercel's provider keys to call catalog models without separate provider accounts. Token charges use the provider's list price and draw from [AI Gateway Credits](https://vercel.com/docs/ai-gateway/pricing), with no markup or base platform fee. Every team can also use a subset of models on the free tier at lower rate limits.

For API-funded traffic, Datadog AI Gateway connects your own provider accounts through Datadog integrations. Its Preview subscription providers let Claude Code and Codex use each user's Claude or ChatGPT subscription.

### Your own provider keys, with fallback to Vercel's

[BYOK](https://vercel.com/docs/ai-gateway/authentication-and-byok/byok) stores provider credentials for the team's projects. Failed requests retry with Vercel's keys by default and charge that usage to your credits.

BYOK requires purchased credits and a positive balance. Turning off **Fallback to Vercel Keys** prevents this retry path and costs $0.20 per 1,000 BYOK requests.

One request can also carry its own provider key. Add your Anthropic key as `ANTHROPIC_API_KEY` in `.env.local`; AI Gateway authentication is still required:

```typescript
import { gateway } from '@ai-sdk/gateway';
import { generateText } from 'ai';

const { text } = await generateText({
  model: gateway('anthropic/claude-sonnet-5'),
  prompt: 'Explain quantum computing in two sentences.',
  providerOptions: {
    gateway: {
      byok: {
        anthropic: [
          {
            apiKey: process.env.ANTHROPIC_API_KEY!,
          },
        ],
      },
    },
  },
});

console.log(text);
```

For a request that brings its own credentials, AI Gateway skips the keys stored for the team. For API-funded traffic on Datadog, provider credentials stay in integration accounts and applications authenticate with Datadog tokens.

### Routing options in the request

Each request can set its own routing in `providerOptions.gateway`, which you pass in an AI SDK call or in the JSON body of a Chat Completions, Messages, or Responses request. This request names one fallback model:

```typescript
import { gateway } from '@ai-sdk/gateway';
import { generateText } from 'ai';

const { text } = await generateText({
  model: gateway('anthropic/claude-opus-5.5'),
  prompt: 'Write a haiku about TypeScript.',
  providerOptions: {
    gateway: {
      models: ['openai/gpt-5.5'],
    },
  },
});

console.log(text);
```

AI Gateway tries `openai/gpt-5.5` after every provider for the primary model fails. Datadog stores provider order and fallbacks in a routing rule, which the request selects using its `router/<RULE_SLUG>` model ID.

### Zero data retention routing

Enable **Zero Data Retention** in team settings or set `zeroDataRetention: true` per request. Routing is then limited to providers whose policy or agreement with Vercel commits them to ZDR.

ZDR requires a Pro or Enterprise plan, or purchased credits. Per-request ZDR adds no charge; team-wide enforcement costs $0.10 per 1,000 requests.

```typescript
import { gateway } from '@ai-sdk/gateway';
import { generateText } from 'ai';

const { text } = await generateText({
  model: gateway('anthropic/claude-sonnet-5'),
  prompt: 'Analyze this example business data: revenue grew by 5%.',
  providerOptions: {
    gateway: {
      zeroDataRetention: true,
    },
  },
});

console.log(text);
```

The request fails if no eligible provider can serve the model. Check the provider's ZDR terms for exclusions covering models, tools, or request types. AI Gateway also skips BYOK keys unless you mark them as ZDR-compliant.

### AI SDK, eve, and framework integrations

The AI SDK uses AI Gateway by default for string model IDs, so TypeScript apps can call catalog models without a separate provider client. Other agent frameworks connect through dedicated adapters or built-in providers:

- [eve](https://eve.dev/docs/agent-config): Set a Gateway model ID in your agent configuration to route calls through AI Gateway. eve passes a conversation ID automatically, grouping calls in Gateway logs and supporting session affinity within your allowed providers.
  
- [TanStack AI](https://vercel.com/docs/ai-gateway/ecosystem/framework-integrations/tanstack-ai): Its adapter supports chat, embeddings, and image generation. Each request can set provider preferences and model fallbacks.
  
- [Mastra](https://vercel.com/docs/ai-gateway/ecosystem/framework-integrations/mastra): Its agents accept the AI SDK's Gateway provider as their model, giving them access to Gateway's catalog and routing options.
  
- [Flue](https://vercel.com/docs/ai-gateway/ecosystem/framework-integrations/flue): Its built-in `vercel-ai-gateway` provider routes the model selected with `useModel()` through AI Gateway. It reads an AI Gateway API key; OIDC requires a custom authentication resolver.
  

Vercel AI Gateway supports [multiple modalities](https://vercel.com/docs/ai-gateway/modalities), including image and video generation, speech, transcription, realtime, embeddings, and reranking. These use the same gateway credential.

### Automatic prompt caching

Set [`caching: 'auto'`](https://vercel.com/docs/ai-gateway/models-and-providers/automatic-caching) and AI Gateway applies the caching strategy each provider needs, adding cache markers for providers such as Anthropic that require them. Vercel AI Gateway doesn't cache full responses, and Datadog's docs describe no response cache, so cache responses in your application with either product.

## Where Datadog AI Gateway goes deeper

### Guardrails backed by AI Guard

Each guardrail attaches an AI Guard policy to all AI Gateway traffic or to one routing rule. The [policy](https://docs.datadoghq.com/security/ai_guard/policies) defines what AI Guard detects, with settings such as evaluation sensitivity, sensitive data scanning, and custom keyword or regular-expression rules. Start in Monitor only to observe policy decisions, then select Block unsafe to enforce them, within the coverage limits in [Guardrails and data handling](#guardrails-and-data-handling).

For Vercel AI Gateway, put input and output checks in your application.

### Access policies with reasoning ceilings

Access policies decide who can call each provider, model, and routing rule. With access to a routing rule, a caller can use every provider the rule reaches without direct access to those models.

Datadog policies limit reasoning from Off to Max and can disallow a provider's fast mode. The gateway rejects explicit settings above the ceiling instead of lowering them. Vercel's model and provider allowlists and deny rules cover the whole team.

For OpenAI and native Gemini requests, omitted reasoning settings use the provider's default. Send an explicit value for Datadog to check against the ceiling.

### Routing by session, weight, and decision model

Weighted steps split sessions across destinations. Each session keeps the same destination order so later requests can reuse a provider's prompt cache. Datadog recommends introducing a model with 5% to 10% of sessions.

Smart routing uses a decision model to choose one of 1 to 9 destinations from the opening user messages and a rubric for each destination. Decision calls use your provider account and count toward budgets and rate limits. Keep security, privacy, and compliance rules separate from this model-based choice.

Vercel's Custom Routing, in Beta, selects models, virtual models, or other routers by declared order, cost, time to first token, or output throughput.

### Rate limits and budgets on your own provider accounts

Datadog supports up to 100 active rate-limit rules per organization in Preview. Its budgets count the estimated cost of traffic to your provider accounts and can assign an allowance to each user, team, model, provider, or tag value.

Vercel budgets count usage billed through Vercel's keys and the fee for BYOK without fallback. Use your provider's spending controls for its token charges.

### Subscription providers for Claude Code and Codex

Datadog's Preview subscription providers let Claude Code and Codex use each user's Claude or ChatGPT subscription. The agent sends the user's Datadog personal access token in `dd-application-key` and keeps the vendor subscription credential in `Authorization`.

Datadog applies access policies and rate limits and records the user's requests in Agent Observability. Budgets do not count or block subscription traffic.

On Vercel AI Gateway, [Claude Code](https://vercel.com/docs/ai-gateway/coding-agents/claude-code) can sign in with a Claude subscription and route through the gateway, where its requests appear in observability. The `vercel ai-gateway setup` command configures API-key authentication.

### Spans in Agent Observability

When your team already investigates agents in Datadog, gateway requests arrive in the same product. The gateway span can nest under your application's Agent Observability span when the propagated context carries that trace ID and parent span ID. Without that context, each request starts its own trace.

Data capture can differ by workload. An override can match a user, team, model, provider, or custom tag, and when overrides conflict, Metadata only applies.

### Workload Identity Federation and configuration as code

For workloads running in AWS, Workload Identity Federation exchanges the workload's AWS role for a short-lived Datadog token, so you don't create, store, or rotate a Datadog credential for that application. Datadog also recommends managing gateway configuration as code with approved automation, such as Terraform, so changes are versioned and reviewed.

On Vercel AI Gateway, the keyless path is the OIDC token on Vercel deployments, and code on other hosts uses an API key. The [`vercel ai-gateway`](https://vercel.com/docs/cli/ai-gateway) CLI manages API keys, budgets, and routing rules.

## Estimate costs for your workload

For Vercel AI Gateway, estimate token cost from the provider's list price for each model in the [model list](https://vercel.com/ai-gateway/models). Add the [surcharges](https://vercel.com/docs/ai-gateway/pricing) for the optional features you turn on, such as team-wide allowlists, team-wide ZDR, regional endpoints, Custom Reporting, and Trace Drains. Payment processing fees may apply. With BYOK, your provider bills the tokens directly.

Ask Datadog to confirm gateway, observability, and AI Guard charges.

## Choose by workload requirements

Compare the two gateways against your requirements:

| Requirement                                                        | Product fit                  | Reason                                                                                                                            |
| ------------------------------------------------------------------ | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| Call models without opening provider accounts                      | Vercel AI Gateway            | Vercel's provider keys and AI Gateway Credits, with a catalog of 400+ models                                                      |
| Set provider order or fallback models in the request               | Vercel AI Gateway            | `order`, `only`, `sort`, and `models` in `providerOptions.gateway`                                                                |
| Route to providers with zero data retention agreements             | Vercel AI Gateway            | ZDR team-wide or per request                                                                                                      |
| Image, video, speech, or embedding models through the same gateway | Vercel AI Gateway            | Modalities beyond text under one credential                                                                                       |
| Authenticate without a stored secret                               | Both, with different setup   | Vercel uses the project's OIDC token on Vercel deployments. Datadog uses Workload Identity Federation for workloads in AWS.       |
| Block or monitor unsafe prompts at the gateway                     | Datadog AI Gateway           | Guardrails with AI Guard policies, in Preview                                                                                     |
| Model access by user, team, or service account                     | Datadog AI Gateway           | Access policies with Viewer, Runner, and Editor levels                                                                            |
| Weighted traffic splits or model-chosen destinations               | Datadog AI Gateway           | Weighted and Smart steps in a routing rule                                                                                        |
| Coding agents on existing subscriptions                            | Both, with different support | Vercel supports Claude Code with a Claude subscription. Datadog supports Claude Code and Codex subscription providers in Preview. |

## Get started with Vercel AI Gateway

You need a [Vercel account](https://vercel.com/signup), the [Vercel CLI](https://vercel.com/docs/cli), and Node.js 22.18 or later. Your application doesn't need to run on Vercel.

The example consumes AI Gateway Credits, so if your team hasn't purchased credits, replace its model with one from the [free tier](https://vercel.com/ai-gateway/models?freeTier=true).

Choose project OIDC or an AI Gateway API key for local authentication.

### Use a project token

Link your working directory to a Vercel project:

```bash
vercel link
```

Pull the project's development environment variables, including its OIDC token, into `.env.local`. Rerun this command when the token expires after 12 hours:

```bash
vercel env pull
```

### Use an API key

Create an API key with the Vercel CLI to authenticate from any environment:

```bash
vercel ai-gateway api-keys create --name my-api-key
```

Add the key to the `.env.local` env file:

```text
AI_GATEWAY_API_KEY=your_ai_gateway_api_key
```

Replace `your_ai_gateway_api_key` with the key's value, and keep the file out of version control. Any non-empty API key takes priority over the OIDC token, so set the key only when you intend to use it.

### Run your first request

Install the AI SDK and the Gateway provider:

**pnpm**

```bash
pnpm add ai@7 @ai-sdk/gateway
```

**yarn**

```bash
yarn add ai@7 @ai-sdk/gateway
```

**npm**

```bash
npm install ai@7 @ai-sdk/gateway
```

**bun**

```bash
bun add ai@7 @ai-sdk/gateway
```

Create `index.mts` with a call that selects its model through `gateway()`:

```typescript
import { gateway } from '@ai-sdk/gateway';
import { generateText } from 'ai';

const { text } = await generateText({
  model: gateway('openai/gpt-6-luna'),
  prompt: 'Why is the sky blue?',
});

console.log(text);
```

Run the script with the environment file loaded:

```bash
node --env-file=.env.local index.mts
```

The script prints the model's answer. To confirm that the request went through AI Gateway, list your team's recent requests:

```bash
vercel ai-gateway requests list --since 24h
```

The request also appears in [Logs](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai-gateway%2Flogs&title=AI+Gateway+Logs) in the Vercel dashboard, where new rows can take about 90 seconds to show.

## Next steps

- Read the [Vercel AI Gateway docs](https://vercel.com/docs/ai-gateway) for models, APIs, and settings
  
- Set [provider order and model fallbacks](https://vercel.com/docs/ai-gateway/models-and-providers/provider-options) for a request
  
- Limit spend with [budgets](https://vercel.com/docs/ai-gateway/observability-and-spend/budgets) for a team, project, API key, or team member
  
- Restrict where your data goes with [zero data retention and provider controls](https://vercel.com/docs/ai-gateway/security-and-compliance)
  
- Migrate from [Cloudflare AI Gateway](https://vercel.com/kb/guide/cloudflare-aig-to-vercel-aig), [Netlify AI Gateway](https://vercel.com/kb/guide/netlify-aig-to-vercel-aig), or [Neon AI Gateway](https://vercel.com/kb/guide/neon-aig-to-vercel-aig)
  

## Frequently asked questions

### Is Datadog AI Gateway generally available?

No. Datadog AI Gateway is in Preview, described at launch as Limited Availability for Datadog customer organizations. Features such as guardrails and subscription providers require separate enablement. Vercel AI Gateway is available to every Vercel team, with a free tier and a paid tier.

### Do I need my own provider API keys for Vercel AI Gateway or Datadog AI Gateway?

Datadog AI Gateway generally uses provider accounts and credentials you supply through Datadog integrations. Its Preview subscription providers instead let Claude Code and Codex use each user's Claude or ChatGPT subscription.

Vercel AI Gateway does not require your own provider keys. Vercel's keys serve catalog models and charge them to AI Gateway Credits. BYOK is also available to teams with purchased credits and a positive balance.

### Can I use the OpenAI SDK with Vercel AI Gateway and Datadog AI Gateway?

Yes. Both gateways accept Chat Completions and Responses requests from the OpenAI SDK. Configure the gateway's base URL, credential, and model ID.

For Vercel, use a catalog model ID and its [OpenAI-compatible endpoint](https://vercel.com/docs/ai-gateway/sdks-and-apis/openai-chat-completions) with an AI Gateway key. For Datadog, copy your site's endpoint and use a model or routing-rule ID returned by `GET /ai/v1/models`.

### Does Vercel AI Gateway have guardrails like Datadog AI Gateway?

No. Vercel AI Gateway has no built-in content guardrails or sensitive-data scanning, so those checks run in your application. Datadog AI Gateway guardrails, in Preview, apply an AI Guard policy to prompts and can block them, but they don't evaluate streamed output, native Gemini requests, or tool content.

### How much do Vercel AI Gateway and Datadog AI Gateway cost?

Vercel AI Gateway charges the provider's list price through AI Gateway Credits, plus optional feature surcharges and applicable payment-processing fees. With BYOK, your provider bills inference. Check [Vercel pricing](https://vercel.com/docs/ai-gateway/pricing) and confirm Datadog's charges with your account team when estimating total spend.

### Can I set rate limits on Vercel AI Gateway and Datadog AI Gateway?

On Datadog AI Gateway, yes. Rate limits, in Preview, set per-minute limits on requests, input tokens, or output tokens, and reject requests with HTTP 429 in Enforce mode. Vercel AI Gateway has no rate limits you configure, so limit request rates in your application or with WAF rate limiting on your own endpoint.

### Can I route Claude Code and Codex through Vercel AI Gateway or Datadog AI Gateway?

Yes. On Vercel AI Gateway, the `vercel ai-gateway setup` command configures supported coding agents, including Claude Code and Codex, with an AI Gateway API key. On Datadog AI Gateway, the Trajectory CLI connects Claude Code and Codex and signs you in to Datadog.

## Related Resources

- [Migrate from Cloudflare AI Gateway to Vercel AI Gateway](/kb/guide/cloudflare-aig-to-vercel-aig): Swap Cloudflare's base URL and cf-aig-\* headers for Vercel's, map each model to a creator/model slug, and move caching, rate limits, and guardrails into your app.
- [Migrate from Netlify AI Gateway to Vercel AI Gateway](/kb/guide/netlify-aig-to-vercel-aig): Replace Netlify's injected provider keys and base URLs with a Vercel AI Gateway credential, map each model to a creator/model slug, and move Gemini SDK calls to a supported API.
- [Migrate from Neon AI Gateway to Vercel AI Gateway](/kb/guide/neon-aig-to-vercel-aig): Swap Neon's per-branch base URL and credential for Vercel's, map each short model ID to a creator/model slug, and replace the Gemini endpoint, rate limits, and daily spend cap.

## More AI Gateway guides

- [Migrate from Neon AI Gateway to Vercel AI Gateway](/kb/guide/neon-aig-to-vercel-aig): Swap Neon's per-branch base URL and credential for Vercel's, map each short model ID to a creator/model slug, and replace the Gemini endpoint, rate limits, and daily spend cap.
- [Migrate from Netlify AI Gateway to Vercel AI Gateway](/kb/guide/netlify-aig-to-vercel-aig): Replace Netlify's injected provider keys and base URLs with a Vercel AI Gateway credential, map each model to a creator/model slug, and move Gemini SDK calls to a supported API.
- [Migrate from Cloudflare AI Gateway to Vercel AI Gateway](/kb/guide/cloudflare-aig-to-vercel-aig): Swap Cloudflare's base URL and cf-aig-\* headers for Vercel's, map each model to a creator/model slug, and move caching, rate limits, and guardrails into your app.

## Reference Architecture

Choose a stack and work through the decisions behind it, with curated documentation, guides, templates, and courses to help you build.

- [Agent stack](/kb/architecture/agents): Build and operate agents with models, tools, and durable workflows.
- [Web applications](/kb/architecture/web): Choose rendering, data, authentication, and caching approaches.
- [Backends](/kb/architecture/backends): Choose a runtime, connect services, and run background work.

[Browse all stacks](/kb/architecture)

## Build with prompts

Build an app, extend an agent, or improve your project with ready-to-use prompts for your coding agent.

[Browse the prompt library](/kb/prompts) · [Read the Markdown index](/kb/prompts.md)

## Search guides from your terminal

Search the Knowledge Base and read guides as Markdown with the Vercel CLI. No login required.

```bash
# Find guides by keyword
npx vercel@latest kb search "rewrites and redirects"
npx vercel@latest kb search "AI SDK streaming"

# Show the latest guides
npx vercel@latest kb

# Print a guide as Markdown, by slug or URL
npx vercel@latest kb inspect <guide>
```
