---
title: "Operate the queue"
description: "Run the job queue from the admin console's Queue tab: see what runs and waits, pause the queue, change how many jobs run at once, retune a tier or a model's limit, and cancel a job, each change on the activity trail."
canonical_url: "https://nuxt-backend.dev/docs/build/ai/jobs/operate"
---
# Operate the queue

> Run the job queue from the admin console's Queue tab: see what runs and waits, pause the queue, change how many jobs run at once, retune a tier or a model's limit, and cancel a job, each change on the activity trail.

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:** the queue in production at a glance, and the controls to pause it, resize it, retune a tier or a model, cancel a job, and retry or discard the jobs that failed.
- **Powered by:** the admin console and the activity trail, over the queue's own tables in your deployment.
- **The package adds:** the Queue tab, its dead-letter view, the functions behind it, and a recent-sign-in check on every change.

The admin console gets a **Queue** tab once your app defines a job queue, at `/admin?tab=queue`. From it an administrator sees what runs and what waits, and changes how the queue behaves without a deploy: pause it, set how many jobs run at once, retune a tier or a model's limit, or cancel one job. Each change asks for a recent sign-in and is recorded on the activity trail, like every other admin action.

## What the tab shows

<table>
<thead>
  <tr>
    <th>
      Part
    </th>
    
    <th>
      What it shows
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      The queue
    </td>
    
    <td>
      Jobs running and waiting, the guest jobs among them once the queue takes guests, the concurrency, the shared slots, the average job's length over the last jobs, and whether the queue is paused
    </td>
  </tr>
  
  <tr>
    <td>
      Tiers
    </td>
    
    <td>
      Each tier's feature, head start, <code>
        perOwner
      </code>
      
      , dedicated slots (configured and in effect), budget per period, and its jobs running and waiting
    </td>
  </tr>
  
  <tr>
    <td>
      Models
    </td>
    
    <td>
      Each model's rate in calls a minute, its <code>
        min
      </code>
      
       and <code>
        max
      </code>
      
      , its <code>
        429
      </code>
      
       count and when the last one came back
    </td>
  </tr>
  
  <tr>
    <td>
      Jobs
    </td>
    
    <td>
      The newest jobs first: kind, owner, tier (the better of the one it joined under and its owner's now), status, attempts, when it joined and started, and the last error
    </td>
  </tr>
</tbody>
</table>

A job's last error here is the provider's own text, cut to 500 characters, so you can tell a throttled model from a bad prompt. The person who started the job only ever sees the catalog error ([What happens to a job](https://nuxt-backend.dev/docs/build/ai/jobs#what-happens-to-a-job)).

## Pause the queue

**Pause** stops the queue from starting jobs. Jobs that run go on to the end, and new jobs still join the line, with their credits held. **Resume** starts the waiting jobs again, in order.

Pause the queue to hold jobs through a provider outage or a deploy you are unsure of. To stop every model call in the app at once, metered actions and chat included, turn on `pause_ai` instead ([Pause AI](https://nuxt-backend.dev/docs/build/ai/models#pause-ai)). While it is on, new jobs are refused at the door, and queued jobs wait as they do under a paused queue.

## Change how many jobs run

**Concurrency** sets how many jobs run at once across the app, from `0` to `20`. The queue starts waiting jobs as soon as you raise it, and lets running jobs finish when you lower it. `0` works like a pause that still shows as running.

The dedicated slots come out of this number ([Keep slots for paid plans](https://nuxt-backend.dev/docs/build/ai/jobs/priority#keep-slots-for-paid-plans)), and at least one slot always stays shared. Lower it below what the tiers' `dedicated` counts need, and the queue trims them, from the worst-listed paid tier up, until one shared slot remains. The Tiers table then shows both numbers, such as "2 (1 in effect)", and the tab warns. Raise it again, and the configured counts come back. Lowering never stops a running job: new jobs wait until the counts fit.

Raise it when jobs wait long and your models have room. The [model limits](https://nuxt-backend.dev/docs/build/ai/jobs/model-limits) keep a model under its provider's limit whatever the concurrency, so a higher one never causes `429`s by itself, but it does let more jobs share each model's calls.

## Retune a tier

Each tier's row takes a new `perOwner`, `dedicated` count and budget units, and wins over `backend/jobs.ts` until you set it back:

- **perOwner** is a whole number of 1 or more. It applies at the next pick.
- **dedicated** is a whole number of 0 or more, never on the catch-all tier. A count too large for the concurrency is trimmed, not refused. It applies at the next pick.
- **Budget units** must be above 0, on a tier whose code declares a budget. The change applies to the current window at once and keeps what was used.

Tighten a free tier's budget during a cost spike, without a deploy and before the gateway's own limit stops the whole deployment. An owner already past the new units is refused until the window resets, and the jobs already queued still run. The period, the feature, the head start and the list of tiers stay in code. The plan feature descriptions you synced to the billing provider do not change with a retune.

## Retune a model

Each model's row takes a new rate, `min` and `max`. The queue keeps adapting from the values you set. Retune a model when its provider raises your limit, or when its rate sits at `min` and jobs crawl.

## Cancel a job

**Cancel** on a job's row works as the person's own cancel does: a waiting job leaves the line, its hold is released and its cost goes back to the owner's budget window, and a running job stops after its current step and stays charged. **Cancel and refund** also gives a running job's credits and budget back, for a job that went wrong on your side. The activity trail records who canceled it, and whether it was refunded.

## Dead letters

A job that failed after its last attempt, stalled, or threw from your code lands in the tab's **Dead letters** view, with its kind, owner, attempts and last error. Its credits were already refunded. For each one an administrator can:

- **Retry** it: the job joins the line again under its owner, with the same arguments and a new hold on their credits. It counts in the owner's current budget window, which never refuses an administrator's retry. A retry is refused with `insufficient_credits` when the owner can no longer afford it, and it runs the steps that had not finished: those that had are saved.
- **Discard** it: the job leaves the view for good, and its rows stay as your code left them.

Fix the cause first: a model whose limit sits at `min`, a prompt your step rejects, a provider outage. Dead letters are kept for 30 days, then pruned with the job.

## From your own code

The same reads and changes are functions the scaffold exports from `backend/jobs.ts`, for the app-wide admin role:

<table>
<thead>
  <tr>
    <th>
      Function
    </th>
    
    <th>
      What it does
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        getQueue
      </code>
    </td>
    
    <td>
      The queue's state and each model's limit
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        listJobs
      </code>
    </td>
    
    <td>
      The jobs, newest first, paginated
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        setQueue
      </code>
    </td>
    
    <td>
      Pause or resume, set the concurrency, retune a tier, or retune a model: <code>
        { paused?, concurrency?, tier?: { name, perOwner?, dedicated?, budget?: { units } }, model?: { id, perMinute?, min?, max? } }
      </code>
      
      . <code>
        null
      </code>
      
       on a tier's field sets it back to <code>
        backend/jobs.ts
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        cancelJob
      </code>
    </td>
    
    <td>
      Cancel a job: the person who started it may, and so may the workspace's owners and admins. An app admin may also pass <code>
        { refund: true }
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        retryJob
      </code>
    </td>
    
    <td>
      Put a dead letter back in line, holding its credits again
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        discardJob
      </code>
    </td>
    
    <td>
      Remove a dead letter for good
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        runQueue
      </code>
    </td>
    
    <td>
      Internal: the pick, the stall sweep, a job's progress and each job's end. The queue schedules it by this name
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        billJob
      </code>
    </td>
    
    <td>
      Internal: a job's charge, its refund and its cost report. The queue schedules it by this name
    </td>
  </tr>
</tbody>
</table>

`setQueue` takes a recent sign-in, as the tab's changes do ([Ask for a recent sign-in](https://nuxt-backend.dev/docs/build/auth/access/step-up)). A tier value it cannot take refuses with `invalid_input`, whose `field` is `perOwner`, `dedicated` or `budget`:

```ts [app/composables/useQueueTiers.ts]
import { api } from '#backend/api'

export function useQueueTiers() {
  const setQueue = useMutation(api.jobs.setQueue)
  return {
    // Free days during a cost spike: 30 credits instead of 60.
    tighten: () => setQueue({ tier: { name: 'standard', budget: { units: 30 } } }),
    // Back to what backend/jobs.ts says.
    reset: () => setQueue({ tier: { name: 'standard', budget: null } }),
  }
}
```

## See what jobs cost

The **Costs** tab beside the Queue tab shows what each person's AI calls cost over the last 7, 30 or 90 days, the jobs' model calls among them, once `backend/ai.ts` re-exports `getCosts` from `ai.api`. When the day's spend jumps past the week before, the backend raises an alert ([AI cost per person](https://nuxt-backend.dev/docs/ship/operate/monitoring#ai-cost-per-person), [Alerts](https://nuxt-backend.dev/docs/ship/operate/monitoring#alerts)).

## Related

- [Admin console](https://nuxt-backend.dev/docs/build/auth/admin): the console the tab lives in, and who can open it.
- [Keep models under their limits](https://nuxt-backend.dev/docs/build/ai/jobs/model-limits): what a model's rate means.
- [Record and review activity](https://nuxt-backend.dev/docs/build/auth/admin/audit-log): the trail each change lands on.
- [Roll out features and pause services](https://nuxt-backend.dev/docs/ship/operate/flags): `pause_ai` beside the other switches.


## Sitemap

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