Budget limits for the Vercel AI SDK

Last updated 24 November 2026

Apps built with the AI SDK often call a model for every user, and agents with tools can loop many steps per request. Xpenvo puts a hard dollar limit in front of every call, per agent, per run and per end customer, so one heavy user or one stuck loop cannot run up the bill.

1. Make a budget and a key

Create a free account, make a budget (for example $20 a day) and an agent key for it under Agent keys. The key starts with xpv_ and is shown once. You keep your own provider key and keep paying your provider directly; Xpenvo never stores it.

2. Create the provider with the Xpenvo address

import { createOpenAI } from '@ai-sdk/openai'
import { generateText } from 'ai'

const openai = createOpenAI({
  baseURL: 'https://agents.xpenvo.com/v1',
  headers: { 'X-Xpenvo-Key': process.env.XPENVO_KEY! },
})

const { text } = await generateText({ model: openai('gpt-5-mini'), prompt: 'Hello' })

Your OpenAI key is read from OPENAI_API_KEY as usual. Both the Responses API (the default) and openai.chat(…) work, with streaming. For Claude:

import { createAnthropic } from '@ai-sdk/anthropic'

const anthropic = createAnthropic({
  baseURL: 'https://agents.xpenvo.com/v1',
  headers: { 'X-Xpenvo-Key': process.env.XPENVO_KEY! },
})

3. Limit each of your users

Add X-Xpenvo-Customer with your own user or customer id (never an email address) and set a per-customer limit on the budget, for example $1 a day each. The header can be set per call through the headers option of generateText or streamText. A user who reaches the limit gets a 402 with a clear reason, and every other user keeps working.

Questions

How do I limit AI spending per user in a Vercel AI SDK app?

Create the provider with the Xpenvo Agents base URL and an X-Xpenvo-Key header, send your own user id in X-Xpenvo-Customer, and set a per-customer limit on the budget. Each call is checked before it is sent.

Does streaming still work?

Yes. Streaming calls are checked against the limit before they start and charged by what was actually used.

More: full setup guide · model prices · tested guarantees · security. Questions? [email protected]