> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zespan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel AI Gateway

> Send Vercel AI Gateway traces to Zespan with a Trace Drain, no Zespan SDK required.

> [!NOTE]
>
> Available via: **Vercel Trace Drains** (Pro and Enterprise plans). This is not a Zespan SDK wrapper, see [Send traces from any OTel-instrumented app](https://docs.zespan.com/sdk/otel-integration.md#send-traces-from-any-otel-instrumented-app-no-zespan-sdk) for how the endpoint works.

[Vercel AI Gateway](https://vercel.com/docs/ai-gateway) can drain a trace for each request. Create a Trace Drain that points at Zespan and every call through the gateway is stored with model, provider, token counts and, for calls that were retried or fell back, each attempt.

## Setup

**1. Create a Trace Drain**

In Vercel, go to **Team Settings → Drains → Add Drain**, choose **Traces**, select the projects, and use a custom endpoint with the URL `https://api.zespan.com/v1/traces`. Vercel offers JSON or Protobuf; Zespan accepts both. Vercel batches drain payloads up to 1 MB, inside Zespan's limit.

**2. Add the project key as a custom header**

Add the header `x-api-key: zsp_...`. Vercel tests the drain when you create it and expects `200 OK`, which Zespan answers.

**3. Verify**

Send one request through the gateway, then open **Settings → Instrumentation → Gateway and OTLP data** and press **Refresh**. See [Instrumentation](https://docs.zespan.com/dashboard/instrumentation.md#gateway-and-otlp-data).

## What gets captured

| Field | Read from | Notes |
| - | - | - |
| Model, provider, token counts | The root span `<operation> <model>` with current GenAI names | Also reasoning tokens and cache read and creation tokens |
| First-token time | `gen_ai.response.time_to_first_chunk` (seconds) | Stored in milliseconds |
| End user | `vercel.ai_gateway.user.id` | |
| Retries and fallbacks | One span per try: `vercel.ai_gateway.model_attempt <model>` and `<model> (<provider>)` | Stored as `gateway` spans, not counted as model calls. Each keeps its provider, HTTP status and error type |
| Routing | `vercel.ai_gateway.routing` | Stored as a `gateway` span |
| Cost | Zespan's own price table | Vercel's billed figure (`vercel.ai_gateway.cost.total`) is kept as evidence; its list price (`cost.market`) is not used |
| Prompt and answer text | Never sent by Vercel | Nothing to switch off |

> [!NOTE]
>
> Attribute names come from Vercel's published documentation and can change between versions. Use the **Gateway and OTLP data** card to see what actually arrives.

> [!NOTE]
>
> Gateway identity metadata is not stored. See [AI gateways](https://docs.zespan.com/sdk/otel-integration.md#ai-gateways) and [Security](https://docs.zespan.com/platform/security.md).

## Using the SDK too

With both the Zespan SDK and the gateway reporting the same call, Zespan does not merge the two rows: Vercel puts the provider's response id on each attempt span, not on the root span, and does not document an inbound `traceparent`. Set up either the SDK or the drain for a given call, or expect the call to be counted twice. See [Using the SDK too](https://docs.zespan.com/sdk/otel-integration.md#using-the-sdk-too).

## Next steps

* [OTel integration](https://docs.zespan.com/sdk/otel-integration.md), the endpoint, limits and attributes Zespan reads
* [Instrumentation](https://docs.zespan.com/dashboard/instrumentation.md#gateway-and-otlp-data), check what arrived
* [Vercel AI SDK](https://docs.zespan.com/sdk/integrations/vercel-ai.md), tracing from your app instead
* [Cloudflare AI Gateway](https://docs.zespan.com/sdk/integrations/cloudflare-ai-gateway.md), [Portkey](https://docs.zespan.com/sdk/integrations/portkey.md), other gateways


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.