---
title: "Give plans priority in the queue"
description: "Decide what each plan gets in the job queue: tiers named for plan features set a head start in minutes, how many jobs an owner runs at once, slots kept for paid plans and a daily credit budget, and a job that waits long enough still beats any newcomer for a shared slot."
canonical_url: "https://nuxt-backend.dev/docs/build/ai/jobs/priority"
---
# Give plans priority in the queue

> Decide what each plan gets in the job queue: tiers named for plan features set a head start in minutes, how many jobs an owner runs at once, slots kept for paid plans and a daily credit budget, and a job that waits long enough still beats any newcomer for a shared slot.

Version: nuxt-backend 0.6.x · Tab: Build · Kind: how-to · Status: experimental

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

- **You get:** paid plans that start sooner, run several jobs side by side, get running room kept for their tier, and pace spend with a daily budget, while free jobs still never wait forever.
- **Powered by:** Convex's scheduler and Workflow component, and the plan features in your [Polar](https://nuxt-backend.dev/docs/services/polar) catalog.
- **The package adds:** tiers named for plan features, each with a head start, a `perOwner` count, dedicated slots and a credit budget; the pick that applies them; and the place in line `useJob` shows.

A job queue decides which job runs next whenever a slot frees up. A slot is one running place: `concurrency` sets how many there are across the app. Tiers decide what each plan gets from them. Four settings live on a tier, and each is optional:

<table>
<thead>
  <tr>
    <th>
      Setting
    </th>
    
    <th>
      What it buys
    </th>
    
    <th>
      Default
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        headStart
      </code>
    </td>
    
    <td>
      A place further up the line, in minutes
    </td>
    
    <td>
      None
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        perOwner
      </code>
    </td>
    
    <td>
      More jobs running at once for one owner
    </td>
    
    <td>
      The top-level <code>
        perOwner
      </code>
      
      , <code>
        1
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        dedicated
      </code>
    </td>
    
    <td>
      Slots that only this tier and the tiers above it may take
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        budget
      </code>
    </td>
    
    <td>
      A cap on the credits of jobs an owner queues per day
    </td>
    
    <td>
      None
    </td>
  </tr>
</tbody>
</table>

With none of them set, every job waits in one line, in the order it joined, one running job per owner.

## How the next job is picked

Whenever a job joins, finishes or is canceled, the queue settings change, and every minute while jobs wait, the queue fills its free slots:

1. **Each waiting job carries its tier and score.** The tier is the better of the one the job joined under and its owner's plan now. When a plan changes, the queue rewrites that owner's waiting jobs ([When a plan changes](#when-a-plan-changes)), so a pick reads only the front of the line.
2. **It skips owners at their limit.** An owner whose running jobs reach the tier's `perOwner` waits until one finishes. The owner is who pays: the active workspace, or the person under `billTo: 'user'`.
3. **It goes by score.** A job's score is the time it joined, minus its tier's head start. The lowest score goes first.
4. **It starts every job a free slot allows,** in score order. A job may not take a slot kept for a better tier. It keeps its place, and the jobs behind it are still tried, so a paid job behind a line of free jobs starts in its own slot.

Head starts compare in minutes, so they never starve anyone:

<table>
<thead>
  <tr>
    <th>
      Job
    </th>
    
    <th>
      Tier
    </th>
    
    <th>
      Joined
    </th>
    
    <th>
      Head start
    </th>
    
    <th>
      Score
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      A
    </td>
    
    <td>
      <code>
        standard
      </code>
    </td>
    
    <td>
      12:00
    </td>
    
    <td>
      none
    </td>
    
    <td>
      12:00
    </td>
  </tr>
  
  <tr>
    <td>
      B
    </td>
    
    <td>
      <code>
        front
      </code>
    </td>
    
    <td>
      12:08
    </td>
    
    <td>
      10 minutes
    </td>
    
    <td>
      11:58
    </td>
  </tr>
  
  <tr>
    <td>
      C
    </td>
    
    <td>
      <code>
        front
      </code>
    </td>
    
    <td>
      12:15
    </td>
    
    <td>
      10 minutes
    </td>
    
    <td>
      12:05
    </td>
  </tr>
</tbody>
</table>

B runs first, then A, then C, with the tiers below. A standard job that has waited more than 10 minutes takes the next shared slot before any job that joins after it, whatever its tier.

## Name the tiers

Tiers live on `defineJobQueue`, each named for a plan feature from your [catalog](https://nuxt-backend.dev/docs/build/billing/catalog). List the best tier first:

```ts [backend/jobs.ts]
import { defineJobQueue } from 'nuxt-backend/ai'
import { DAY, MINUTE } from 'nuxt-backend/rate-limit'
import { components } from './_generated/api'
import { ai } from './ai'

export const jobs = defineJobQueue(components, {
  ai,
  concurrency: 6, // 3 slots kept for paid plans below, 3 shared
  perOwner: 1, // for a tier that sets none
  tiers: {
    front: {
      feature: 'front_of_line',
      headStart: 10 * MINUTE,
      perOwner: 3,
      dedicated: 2,
    },
    priority: {
      feature: 'priority_queue',
      headStart: 4 * MINUTE,
      perOwner: 2,
      dedicated: 1,
      budget: { units: 600, period: DAY },
    },
    standard: {
      budget: { units: 60, period: DAY },
    },
  },
})

export const { getJob, cancelJob, getQueue, listJobs, setQueue, retryJob, discardJob, runQueue, billJob } = jobs.api
```

`tiers` is a `Record<string, Tier>`, and each tier takes:

<field-group>
<field name="feature" type="string">

The plan feature that puts a job in this tier. Leave it out on the last tier, which then catches everyone else.

</field>

<field name="headStart" type="number">

How far up the line the tier's jobs score, in milliseconds. Default `0`. `MINUTE` and `HOUR` come from `nuxt-backend/rate-limit`.

</field>

<field name="perOwner" type="number">

How many jobs one owner of this tier may have running at once. Default: the top-level `perOwner`, which defaults to `1`.

</field>

<field name="dedicated" type="number">

How many of the `concurrency` slots are kept for this tier and the tiers listed above it. Default `0`. Never on the catch-all tier.

</field>

<field name="budget" type="{ units: number, period: number }">

How many credits of jobs one owner may queue per `period`. Default none: the owner's credits are the only cap. Every tier's budget uses the same `period`.

</field>
</field-group>

- **A job takes the first tier, in the order you list them, whose feature the owner's plan has.** The plan comes from the entitlement cache. A plan that grants two queue features gets the first-listed tier, so give each plan one.
- **A tier without a feature** catches everyone else, and must come last. Without one, an owner who matches no tier gets the top-level `perOwner`, no head start, no dedicated slots and no budget, and ranks below every tier. Guest jobs rank there too ([Let a visitor try once](https://nuxt-backend.dev/docs/build/ai/jobs/guests)).
- **defineJobQueue throws at push** when a rule breaks: the catch-all tier is not last or sets `dedicated`, `perOwner` is not a whole number of 1 or more, the `dedicated` counts leave no shared slot, or two budgets use different periods.

Grant the features on the plans that include them, and the [pricing page](https://nuxt-backend.dev/docs/build/billing/pricing-page) lists them:

```ts [backend/billing.catalog.ts]
import { defineBillingCatalog } from 'nuxt-backend/billing'

export default defineBillingCatalog({
  meters: { credits: {} },
  plans: {
    free: {
      name: 'Free',
      prices: { month: 0 },
      credits: { meter: 'credits', units: 20 },
    },
    pro: {
      name: 'Pro',
      prices: { month: 1200, year: 12000 },
      credits: { meter: 'credits', units: 300 },
      features: ['priority_queue'],
    },
    studio: {
      name: 'Studio',
      prices: { month: 2900, year: 29000 },
      credits: { meter: 'credits', units: 1500 },
      features: ['front_of_line'],
    },
  },
  features: {
    priority_queue: { description: 'Your strips start up to 4 minutes sooner, draw side by side, and get running room set aside for Pro' },
    front_of_line: { description: 'Your strips start up to 10 minutes sooner, draw side by side, and get running room set aside for Studio' },
  },
})
```

Run `npx nuxt-backend billing sync` to push them, as for any feature ([Feature gating](https://nuxt-backend.dev/docs/build/billing/subscriptions/feature-gating)). The Queue tab can retune `perOwner`, `dedicated` and a budget's units without a deploy, so keep those numbers out of the descriptions, or run `billing sync` again after a retune.

## Run more than one job per owner

`perOwner` on a tier lets each of its owners run that many jobs at once. Above, a Studio workspace draws three strips side by side, a Pro workspace two, and everyone else one. Raise it where an owner's jobs are independent, and keep it at `1` on plans where one account's burst could fill the shared slots.

- **It counts running jobs only.** An owner may have any number waiting, and an extra job is never refused: it waits, and `useJob` says why ([Show the place in line](#show-the-place-in-line)).
- **It counts every running job of the owner,** across kinds and tiers, against the limit of the job about to start.
- **The owner is the billing entity,** fixed when the job joins. A guest job claimed at sign-up stays a guest job in the queue ([When a plan changes](#when-a-plan-changes)). Two members of one workspace share its count. One person in two workspaces gets each workspace's count. A kind billed with `billTo: 'user'` counts against the person, apart from their workspace.
- **A slot is always released.** The count drops when a job ends, fails or is canceled, and the stall sweep frees the slot of a job that went silent.

## Keep slots for paid plans

`dedicated` keeps running room for a tier, also called reserved slots. A dedicated slot is taken from `concurrency`, never added to it. It is kept for its tier and every tier listed above it, so a better plan is never worse off than a cheaper one. Worse tiers, the catch-all tier and guests never take one. The rest are shared, and anyone may take a shared slot.

With `concurrency: 6` and the tiers above:

<table>
<thead>
  <tr>
    <th>
      Slots
    </th>
    
    <th>
      How many
    </th>
    
    <th>
      Who may take them
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Kept for <code>
        front
      </code>
    </td>
    
    <td>
      2
    </td>
    
    <td>
      <code>
        front
      </code>
      
       jobs
    </td>
  </tr>
  
  <tr>
    <td>
      Kept for <code>
        priority
      </code>
    </td>
    
    <td>
      1
    </td>
    
    <td>
      <code>
        priority
      </code>
      
       and <code>
        front
      </code>
      
       jobs
    </td>
  </tr>
  
  <tr>
    <td>
      Shared
    </td>
    
    <td>
      3
    </td>
    
    <td>
      Every job, guests included
    </td>
  </tr>
</tbody>
</table>

A job takes the narrowest slot it may use: its own tier's, then a worse paid tier's, then a shared one. A job may start only while the free slots left after it still cover every slot kept for a better tier and not in use. Here is a busy afternoon, with every shared slot taken by a free job and 30 more waiting:

<table>
<thead>
  <tr>
    <th>
      Time
    </th>
    
    <th>
      What happens
    </th>
    
    <th>
      The slot it takes
    </th>
    
    <th>
      Free jobs
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      12:00
    </td>
    
    <td>
      Three <code>
        standard
      </code>
      
       jobs start
    </td>
    
    <td>
      Shared, all three
    </td>
    
    <td>
      30 wait, the oldest joined 12:01
    </td>
  </tr>
  
  <tr>
    <td>
      12:20
    </td>
    
    <td>
      A Studio strip joins
    </td>
    
    <td>
      Kept for <code>
        front
      </code>
      
      : starts at once
    </td>
    
    <td>
      Their places do not change
    </td>
  </tr>
  
  <tr>
    <td>
      12:21
    </td>
    
    <td>
      A Pro strip joins
    </td>
    
    <td>
      Kept for <code>
        priority
      </code>
      
      : starts at once
    </td>
    
    <td>
      Their places do not change
    </td>
  </tr>
  
  <tr>
    <td>
      12:22
    </td>
    
    <td>
      Another Pro workspace's strip joins, score 12:18
    </td>
    
    <td>
      None it may take: it waits
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      12:25
    </td>
    
    <td>
      A <code>
        standard
      </code>
      
       job ends
    </td>
    
    <td>
      Shared: the free job that joined 12:01 starts, as its score is lower
    </td>
    
    <td>
      29 wait
    </td>
  </tr>
</tbody>
</table>

- **Idle dedicated slots stay idle.** They are not lent to worse tiers, because the queue never preempts a running job, and some generations, such as video, keep costing after the request is canceled (Convex AI Gateway, checked on 2026-10-27). A lent slot would block the next paid job for a whole job's length.
- **A paid tier can take a worse paid tier's slot.** A Studio strip may use Pro's slot when Studio's are full, and the next Pro strip then waits for a shared slot or for Pro's. A free job never takes a paid slot.
- **A dedicated slot is a pool, not a seat.** Every owner of its tier and the tiers above it shares it: 50 Pro workspaces share Pro's one slot. One owner above can fill it too: above, a Studio workspace drawing three strips takes Studio's two slots and Pro's one. For a paid tier never to be squeezed out by a single owner above it, keep its slots and those of the tiers above it at least one more than the biggest `perOwner` above it. Trimming takes the worst paid tier's slots first, so promise running room in plan copy, never a slot of one's own.
- **Head starts and dedicated slots work together.** The head start orders the line, for the shared slots and inside a tier's own. The dedicated slots guarantee running room. A tier may use either alone.
- **A dedicated slot is a running place, not model throughput.** Every job shares each model's calls ([Keep models under their limits](https://nuxt-backend.dev/docs/build/ai/jobs/model-limits)). When a model is the bottleneck, lower `concurrency` or route the paid kind to its own model.

At least one slot always stays shared. `defineJobQueue` refuses `dedicated` counts that add up to `concurrency`. When an administrator lowers `concurrency` below what the counts need, the queue trims them from the worst-listed paid tier up until one shared slot remains. Raising it back restores them ([Operate the queue](https://nuxt-backend.dev/docs/build/ai/jobs/operate#change-how-many-jobs-run)).

## Cap what an owner spends per day

`budget` caps the credits of jobs an owner queues per window. Above, a free workspace queues 60 credits of strips a day, a Pro workspace 600, and a Studio workspace as many as its credits cover. Credits still cap the total. The budget paces spend from one window to the next: it matters for owners with plenty of credits, such as big plans and packs, and for kinds the app pays for.

- **It counts a job's cost,** the same number its credits hold, once, when the job joins. A `meter: false` kind moves no credits, but its `cost`, `1` by default, still counts here, so jobs the app pays for can be capped too. Guest jobs count nothing.
- **There is one window per owner,** shared by every tier and kind. An upgrade raises the allowance at once and keeps what was used. A job counts in the window it joined, even when it starts after midnight.
- **Windows align to the clock.** `period: DAY` resets at 00:00 UTC, and `HOUR` on the hour, the same instants a gateway's daily limit resets.
- **It is checked at the door, never at start.** `jobs.enqueue` counts the job in the same transaction that holds its credits. Two members who enqueue at once can never overshoot it, and an admitted job is never refused later.

### What gives budget back

The budget follows the credits. A job's cost goes back to the window it counted in when its hold is released or its credits are refunded:

<table>
<thead>
  <tr>
    <th>
      The job
    </th>
    
    <th>
      Its credits
    </th>
    
    <th>
      Its budget
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Is canceled before it starts
    </td>
    
    <td>
      Released
    </td>
    
    <td>
      Given back
    </td>
  </tr>
  
  <tr>
    <td>
      Fails, stalls or finds its model unavailable
    </td>
    
    <td>
      Refunded
    </td>
    
    <td>
      Given back
    </td>
  </tr>
  
  <tr>
    <td>
      Is canceled by an administrator with a refund
    </td>
    
    <td>
      Refunded
    </td>
    
    <td>
      Given back
    </td>
  </tr>
  
  <tr>
    <td>
      Finishes, or is canceled while it runs
    </td>
    
    <td>
      Stay charged
    </td>
    
    <td>
      Stays counted
    </td>
  </tr>
</tbody>
</table>

A job that joined at 23:58 UTC and fails at 00:03 is refunded, and its cost goes back to yesterday's window, which has ended: the new day gains nothing. An administrator's retry of a dead letter counts in the owner's current window, but the budget never refuses it.

This budget covers queued jobs only. `setupAi({ budget })` ([Cap spend per window](https://nuxt-backend.dev/docs/build/ai/models#cap-spend-per-window)) keeps covering metered actions and chat, and never counts a job. Jobs still share the `ai` call limit. To cap an owner across both kinds of spend, set both.

### The refusals

An owner over the budget is refused at the door with `rate_limited`, before any credit is held. `data.limit` is `'jobBudget'`, `retryAfter` is the time until the window resets, and `plans` lists the plans on sale whose tier would fit this job now, in pricing order. A release or a refund can free room sooner.

A job bigger than the owner's whole budget could never fit, so waiting cannot help. The refusal then says what can:

- **feature_required** when a tier on sale fits it: `feature` belongs to the smallest upgrade that does, and `plans` lists the plans that grant it. A 20-panel strip at 100 credits gets this on the free plan.
- **invalid_input**, with `field: 'cost'` and reason `over_budget`, when no tier fits it. `need` and `units` carry both numbers.

```vue [app/pages/strips/new.vue]
<script setup lang="ts">
import { api } from '#backend/api'

const create = useMutation(api.strips.create)
const idea = ref('')
const refusal = ref<BackendError | null>(null)

async function start() {
  refusal.value = null
  try {
    const stripId = await create({ idea: idea.value, panels: 6 })
    await navigateTo(`/strips/${stripId}`)
  }
  catch (error) {
    refusal.value = getBackendError(error)
    if (refusal.value?.code === 'insufficient_credits') await navigateTo('/pricing')
  }
}
</script>

<template>
  <input v-model="idea" placeholder="A fox who wants to fly">
  <button @click="start">
    Draw the strip
  </button>
  <template v-if="refusal?.code === 'rate_limited' && refusal.data.limit === 'jobBudget'">
    <p role="alert">
      {{ refusal.message }}
    </p>
    <UpgradePrompt v-if="refusal.data.plans?.length" :plans="refusal.data.plans" />
  </template>
  <UpgradePrompt v-else-if="refusal?.code === 'feature_required'" :plans="refusal.data.plans" />
  <p v-else-if="refusal" role="alert">
    {{ refusal.message }}
  </p>
</template>
```

The message reads "Resets in…" with the time left. Show the reset in the person's local time, not as "tomorrow": 00:00 UTC is the afternoon before in California. [Start a job](https://nuxt-backend.dev/docs/build/ai/jobs#start-a-job) lists every check `enqueue` makes, in order.

## When a plan changes

A waiting job uses the better of the tier it joined under and its owner's tier now. When the billing webhook refreshes an owner's plan, the queue rewrites the tier and score of that owner's waiting jobs, so the change applies at the next pick:

- **An upgrade helps the jobs already waiting.** Their score takes the new head start, and they get the new `perOwner` and the new dedicated slots. Their places drop. Nothing is counted against the budget again, and the next job checks the new tier's units against the same window.
- **A downgrade never worsens a waiting or running job.** It joined, and holds its credits, under the old plan. A new job joins the current tier: it is checked against the current units, with everything already counted that day, and starts under the current `perOwner`.
- **Running jobs are never touched.** A deploy that removes a tier moves its waiting jobs to their owner's current tier at the next pick.
- **A guest job claimed at sign-up still runs as a guest.** It keeps guest rank and its visitor's count until it starts, and never counts against the new workspace's `perOwner` or budget. So the first paid strip starts on its own tier, never behind the free guest strip.

Reverse trials and card-free plan passes grant features, so a Studio pass gets Studio's tier. To keep trials out of paid slots, give the trial plan a feature that maps to a tier without `dedicated`.

A downgrade keeps what a waiting job joined with, so only that bounds an ex-subscriber's waiting jobs: the credits they hold and the budget they counted against. A `meter: false` kind holds no credits. On a tier without a budget, such as `front` above, nothing bounds it: a pass holder could queue thousands of app-paid jobs that keep the paid tier's treatment after the pass ends. If you have app-paid kinds, give every tier a budget, the top one included.

## Why nobody waits forever

Dedicated slots change what a free job competes for, not whether it starts:

- **At least one slot is always shared,** at any `concurrency` of 1 or more.
- **Among jobs that need a shared slot, the lowest score goes first.** A job that has waited longer than the biggest head start starts before any job that joins after it and needs a shared slot.
- **A job that starts in a dedicated slot never uses a shared one,** so it never delays a free job.

A free job's wait is bounded as before, over the shared slots instead of every slot. Dedicated slots sit idle when their tiers have nothing waiting, so give them only the room a paid plan needs.

## Show the place in line

`useJob(jobId)` gives three fields for a waiting job:

- **waitingOn** says what holds it: `'line'` while it waits for a slot it may use, `'owner'` while its owner is at the tier's `perOwner`, and `'paused'` while the queue is paused, at `concurrency` `0`, or under `pause_ai`.
- **position** is about how many jobs start before this one, plus one: `1` starts next. The queue works it out by running its pick ahead: each running job is expected to end the average length of recent jobs after it started, the earliest frees its slot and its owner's count first, and the pick runs after each. A job held by its owner's `perOwner` counts once its owner may start it. So a Studio strip with a free dedicated slot reads `1` behind 40 free jobs, and a free job does not count the paid jobs that take dedicated slots. Only the first 100 starts are worked out: past them it reads `null`, so say "100+". It also reads `null` while `waitingOn` is `'owner'` or `'paused'`.
- **estimatedWait** is how long until the same run of the pick starts this job, in milliseconds. While `'owner'`, it counts the owner's other jobs ahead of this one too, waiting or running. It is `undefined` while paused and before any job has finished. Show it rounded or as a range: it never knows the gateway's capacity.

```vue [app/pages/strips/[id].vue]
<script setup lang="ts">
import { api } from '#backend/api'

const route = useRoute()
const strip = useQuery(api.strips.get, () => ({ id: route.params.id as string }))
const job = useJob(() => strip.value?.jobId)
</script>

<template>
  <p v-if="job.waitingOn.value === 'owner'">
    Starts after your other strips
  </p>
  <p v-else-if="job.waitingOn.value === 'paused'">
    The queue is paused
  </p>
  <p v-else-if="job.waitingOn.value === 'line'">
    Number {{ job.position.value ?? '100+' }} in line
  </p>
</template>
```

`position` can move back: when a newcomer's head start outweighs the gap, when an upgraded owner's jobs move ahead, or when a job held by its owner's limit becomes free to start.

## Why the package does this, not the gateway

The caps live in the queue, keyed by owner, because neither gateway can hold them. Neither documents a limit per app user or workspace. A gateway limit stops every owner at once. Its caps are soft, and it knows a call's dollars only after the call. Neither publishes a capacity to divide, so `concurrency` and `dedicated` are your settings. [AI gateway](https://nuxt-backend.dev/docs/services/ai-gateway#per-user-limits-and-gateway-wide-stops) has the facts, checked on 2026-10-27.

The gateway's own limit stays as a backstop. The tier budgets do not bound what the gateway spends in a calendar day:

- **Each budget is per owner,** a tier without one is bounded by credits alone, and guest jobs count nothing.
- **A job counts in the window it joined,** so jobs queued just before 00:00 UTC run in the gateway's next day. One owner can queue a whole day's units at 23:59 and another at 00:00.

Size the gateway's daily dollar limit, `aiGatewayCostDollars` on Convex or a `daily` budget on Vercel, from your peak daily spend with headroom, and set a warning threshold below it ([Cap what the gateway spends](https://nuxt-backend.dev/docs/build/ai/models#cap-what-the-gateway-spends)). Polar's Costs dashboard shows that spend per job ([Report what each job cost you](https://nuxt-backend.dev/docs/build/ai/jobs/credits#report-what-each-job-cost-you)). A Convex disable threshold stops the whole deployment, so it must never be the first limit you reach.

- **Throttling upstream is never the owner's rate_limited.** A `429`, a `502`, a `503` or a timeout inside a running job is retried in its slot. Nothing is counted against the budget or held again. After the last attempt the job fails as `unavailable`, its credits are refunded and its budget is given back.
- **A Vercel budget's 402 fails the step at once.** The queue knows it by status `402` or error type `quota_for_entity_exceeded`, whatever error class the AI SDK wraps it in, and never retries it. The step fails as `unavailable`, reason `provider_refused`, and the job is refunded and its budget given back.
- **A Convex usage or spending limit stops the deployment, not a step.** Nothing runs, the queue included, until the window rolls over or the limit is raised. When the deployment comes back, the stall sweep fails the jobs that were running, refunds them and gives their budget back. Only a local deployment that asks for a token gets an error for it, `SpendingLimitExceeded` or `TeamSuspended`, which fails the step as `unavailable` `provider_refused`.
- **A Convex gateway the deployment cannot use gives not_configured,** when no `AI_GATEWAY_API_KEY` is set to fall back to: `AiGatewayDisabled` on a free plan or a team with the gateway turned off, `AiGatewayUnavailable` on an anonymous local or a self-hosted deployment ([Where a model id goes](https://nuxt-backend.dev/docs/build/ai/models#where-a-model-id-goes)).
- **The package never pauses itself:** you pause the queue.

## Related

- [Run generation jobs](https://nuxt-backend.dev/docs/build/ai/jobs): define a job, start it and follow it.
- [Operate the queue](https://nuxt-backend.dev/docs/build/ai/jobs/operate): change the concurrency and the tiers without a deploy.
- [Charge for a queued job](https://nuxt-backend.dev/docs/build/ai/jobs/credits): the hold the budget follows.
- [Feature gating](https://nuxt-backend.dev/docs/build/billing/subscriptions/feature-gating): plan features, and checking them in your own functions.
- [AI gateway](https://nuxt-backend.dev/docs/services/ai-gateway): the gateway's own spending caps.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
