---
title: "nuxt-backend/ai"
description: "Every export of nuxt-backend/ai, with its signature and where it is defined."
canonical_url: "https://nuxt-backend.dev/docs/reference/api/ai"
---
# nuxt-backend/ai

Version: nuxt-backend 0.6.x · Tab: Reference · Kind: reference · Status: stable

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.

**Experimental**

The rails for selling metered AI features — `nuxt-backend/ai`: wrap any
Convex action so it is rate-limited, prepaid-credit-metered (reserve → run →
settle — a failed run consumes nothing), and optionally token-streamed to
the browser with the text persisted server-side (reload mid-stream and it
continues).

Models are named as `provider/model` ids and called through the AI SDK (an
optional peer: install `ai` to call one), each call charged at the cost
the gateway reports. An id goes through the gateways `setupAi({ gateway })`
names, in order: by default the Convex AI Gateway first, on Convex Cloud
with a paid plan (install `@convex-dev/ai-sdk-provider`), then the Vercel
AI Gateway with `AI_GATEWAY_API_KEY`. When none answers, a call is refused,
saying why.

Composes the billing spend reservation (`setupBilling`), the rate limiter,
and the upstream persistent-text-streaming component — usage recording IS
the provider event, so per-customer usage shows up in the provider's own
portal and dashboard with no extra tables here.

Experimental: the metering model (reserve/settle over provider meter
events) is the newest part of the package and may change shape in a minor
release; `useAiStream` on the Vue side is experimental with it.

## Interfaces

### ChatThread

Defined in: [src/convex/integrations/ai/chat.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts)

**Experimental**

One thread in a person's list.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="title">
        
      </a>
      
       <code>
        title
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The start of its first message.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="updatedat">
        
      </a>
      
       <code>
        updatedAt
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       When a message was last sent or answered in it, in ms.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ChatMessage

Defined in: [src/convex/integrations/ai/chat.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts)

**Experimental**

One message of a thread.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id-1">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="role">
        
      </a>
      
       <code>
        role
      </code>
    </td>
    
    <td>
      <code>
        "user"
      </code>
      
       | <code>
        "assistant"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="text">
        
      </a>
      
       <code>
        text
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="status">
        
      </a>
      
       <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        "failed"
      </code>
      
       | <code>
        "done"
      </code>
      
       | <code>
        "streaming"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       <code>
        streaming
      </code>
      
       while the reply is written, <code>
        failed
      </code>
      
       when it could not be (nothing was charged), else <code>
        done
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ChatReply

Defined in: [src/convex/integrations/ai/chat.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts)

**Experimental**

What a reply is, as a finalized cost reads it.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="text-1">
        
      </a>
      
       <code>
        text
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The reply's text.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ChatConfig

Defined in: [src/convex/integrations/ai/chat.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts)

**Experimental**

What `ai.chat` takes.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="name">
        
      </a>
      
       <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The chat's name, unique per app; each reply's usage event records it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="model">
        
      </a>
      
       <code>
        model?
      </code>
    </td>
    
    <td>
      <code>
        LanguageModel
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The model that replies; defaults to <code>
        setupAi
      </code>
      
      's.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="instructions">
        
      </a>
      
       <code>
        instructions?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The system prompt every reply starts from.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meter">
        
      </a>
      
       <code>
        meter?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        false
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The credit meter each reply is charged to. Required for a chat the billing entity pays for; a chat the app pays for (<code>
        billTo: 'app'
      </code>
      
      ) charges no one.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cost">
        
      </a>
      
       <code>
        cost?
      </code>
    </td>
    
    <td>
      <a href="#meteredcost">
        <code>
          MeteredCost
        </code>
      </a>
      
      <<code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <a href="#chatreply">
        <code>
          ChatReply
        </code>
      </a>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       What a reply costs, as on a metered action. Default <code>
        1
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="limit">
        
      </a>
      
       <code>
        limit?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        false
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The named rate limit a reply counts against. Default <code>
        'ai'
      </code>
      
      ; <code>
        false
      </code>
      
       disables it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="allowoverage">
        
      </a>
      
       <code>
        allowOverage?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Let a reply take the balance negative (pay-as-you-go meters).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="maxoutputtokens">
        
      </a>
      
       <code>
        maxOutputTokens?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The longest reply, in tokens. Default <code>
        1000
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="knowledge">
        
      </a>
      
       <code>
        knowledge?
      </code>
    </td>
    
    <td>
      <a href="#knowledge-2">
        <code>
          Knowledge
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A knowledge store each reply searches first, putting the closest passages in the model's context.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="billto">
        
      </a>
      
       <code>
        billTo?
      </code>
    </td>
    
    <td>
      <code>
        "app"
      </code>
      
       | <code>
        "entity"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Who pays for a reply: the billing entity (the default), or the app itself, which needs setupAi's <code>
        rateLimiter
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="moderate">
        
      </a>
      
       <code>
        moderate?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Check each message with the safety classifier (<code>
        setupAi({ moderation })
      </code>
      
      ) in the reply's action, before the model: a flagged message gets no reply, its reservation is released, and it is hidden from the thread and from later replies' context.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### Chat

Defined in: [src/convex/integrations/ai/chat.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts)

**Experimental**

The functions `ai.chat` returns: export each from the chat's module, by these names.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="threads">
        
      </a>
      
       <code>
        threads
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        Promise
      </code>
      
      <<a href="#chatthread">
        <code>
          ChatThread
        </code>
      </a>
      
      <span>
        
      </span>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The caller's threads in the active workspace, newest first.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="messages">
        
      </a>
      
       <code>
        messages
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        threadId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        paginationOpts
      </code>
      
      : { <code>
        numItems
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        cursor
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; }; }, <code>
        Promise
      </code>
      
      <{ <code>
        page
      </code>
      
      : <a href="#chatmessage">
        <code>
          ChatMessage
        </code>
      </a>
      
      <span>
        
      </span>
      
      ; <code>
        isDone
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        continueCursor
      </code>
      
      : <code>
        string
      </code>
      
      ; }>>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       One thread's messages, newest first, paginated, with the reply being written.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="send">
        
      </a>
      
       <code>
        send
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        text
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        threadId?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        string
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Save a message, in a new thread or an existing one, start the reply, and return the thread's id.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="remove">
        
      </a>
      
       <code>
        remove
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        threadId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Delete one of the caller's threads, with its messages.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="reply">
        
      </a>
      
       <code>
        reply
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "internal"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      >, <code>
        Promise
      </code>
      
      <<code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The reply, in a scheduled action: <code>
        send
      </code>
      
       schedules it by this name, next to itself. Internal.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/chat.ts" rel="nofollow">
        src/convex/integrations/ai/chat.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AiRateLimiter

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

The rate limiter shape `setupAi` consumes — satisfied by a
`setupRateLimiter(...)` instance, which seeds the `ai` and `aiBudget` limits
by default. Typed against the literal default names (the limiter's
conditional rest-tuple signature only resolves for known names — the same
pattern as `BillingRateLimiter`); custom `limit:` names pass through a cast
at the call site.

#### Methods

##### limit()

```ts
limit(
   ctx, 
   name, 
   options?
): Promise<{
  ok: boolean;
  retryAfter?: number;
}>;
```

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

###### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        ctx
      </code>
    </td>
    
    <td>
      <code>
        RunWriteCtx
      </code>
      
       & { <code>
        auth?
      </code>
      
      : <code>
        Auth
      </code>
      
      ; }
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        "ai"
      </code>
      
       | <code>
        "aiBudget"
      </code>
      
       | <code>
        "aiGlobal"
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      { <code>
        key?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        throws?
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        count?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        config?
      </code>
      
      : <a href="https://nuxt-backend.dev/docs/reference/api/rate-limit#ratelimitconfig">
        <code>
          RateLimitConfig
        </code>
      </a>
      
      ; }
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options.key?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options.throws?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options.count?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options.config?
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/rate-limit#ratelimitconfig">
        <code>
          RateLimitConfig
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

###### Returns

`Promise`<{
`ok`: `boolean`;
`retryAfter?`: `number`;
}>

##### credit()?

```ts
credit?(
   ctx, 
   name, 
   options?
): Promise<void>;
```

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

Give tokens back to a limit, up to its capacity: how a budget gets back
what a run did not spend. A limiter of your own without it keeps
everything a run counted.

###### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        ctx
      </code>
    </td>
    
    <td>
      <code>
        RunWriteCtx
      </code>
      
       & { <code>
        auth?
      </code>
      
      : <code>
        Auth
      </code>
      
      ; }
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        "aiBudget"
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      { <code>
        key?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        count?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        config?
      </code>
      
      : <a href="https://nuxt-backend.dev/docs/reference/api/rate-limit#ratelimitconfig">
        <code>
          RateLimitConfig
        </code>
      </a>
      
      ; }
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options.key?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options.count?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options.config?
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/rate-limit#ratelimitconfig">
        <code>
          RateLimitConfig
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

###### Returns

`Promise`<`void`>

---

### AiComponents

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

The component handles `setupAi` reads from your generated `components` object.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="backend">
        
      </a>
      
       <code>
        backend
      </code>
    </td>
    
    <td>
      { <code>
        ai
      </code>
      
      : { <code>
        createRequest
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        name
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        args
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        cost
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        getByStream
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, | { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        name
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        args
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        cost
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        status
      </code>
      
      : <code>
        "reserved"
      </code>
      
       | <code>
        "released"
      </code>
      
       | <code>
        "streaming"
      </code>
      
       | <code>
        "settled"
      </code>
      
      ; <code>
        createdAt
      </code>
      
      : <code>
        number
      </code>
      
      ; } | <code>
        null
      </code>
      
      >; <code>
        claimRequest
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >; <code>
        markSettled
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        markReleased
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; }; <code>
        billing
      </code>
      
      : { <code>
        finalize
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        finalAmount?
      </code>
      
      : <code>
        number
      </code>
      
      ; }, { <code>
        settled
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        released
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        balance
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        balanceBefore
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        releaseJobId?
      </code>
      
      : <code>
        string
      </code>
      
      ; }>; <code>
        debit
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        amount
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        allowOverage?
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }, { <code>
        ok
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        balance
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        reason?
      </code>
      
      : <code>
        "no-row"
      </code>
      
       | <code>
        "no-meter"
      </code>
      
       | <code>
        "insufficient"
      </code>
      
      ; }>; <code>
        settle
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        finalAmount?
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        release
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        attachReleaseJob
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        jobId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; }; <code>
        costs
      </code>
      
      : { <code>
        record
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        owner
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        usage
      </code>
      
      : { <code>
        usd?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        input
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        output
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        cached
      </code>
      
      : <code>
        number
      </code>
      
      ; }; <code>
        spendLimitUsd?
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        summary
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        since
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <a href="#aicosts">
        <code>
          AiCosts
        </code>
      </a>
      
      >; }; <code>
        adapter
      </code>
      
      : { <code>
        findOne
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      >; }; }
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.ai
      </code>
    </td>
    
    <td>
      { <code>
        createRequest
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        name
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        args
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        cost
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        getByStream
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, | { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        name
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        args
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        cost
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        status
      </code>
      
      : <code>
        "reserved"
      </code>
      
       | <code>
        "released"
      </code>
      
       | <code>
        "streaming"
      </code>
      
       | <code>
        "settled"
      </code>
      
      ; <code>
        createdAt
      </code>
      
      : <code>
        number
      </code>
      
      ; } | <code>
        null
      </code>
      
      >; <code>
        claimRequest
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >; <code>
        markSettled
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        markReleased
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.ai.createRequest
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        name
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        args
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        cost
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.ai.getByStream
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, | { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        name
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        args
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        cost
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        status
      </code>
      
      : <code>
        "reserved"
      </code>
      
       | <code>
        "released"
      </code>
      
       | <code>
        "streaming"
      </code>
      
       | <code>
        "settled"
      </code>
      
      ; <code>
        createdAt
      </code>
      
      : <code>
        number
      </code>
      
      ; } | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.ai.claimRequest
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.ai.markSettled
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.ai.markReleased
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing
      </code>
    </td>
    
    <td>
      { <code>
        finalize
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        finalAmount?
      </code>
      
      : <code>
        number
      </code>
      
      ; }, { <code>
        settled
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        released
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        balance
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        balanceBefore
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        releaseJobId?
      </code>
      
      : <code>
        string
      </code>
      
      ; }>; <code>
        debit
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        amount
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        allowOverage?
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }, { <code>
        ok
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        balance
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        reason?
      </code>
      
      : <code>
        "no-row"
      </code>
      
       | <code>
        "no-meter"
      </code>
      
       | <code>
        "insufficient"
      </code>
      
      ; }>; <code>
        settle
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        finalAmount?
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        release
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        attachReleaseJob
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        jobId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; }
    </td>
    
    <td>
      The entitlement cache's reservation protocol. <code>
        setupAi
      </code>
      
       closes its own spends here rather than through <code>
        settleSpend
      </code>
      
      : only <code>
        finalize
      </code>
      
       can drop a reservation <em>
        and
      </em>
      
       hand back the unspent remainder atomically, and it reports the balance the low-balance hooks read.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.finalize
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        finalAmount?
      </code>
      
      : <code>
        number
      </code>
      
      ; }, { <code>
        settled
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        released
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        balance
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        balanceBefore
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        releaseJobId?
      </code>
      
      : <code>
        string
      </code>
      
      ; }>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.debit
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        amount
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        allowOverage?
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }, { <code>
        ok
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        balance
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        reason?
      </code>
      
      : <code>
        "no-row"
      </code>
      
       | <code>
        "no-meter"
      </code>
      
       | <code>
        "insufficient"
      </code>
      
      ; }>
    </td>
    
    <td>
      Take a spend the provider has from the balance again, once its reservation lapsed.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.settle
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        finalAmount?
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.release
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.attachReleaseJob
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        jobId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.costs
      </code>
    </td>
    
    <td>
      { <code>
        record
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        owner
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        usage
      </code>
      
      : { <code>
        usd?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        input
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        output
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        cached
      </code>
      
      : <code>
        number
      </code>
      
      ; }; <code>
        spendLimitUsd?
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        summary
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        since
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <a href="#aicosts">
        <code>
          AiCosts
        </code>
      </a>
      
      >; }
    </td>
    
    <td>
      What AI cost per person per day: each run's usage goes in, the Costs tab's summary comes out.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.costs.record
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        owner
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        usage
      </code>
      
      : { <code>
        usd?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        input
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        output
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        cached
      </code>
      
      : <code>
        number
      </code>
      
      ; }; <code>
        spendLimitUsd?
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.costs.summary
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        since
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <a href="#aicosts">
        <code>
          AiCosts
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.adapter
      </code>
    </td>
    
    <td>
      { <code>
        findOne
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      >; }
    </td>
    
    <td>
      The auth tables, where <code>
        getCosts
      </code>
      
       reads whether its caller is an administrator now.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.adapter.findOne
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="persistenttextstreaming">
        
      </a>
      
       <code>
        persistentTextStreaming
      </code>
    </td>
    
    <td>
      { <code>
        lib
      </code>
      
      : { <code>
        createStream
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { }, <code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >; <code>
        addChunk
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        text
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        final
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }, <code>
        null
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >; <code>
        setStreamStatus
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        status
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >; <code>
        getStreamStatus
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >; <code>
        getStreamText
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        text
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        status
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >; <code>
        deleteStream
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >; }; }
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        persistentTextStreaming.lib
      </code>
    </td>
    
    <td>
      { <code>
        createStream
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { }, <code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >; <code>
        addChunk
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        text
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        final
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }, <code>
        null
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >; <code>
        setStreamStatus
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        status
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >; <code>
        getStreamStatus
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >; <code>
        getStreamText
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        text
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        status
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >; <code>
        deleteStream
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        persistentTextStreaming.lib.createStream
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { }, <code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      node_modules/@convex-dev/persistent-text-streaming/dist/component/lib.d.ts:1
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        persistentTextStreaming.lib.addChunk
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        text
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        final
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }, <code>
        null
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      node_modules/@convex-dev/persistent-text-streaming/dist/component/lib.d.ts:2
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        persistentTextStreaming.lib.setStreamStatus
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        status
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      node_modules/@convex-dev/persistent-text-streaming/dist/component/lib.d.ts:7
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        persistentTextStreaming.lib.getStreamStatus
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      node_modules/@convex-dev/persistent-text-streaming/dist/component/lib.d.ts:11
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        persistentTextStreaming.lib.getStreamText
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        text
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        status
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      node_modules/@convex-dev/persistent-text-streaming/dist/component/lib.d.ts:14
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        persistentTextStreaming.lib.deleteStream
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        streamId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      node_modules/@convex-dev/persistent-text-streaming/dist/component/lib.d.ts:20
    </td>
  </tr>
</tbody>
</table>

---

### AiBudget

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

A per-entity spending cap, enforced through the rate limiter as a fixed
window over spend *value*: each metered call consumes its cost in tokens, so
`{ units: 500, period: DAY }` is "500 credits a day per workspace", not "500
calls a day".

The window is the limiter's own state, there is no new table. A call counts
its whole estimate when it starts, and the window gets back what it did not
spend when it closes: the rest of the estimate for a run that settles under
it, all of it for a run that fails or a call the balance refuses. While a run
is in flight its estimate stays counted, so concurrent calls can't overshoot.

Two things stay counted: an abandoned stream's estimate, whose credits come
back on a timer that can't reach the limiter, and what `charge: 'start'`
settles. A run that crosses into the next window gives its remainder to that
window, up to `units`.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="units">
        
      </a>
      
       <code>
        units
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Credits an entity may spend per window.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="period">
        
      </a>
      
       <code>
        period
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Window length in ms — <code>
        HOUR
      </code>
      
       / <code>
        DAY
      </code>
      
       from <code>
        nuxt-backend/rate-limit
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="limit-2">
        
      </a>
      
       <code>
        limit?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The named limit the window is recorded under. Default <code>
        'aiBudget'
      </code>
      
       (see <code>
        DEFAULT_LIMITS
      </code>
      
      ); name your own to keep separate budgets per feature.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AiSpendLimit

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

A ceiling on what AI costs the whole app in one UTC day, in US dollars, as
the gateway reports each call's cost. Once the day's spend reaches it, the
`pause_ai` kill switch turns on: every metered call, stream, job, chat
reply and safety check is refused (`unavailable`, reason `ai_paused`) until the next UTC
day begins, when the pause lifts by itself. An override of `pause_ai` an
administrator set (a pause, a targeted one, or a resume) is never written
over, and the lift leaves it. The `ai.spend_limit_reached`
event and the `ai_spend_limit` alert record it. A call already running
finishes, so the day can end a little over.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="usdperday">
        
      </a>
      
       <code>
        usdPerDay
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The most the whole app may spend on model calls in a UTC day, in US dollars: above 0.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CreditsBalanceEvent

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

What crossed a balance threshold, handed to the low-balance hooks.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="entityid">
        
      </a>
      
       <code>
        entityId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The billing entity (workspace/user) charged.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="userid">
        
      </a>
      
       <code>
        userId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The member whose call spent the credits.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meter-1">
        
      </a>
      
       <code>
        meter?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The configured meter name, when the spend named one.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meterid">
        
      </a>
      
       <code>
        meterId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The provider meter id.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="balance">
        
      </a>
      
       <code>
        balance
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Balance after the spend settled (negative when overage is allowed).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="previousbalance">
        
      </a>
      
       <code>
        previousBalance
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Balance as of before the spend reserved.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="spent">
        
      </a>
      
       <code>
        spent
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Credits this spend actually consumed.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="threshold">
        
      </a>
      
       <code>
        threshold?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The configured threshold, for <code>
        onCreditsLow
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AiCreditsConfig

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

Credit-side reactions to a settled spend.

The threshold lives here — on `setupAi` — rather than in
`appConfig.backend.*`: that is the client-side content layer (labels, plan
copy), and these hooks fire inside a Convex action where no Nuxt app config
exists. Keep them thin: send nothing from here (the lifecycle emails own
that), just record or hand off.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="lowbalancethreshold">
        
      </a>
      
       <code>
        lowBalanceThreshold?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Fire <a href="#oncreditslow">
        onCreditsLow
      </a>
      
       when a settle takes the balance from above this to at or below it. Omit to never fire it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="oncreditslow">
        
      </a>
      
       <code>
        onCreditsLow?
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        event
      </code>
      
      ) => <code>
        void
      </code>
      
       | <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The balance just crossed <a href="#lowbalancethreshold">
        lowBalanceThreshold
      </a>
      
       downwards. Fires on the crossing only — a second spend that stays below it is silent, so this is safe to wire straight to a notification. <strong>
        Guarantee
      </strong>
      
       - Runs: in the action that settled the spend - Delivery: once per crossing of the threshold downwards; a spend that stays below it is silent - Order: after the spend settles - When it throws: logged as <code>
        ai.balance_hook_failed
      </code>
      
       and swallowed; the spend stays settled - Idempotency: none needed: safe to wire straight to a notification
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="oncreditsexhausted">
        
      </a>
      
       <code>
        onCreditsExhausted?
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        event
      </code>
      
      ) => <code>
        void
      </code>
      
       | <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The balance just went from positive to zero-or-below. Same crossing rule. <strong>
        Guarantee
      </strong>
      
       - Runs: in the action that settled the spend - Delivery: once per crossing from a positive balance to zero or below - Order: after the spend settles - When it throws: logged as <code>
        ai.balance_hook_failed
      </code>
      
       and swallowed; the spend stays settled - Idempotency: none needed: safe to wire straight to a notification
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ModelStatus

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

Where calls to a model go on this deployment, as `ai.modelStatus()`
reports it: the state its app layer reads.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="model-1">
        
      </a>
      
       <code>
        model
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The model's id (<code>
        openai/gpt-5-mini
      </code>
      
      , or a model object's own); <code>
        null
      </code>
      
       when none is configured.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="state">
        
      </a>
      
       <code>
        state
      </code>
    </td>
    
    <td>
      <code>
        "missing"
      </code>
      
       | <code>
        "live"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       - <code>
        live
      </code>
      
      : calls reach the model: through the Convex AI Gateway on Convex Cloud (a free plan refuses it when called, unless the order goes on to the Vercel AI Gateway and <code>
        AI_GATEWAY_API_KEY
      </code>
      
       is set), through the Vercel AI Gateway with <code>
        AI_GATEWAY_API_KEY
      </code>
      
      , or with a model object's own provider key; - <code>
        missing
      </code>
      
      : no gateway in <code>
        setupAi({ gateway })
      </code>
      
      's order can serve this deployment, or no model is configured: calls are refused <code>
        unavailable
      </code>
      
       (reason <code>
        not_configured
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="route">
        
      </a>
      
       <code>
        route
      </code>
    </td>
    
    <td>
      <code>
        "provider"
      </code>
      
       | <code>
        "convex-gateway"
      </code>
      
       | <code>
        "vercel-gateway"
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Where calls go first: <code>
        convex-gateway
      </code>
      
       (the Convex AI Gateway, where the deployment can have it; the next gateway in the order answers when it refuses), <code>
        vercel-gateway
      </code>
      
       (<code>
        AI_GATEWAY_API_KEY
      </code>
      
      ), <code>
        provider
      </code>
      
       (a model object's own key), or <code>
        null
      </code>
      
       when calls are refused.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### SetupAiConfig

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="billing">
        
      </a>
      
       <code>
        billing
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/billing#billing">
        <code>
          Billing
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The <code>
        setupBilling(...)
      </code>
      
       instance — supplies entity resolution + the credit spend.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="model-2">
        
      </a>
      
       <code>
        model?
      </code>
    </td>
    
    <td>
      <code>
        LanguageModel
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The model <code>
        ctx.model()
      </code>
      
       calls when an action names none: a <code>
        provider/model
      </code>
      
       id or a model object. See <a href="#aimodel">
        AiModel
      </a>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="ratelimiter">
        
      </a>
      
       <code>
        rateLimiter?
      </code>
    </td>
    
    <td>
      <a href="#airatelimiter">
        <code>
          AiRateLimiter
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Your <code>
        setupRateLimiter(...)
      </code>
      
       instance. Metered actions/streams check their named limit (default <code>
        'ai'
      </code>
      
      ) per billing entity before reserving. Omit to leave them unthrottled.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cors">
        
      </a>
      
       <code>
        cors?
      </code>
    </td>
    
    <td>
      { <code>
        origin?
      </code>
      
      : <code>
        string
      </code>
      
      ; }
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       CORS origin for the stream endpoint. Defaults to the <code>
        SITE_URL
      </code>
      
       env var.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        cors.origin?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="budget">
        
      </a>
      
       <code>
        budget?
      </code>
    </td>
    
    <td>
      <a href="#aibudget">
        <code>
          AiBudget
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A per-entity credit budget on top of the call-rate limit. Requires <code>
        rateLimiter
      </code>
      
       (it is enforced through it).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="credits">
        
      </a>
      
       <code>
        credits?
      </code>
    </td>
    
    <td>
      <a href="#aicreditsconfig">
        <code>
          AiCreditsConfig
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Low-balance reactions fired after a spend settles.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="streamtimeout">
        
      </a>
      
       <code>
        streamTimeout?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
      
       | <code>
        false
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       How long a started stream may hold its reservation before it is released automatically (ms). Default 5 minutes; <code>
        false
      </code>
      
       disables the timer.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="guest">
        
      </a>
      
       <code>
        guest?
      </code>
    </td>
    
    <td>
      <a href="#aiguestconfig">
        <code>
          AiGuestConfig
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       What happens to a visitor's guest jobs (<code>
        defineJobQueue({ guest })
      </code>
      
      ) once they sign up. See <a href="#aiguestconfig">
        AiGuestConfig
      </a>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="gateway">
        
      </a>
      
       <code>
        gateway?
      </code>
    </td>
    
    <td>
      <a href="#aigateway">
        <code>
          AiGateway
        </code>
      </a>
      
       | readonly <a href="#aigateway">
        <code>
          AiGateway
        </code>
      </a>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The gateways a <code>
        provider/model
      </code>
      
       id goes through, in order (<a href="#aigateway">
        AiGateway
      </a>
      
      ): one name for that gateway alone, a list for an order. Default <code>
        ['convex', 'vercel']
      </code>
      
      . The next gateway answers only when one cannot serve this deployment: the Convex AI Gateway on a free plan (<code>
        AiGatewayDisabled
      </code>
      
      ), an anonymous local or a self-hosted deployment, or without <code>
        @convex-dev/ai-sdk-provider
      </code>
      
      ; the Vercel AI Gateway without <code>
        AI_GATEWAY_API_KEY
      </code>
      
      . A spent limit or a provider's refusal refuses the call: it is never routed around. With no gateway left, the call is refused <code>
        unavailable
      </code>
      
       (reason <code>
        not_configured
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="inferenceregion">
        
      </a>
      
       <code>
        inferenceRegion?
      </code>
    </td>
    
    <td>
      <code>
        "eu"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Pin every model call to providers' endpoints in one region. <code>
        'eu'
      </code>
      
       sends every <code>
        provider/model
      </code>
      
       id through the Vercel AI Gateway with <code>
        AI_GATEWAY_API_KEY
      </code>
      
       (the Convex AI Gateway documents no inference region, so it is never tried: a <code>
        gateway
      </code>
      
       order without <code>
        'vercel'
      </code>
      
       is refused), and adds the gateway's <code>
        providerOptions.gateway.inferenceRegion: { scope: 'zone', geoRegion: 'eu' }
      </code>
      
       to every call through <code>
        ctx.model()
      </code>
      
      . A model no provider serves in the region is refused by the gateway, and the run's reservation released. A call that reports running elsewhere logs <code>
        ai.region_mismatch
      </code>
      
      . The pin covers inference only: the deployment's data stays in its Convex region.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="routes">
        
      </a>
      
       <code>
        routes?
      </code>
    </td>
    
    <td>
      <code>
        Readonly
      </code>
      
      <<code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <a href="#aigateway">
        <code>
          AiGateway
        </code>
      </a>
      
       | readonly <a href="#aigateway">
        <code>
          AiGateway
        </code>
      </a>
      
      <span>
        
      </span>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A gateway order for some models, over <code>
        gateway
      </code>
      
       (<a href="#modelroutes">
        ModelRoutes
      </a>
      
      ): keyed by <code>
        provider/model
      </code>
      
       id or a pattern ending in <code>
        *
      </code>
      
      , each a gateway or an order. Applies to language, embedding and image models alike. A route to <code>
        'convex'
      </code>
      
       alone never reads <code>
        AI_GATEWAY_API_KEY
      </code>
      
       for those models. With <code>
        inferenceRegion
      </code>
      
      , a route that leaves out <code>
        'vercel'
      </code>
      
       is refused, like such a <code>
        gateway
      </code>
      
      . <strong>
        Example
      </strong>
      
       <code>
        setupAi(components, { billing, routes: { 'google/*': 'vercel', 'openai/gpt-image-2': 'vercel' } })
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="provenance">
        
      </a>
      
       <code>
        provenance?
      </code>
    </td>
    
    <td>
      <a href="#provenanceconfig">
        <code>
          ProvenanceConfig
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Content credentials on what a model made (EU AI Act Art. 50): every image stored through <code>
        ctx.storeImage
      </code>
      
       gets a C2PA manifest signed with <code>
        PROVENANCE_PRIVATE_KEY
      </code>
      
       and the IPTC <code>
        trainedAlgorithmicMedia
      </code>
      
       digital source type, and a provenance record of the models, the time and its inputs' ids; job results carry <code>
        provenance
      </code>
      
      . <code>
        true
      </code>
      
       for the defaults, <code>
        { name }
      </code>
      
       for the generator name each manifest shows.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="moderation">
        
      </a>
      
       <code>
        moderation?
      </code>
    </td>
    
    <td>
      <a href="#moderationconfig">
        <code>
          ModerationConfig
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The safety classifier <code>
        ai.moderate
      </code>
      
      , <code>
        ai.requireSafe
      </code>
      
       and every <code>
        moderate
      </code>
      
       option check content with: a model call through the gateway, on the app's bill, never on the person's credits. Its cost is recorded like any run's, so <code>
        spendLimit
      </code>
      
       counts it. Default <code>
        { model: 'meta-llama/llama-guard-4-12b' }
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="spendlimit">
        
      </a>
      
       <code>
        spendLimit?
      </code>
    </td>
    
    <td>
      <a href="#aispendlimit">
        <code>
          AiSpendLimit
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The daily ceiling on what AI costs the whole app (<a href="#aispendlimit">
        AiSpendLimit
      </a>
      
      ). A <code>
        sandbox
      </code>
      
       deployment, a public demo, refuses every metered call, stream, job and chat reply without one (<code>
        not_ready
      </code>
      
      , reason <code>
        no_budget
      </code>
      
      ): anyone may sign up there, and the model calls are real.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AiGuestConfig

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

What the guest jobs' claim at sign-up runs (`setupAi({ guest })`).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="claim">
        
      </a>
      
       <code>
        claim?
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , <a href="#guestclaim">
        <code>
          GuestClaim
        </code>
      </a>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       An internal mutation of yours that moves your own rows to the new account when a visitor signs up in the browser that started guest jobs: it receives the guest's job ids, the new account's workspace and the account itself. The jobs have moved by then (<code>
        useJob
      </code>
      
       reads them for the new account); your rows that name them are yours to move.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### MeteredUsage

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

Usage details handed to metered handlers (`ctx.usage`).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="entityid-1">
        
      </a>
      
       <code>
        entityId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The billing entity (workspace/user) charged.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="userid-2">
        
      </a>
      
       <code>
        userId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The signed-in caller.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meter-2">
        
      </a>
      
       <code>
        meter?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Configured meter name, when metered.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cost-1">
        
      </a>
      
       <code>
        cost
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Credits this call costs — the estimate, for a finalized cost.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### FinalizedCost

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

A cost that is only known once the work is done: reserve `estimate`, run,
then settle what `finalize` returns and hand the remainder back.

The estimate is the *ceiling* — a final amount above it is clamped down (the
reservation is what made the spend safe against a concurrent one, so
settling beyond it would be a second, unguarded debit). Estimate high.

Requires a sum meter (one with a `property`): the finalized amount rides in
the ingested event's metadata, and a count meter can only ever count 1 per
event.

#### Example

```ts
cost: {
  estimate: 500,
  finalize: result => priceTokens({ model: result.model, ...result.usage }, prices),
}
```

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-args">
        
      </a>
      
       <code>
        Args
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        PropertyValidators
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-result">
        
      </a>
      
       <code>
        Result
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="estimate">
        
      </a>
      
       <code>
        estimate
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
      
       | ((<code>
        args
      </code>
      
      ) => <code>
        number
      </code>
      
      )
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Credits to reserve up front — a number or derived from the args.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="finalize">
        
      </a>
      
       <code>
        finalize
      </code>
    </td>
    
    <td>
      (<code>
        result
      </code>
      
      , <code>
        usage
      </code>
      
      ) => <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The credits actually consumed, from what the handler returned.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="creditsperusd">
        
      </a>
      
       <code>
        creditsPerUsd?
      </code>
    </td>
    
    <td>
      <code>
        undefined
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Not here: a cost is finalized from the result or reported by the model (<a href="#reportedcost">
        ReportedCost
      </a>
      
      ), never both.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ReportedCost

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

A cost the model reports: reserve `estimate`, run, then settle what the
model calls made through `ctx.model()` cost, at `creditsPerUsd`. A call
through the AI Gateway reports its cost in US dollars
(`providerMetadata.gateway.cost`).

The estimate is the ceiling, as for a [FinalizedCost](#finalizedcost): a cost above it
settles at the reservation. A call that reports no cost (a model object of
your own) is priced by its tokens from `prices` when the table has its
model; otherwise, and for a stream left unread or broken before it
reported one, the run settles at the reservation and the line
`ai.cost_unreported` is logged, so an unpriced call is never free. A run
that made no model call settles at `minimum`, zero by default; one whose
every call failed is a failed run, released.

Needs a sum meter, like any cost settled after the run.

#### Example

```ts
// 1 credit per cent of model spend, at least 1 credit a call.
cost: { estimate: 20, creditsPerUsd: 100, round: 'up', minimum: 1 },
```

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-args-1">
        
      </a>
      
       <code>
        Args
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        PropertyValidators
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="estimate-1">
        
      </a>
      
       <code>
        estimate
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
      
       | ((<code>
        args
      </code>
      
      ) => <code>
        number
      </code>
      
      )
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Credits to reserve up front — a number or derived from the args.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="creditsperusd-1">
        
      </a>
      
       <code>
        creditsPerUsd
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Credits per US dollar of reported model cost: your price, margin included.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="prices">
        
      </a>
      
       <code>
        prices?
      </code>
    </td>
    
    <td>
      <a href="#tokenpricetable">
        <code>
          TokenPriceTable
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Token prices for calls that report no cost, as <code>
        priceTokens
      </code>
      
       reads them: model id → credits per block of tokens. Keyed by the id the call was made with: the <code>
        provider/model
      </code>
      
       id through the gateway, a model object's own <code>
        modelId
      </code>
      
       (<code>
        gpt-5-mini
      </code>
      
       from <code>
        @ai-sdk/openai
      </code>
      
      ) for your own provider.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="round">
        
      </a>
      
       <code>
        round?
      </code>
    </td>
    
    <td>
      <code>
        "none"
      </code>
      
       | <code>
        "up"
      </code>
      
       | <code>
        "nearest"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Round the credits up, to the nearest whole credit, or not at all (the default).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="minimum">
        
      </a>
      
       <code>
        minimum?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The fewest credits a run settles at. Default <code>
        0
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="finalize-1">
        
      </a>
      
       <code>
        finalize?
      </code>
    </td>
    
    <td>
      <code>
        undefined
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Not here: a cost is reported by the model or finalized from the result (<a href="#finalizedcost">
        FinalizedCost
      </a>
      
      ), never both.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### MeteredContext

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

What a metered handler gets beside the action context.

#### Extends

- [`ImageStoreContext`](#imagestorecontext)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Inherited from
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="usage">
        
      </a>
      
       <code>
        usage
      </code>
    </td>
    
    <td>
      <a href="#meteredusage">
        <code>
          MeteredUsage
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Who is charged, and the cost reserved.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="model-3">
        
      </a>
      
       <code>
        model
      </code>
    </td>
    
    <td>
      (<code>
        model?
      </code>
      
      ) => <code>
        LanguageModelV4
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The model to call: the call's own (<code>
        model
      </code>
      
       on the action, else on <code>
        setupAi
      </code>
      
      ), or another by id or object. Every call made through what it returns counts toward the run's cost: a <a href="#reportedcost">
        ReportedCost
      </a>
      
       settles from what those calls report. <strong>
        Example
      </strong>
      
       <code>
        const { text } = await generateText({ model: ctx.model(), prompt })
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="storeimage">
        
      </a>
      
       <code>
        storeImage
      </code>
    </td>
    
    <td>
      (<code>
        file
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Id
      </code>
      
      <<code>
        "_storage"
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Store an image a model made, with its content credentials: the IPTC source type in its XMP, a C2PA manifest signed with <code>
        PROVENANCE_PRIVATE_KEY
      </code>
      
      , and a provenance record of the models, the time and <code>
        inputs
      </code>
      
      . The image is kept in the <code>
        backend
      </code>
      
       component's storage as the job's owner's (the run's billing entity in a metered action), like an upload <code>
        storage.claim
      </code>
      
       kept: counted in the quota, listed in the owner's export and deleted with it. Resolves with its id there, typed as a storage id: read its URL through <code>
        storage.fileUrl
      </code>
      
      , <code>
        storage.signedUrl
      </code>
      
       or <code>
        getFileUrl
      </code>
      
      , never <code>
        ctx.storage.getUrl
      </code>
      
      , and delete it with <code>
        storage.release
      </code>
      
      .
    </td>
    
    <td>
      <a href="#imagestorecontext">
        <code>
          ImageStoreContext
        </code>
      </a>
      
      .<a href="#storeimage-2">
        <code>
          storeImage
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/provenance.ts" rel="nofollow">
        src/convex/integrations/ai/provenance.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### MeteredActionConfig

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
    
    <th>
      Default type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-args-3">
        
      </a>
      
       <code>
        Args
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        PropertyValidators
      </code>
    </td>
    
    <td>
      -
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-result-2">
        
      </a>
      
       <code>
        Result
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="meter-3">
        
      </a>
      
       <code>
        meter
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        false
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The configured credit meter to charge (<code>
        setupBilling({ credits })
      </code>
      
       / catalog key) — or <code>
        false
      </code>
      
       for a rate-limit-only action.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cost-2">
        
      </a>
      
       <code>
        cost?
      </code>
    </td>
    
    <td>
      <a href="#meteredcost">
        <code>
          MeteredCost
        </code>
      </a>
      
      <<code>
        Args
      </code>
      
      , <code>
        Result
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Credits per call. Default <code>
        1
      </code>
      
      . See <a href="#meteredcost">
        MeteredCost
      </a>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="limit-3">
        
      </a>
      
       <code>
        limit?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        false
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Named rate limit (checked per billing entity via the configured <code>
        rateLimiter
      </code>
      
      ). Default <code>
        'ai'
      </code>
      
      ; <code>
        false
      </code>
      
       disables the check.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="allowoverage-1">
        
      </a>
      
       <code>
        allowOverage?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Let this spend take the balance negative instead of refusing it — for a pay-as-you-go meter with no credit benefit behind it, where every unit is overage the provider invoices at the end of the cycle.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="charge">
        
      </a>
      
       <code>
        charge?
      </code>
    </td>
    
    <td>
      <code>
        "success"
      </code>
      
       | <code>
        "start"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       When to charge: <code>
        'success'
      </code>
      
       (default) settles after the handler returns — a failed run consumes nothing; <code>
        'start'
      </code>
      
       settles before running, for work that is irrevocably consumed upstream the moment it starts. A finalized or reported cost needs the run, so it only applies to <code>
        'success'
      </code>
      
      : under <code>
        'start'
      </code>
      
       the estimate settles.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="model-4">
        
      </a>
      
       <code>
        model?
      </code>
    </td>
    
    <td>
      <code>
        LanguageModel
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The model <code>
        ctx.model()
      </code>
      
       calls, over <code>
        setupAi
      </code>
      
      's. Naming one also refuses the call before anything is counted when this deployment cannot reach it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="moderate-1">
        
      </a>
      
       <code>
        moderate?
      </code>
    </td>
    
    <td>
      (<code>
        args
      </code>
      
      ) => <a href="#moderationinput">
        <code>
          ModerationInput
        </code>
      </a>
      
       & <code>
        Pick
      </code>
      
      <<a href="#moderationsubject">
        <code>
          ModerationSubject
        </code>
      </a>
      
      , <code>
        "subject"
      </code>
      
       | <code>
        "stage"
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       What to check with the safety classifier before the reservation: the args' text and images (file storage ids). A flagged call is refused <code>
        invalid_input
      </code>
      
       with reason <code>
        content_blocked
      </code>
      
      , and nothing is reserved, counted against the budget or charged. Its flag names the caller and the entity that pays, at stage <code>
        prompt
      </code>
      
      ; add <code>
        subject
      </code>
      
      , your id of what was checked, and <code>
        stage
      </code>
      
       to name them in your words.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="args">
        
      </a>
      
       <code>
        args
      </code>
    </td>
    
    <td>
      <code>
        Args
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="handler">
        
      </a>
      
       <code>
        handler
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        args
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Result
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### MeteredStreamConfig

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
    
    <th>
      Default type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-args-4">
        
      </a>
      
       <code>
        Args
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        PropertyValidators
      </code>
    </td>
    
    <td>
      -
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-result-3">
        
      </a>
      
       <code>
        Result
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="name-1">
        
      </a>
      
       <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Registry key — unique per app; the HTTP dispatcher routes by it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meter-4">
        
      </a>
      
       <code>
        meter
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        false
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The configured credit meter to charge, or <code>
        false
      </code>
      
       for limit-only.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cost-3">
        
      </a>
      
       <code>
        cost?
      </code>
    </td>
    
    <td>
      <a href="#meteredcost">
        <code>
          MeteredCost
        </code>
      </a>
      
      <<code>
        Args
      </code>
      
      , <code>
        Result
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Credits per stream. Default <code>
        1
      </code>
      
      . A <a href="#finalizedcost">
        FinalizedCost
      </a>
      
       prices what the handler <em>
        returns
      </em>
      
       — return the model's token usage from it; a <a href="#reportedcost">
        ReportedCost
      </a>
      
       settles from what the model calls through <code>
        ctx.model()
      </code>
      
       reported once the stream ends.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="limit-4">
        
      </a>
      
       <code>
        limit?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        false
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Named rate limit. Default <code>
        'ai'
      </code>
      
      ; <code>
        false
      </code>
      
       disables.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="allowoverage-2">
        
      </a>
      
       <code>
        allowOverage?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Let this spend take the balance negative (pay-as-you-go meters).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="model-5">
        
      </a>
      
       <code>
        model?
      </code>
    </td>
    
    <td>
      <code>
        LanguageModel
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The model <code>
        ctx.model()
      </code>
      
       calls, over <code>
        setupAi
      </code>
      
      's; refused at <code>
        start
      </code>
      
       when unreachable.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="moderate-2">
        
      </a>
      
       <code>
        moderate?
      </code>
    </td>
    
    <td>
      (<code>
        args
      </code>
      
      ) => <a href="#moderationinput">
        <code>
          ModerationInput
        </code>
      </a>
      
       & <code>
        Pick
      </code>
      
      <<a href="#moderationsubject">
        <code>
          ModerationSubject
        </code>
      </a>
      
      , <code>
        "subject"
      </code>
      
       | <code>
        "stage"
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       What to check with the safety classifier before the reservation: the args' text and images (file storage ids). A flagged call is refused <code>
        invalid_input
      </code>
      
       with reason <code>
        content_blocked
      </code>
      
      , and nothing is reserved, counted against the budget or charged. Its flag names the caller and the entity that pays, at stage <code>
        prompt
      </code>
      
      ; add <code>
        subject
      </code>
      
      , your id of what was checked, and <code>
        stage
      </code>
      
       to name them in your words.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="args-1">
        
      </a>
      
       <code>
        args
      </code>
    </td>
    
    <td>
      <code>
        Args
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="handler-1">
        
      </a>
      
       <code>
        handler
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        args
      </code>
      
      , <code>
        stream
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Result
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Produce the stream: <code>
        append(text)
      </code>
      
       pushes a chunk to the client AND persists it. Credits settle when the handler finishes; an error or disconnect releases them — an interrupted stream never charges.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### PersonCost

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

One person's AI costs over the Costs tab's window, the costliest first.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="who">
        
      </a>
      
       <code>
        who
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       An account id, <code>
        guest
      </code>
      
       for visitors' jobs, or the billing entity a run was paid by without a member (<code>
        app
      </code>
      
       for the app's own).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="name-2">
        
      </a>
      
       <code>
        name?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The account's name and address while it exists.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="email">
        
      </a>
      
       <code>
        email?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="usd">
        
      </a>
      
       <code>
        usd
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       US dollars, as the gateway reported them: a call through a key of your own reports none.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="input">
        
      </a>
      
       <code>
        input
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="output">
        
      </a>
      
       <code>
        output
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="runs">
        
      </a>
      
       <code>
        runs
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Runs that ended in the window: jobs, metered calls, streams, chat replies and embeddings.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AiCosts

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

What AI cost over a window (`getCosts`): the admin console's Costs tab.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="since">
        
      </a>
      
       <code>
        since
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The window's first UTC day, as its first millisecond.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="usd-1">
        
      </a>
      
       <code>
        usd
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="runs-1">
        
      </a>
      
       <code>
        runs
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="days">
        
      </a>
      
       <code>
        days
      </code>
    </td>
    
    <td>
      { <code>
        day
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        usd
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        runs
      </code>
      
      : <code>
        number
      </code>
      
      ; }<span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Each day's total, oldest first; a day without any is absent.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="people">
        
      </a>
      
       <code>
        people
      </code>
    </td>
    
    <td>
      <a href="#personcost">
        <code>
          PersonCost
        </code>
      </a>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The 100 costliest people.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="truncated">
        
      </a>
      
       <code>
        truncated
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       <code>
        true
      </code>
      
       when the window held more rows than one read takes: the people cover its newest days. The totals are whole.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AiApi

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

The functions `setupAi` builds for the admin console, to re-export from `backend/ai.ts`.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="getcosts">
        
      </a>
      
       <code>
        getCosts
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        since
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<a href="#aicosts">
        <code>
          AiCosts
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       What AI cost per person from <code>
        since
      </code>
      
       (a moment; its UTC day counts whole, and 90 days are kept): the job queue, metered actions, streams, chat replies and knowledge embeddings, for administrators; <code>
        null
      </code>
      
       for anyone else. The caller passes the moment, so the query reads no clock.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="getmoderationstatement">
        
      </a>
      
       <code>
        getModerationStatement
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        flagId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<a href="#moderationstatement">
        <code>
          ModerationStatement
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A recorded decision's statement of reasons (DSA Art. 17), for the person it was about or an administrator; <code>
        null
      </code>
      
       to anyone else, once the record is pruned, and to the uploader of a known-abuse match.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="listmoderationflags">
        
      </a>
      
       <code>
        listModerationFlags
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        paginationOpts
      </code>
      
      : { <code>
        numItems
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        cursor
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; }; <code>
        escalated?
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      < | { <code>
        page
      </code>
      
      : <a href="#moderationflag">
        <code>
          ModerationFlag
        </code>
      </a>
      
      <span>
        
      </span>
      
      ; <code>
        isDone
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        continueCursor
      </code>
      
      : <code>
        string
      </code>
      
      ; } | <code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### Ai

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="meteredaction">
        
      </a>
      
       <code>
        meteredAction
      </code>
    </td>
    
    <td>
      <<code>
        Args
      </code>
      
      , <code>
        Result
      </code>
      
      >(<code>
        config
      </code>
      
      ) => <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A drop-in replacement for <code>
        action
      </code>
      
       that rate-limits, reserves prepaid credits, runs your handler, then settles the spend (usage lands in the billing provider as an ingested event). Failed runs release the reservation — nothing charged. <strong>
        Examples
      </strong>
      
       <code>
        export const generate = ai.meteredAction({ meter: 'credits', cost: args => args.long ? 5 : 1, args: { prompt: v.string(), long: v.optional(v.boolean()) }, handler: async (ctx, { prompt }) => runModel(prompt), })
      </code>
      
       <strong>
        Settle what the model reported it cost
      </strong>
      
       <code>
        export const summarize = ai.meteredAction({ meter: 'credits', model: 'openai/gpt-5-mini', cost: { estimate: 20, creditsPerUsd: 100, round: 'up', minimum: 1 }, args: { text: v.string() }, handler: async (ctx, { text }) => { const { text: summary } = await generateText({ model: ctx.model(), prompt:
      </code>
      
      Summarize: ${text}<code>
        }) return summary }, })
      </code>
      
       <strong>
        Token pricing — reserve an estimate, settle the actual usage
      </strong>
      
       <code>
        export const generate = ai.meteredAction({ meter: 'credits', cost: { estimate: 200, finalize: result => priceTokens(result.usage, prices), }, args: { prompt: v.string() }, handler: async (ctx, { prompt }) => runModel(prompt), })
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="stream">
        
      </a>
      
       <code>
        stream
      </code>
    </td>
    
    <td>
      <<code>
        Args
      </code>
      
      , <code>
        Result
      </code>
      
      >(<code>
        config
      </code>
      
      ) => { <code>
        start
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        body
      </code>
      
      : <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      >; }
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A metered, persisted token stream. Returns <code>
        { start, body }
      </code>
      
       to re-export from your module — <code>
        useAiStream
      </code>
      
       drives them: <code>
        start
      </code>
      
       reserves credits and creates the stream, the HTTP endpoint (<code>
        registerBackendRoutes({ ai })
      </code>
      
      ) runs your handler and streams chunks, <code>
        body
      </code>
      
       serves the persisted text reactively (reload mid-stream and it continues). A started stream that is never delivered (the browser closed before the HTTP call, or it died mid-flight) holds its reservation until the scheduled auto-release hands the credits back — <code>
        streamTimeout
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="httphandler">
        
      </a>
      
       <code>
        httpHandler
      </code>
    </td>
    
    <td>
      <code>
        PublicHttpAction
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The stream endpoint for <code>
        registerBackendRoutes({ ai })
      </code>
      
       (POST + CORS preflight).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="corsorigin">
        
      </a>
      
       <code>
        corsOrigin
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       CORS headers for the stream route (used by <code>
        registerBackendRoutes
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="modelstatus-1">
        
      </a>
      
       <code>
        modelStatus
      </code>
    </td>
    
    <td>
      (<code>
        model?
      </code>
      
      ) => <a href="#modelstatus">
        <code>
          ModelStatus
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Where calls to a model go on this deployment — <code>
        setupAi
      </code>
      
      's <code>
        model
      </code>
      
       when none is passed: <code>
        live
      </code>
      
       or <code>
        missing
      </code>
      
      . Reads only the env, so a query can show it. <strong>
        Example
      </strong>
      
       <code>
        export const modelStatus = query({ args: {}, handler: async () => ai.modelStatus() })
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="chat-1">
        
      </a>
      
       <code>
        chat
      </code>
    </td>
    
    <td>
      (<code>
        config
      </code>
      
      ) => <a href="#chat">
        <code>
          Chat
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A chat: threads each person keeps with a model that follows your instructions, every reply streamed into the thread, kept on the server and metered like a metered action (reserved in the send, settled at what the model cost). Built on Convex's Agent component, which the app installs and mounts (<code>
        app.use(agent)
      </code>
      
      ). Export the five functions it returns from the chat's module, under their names: <code>
        send
      </code>
      
       schedules <code>
        reply
      </code>
      
       next to itself. <strong>
        Example
      </strong>
      
       <code>
        // backend/chat.ts export const { threads, messages, send, remove, reply } = ai.chat({ name: 'helper', instructions: 'You help people plan comic strips.', meter: 'credits', cost: { estimate: 20, creditsPerUsd: 1000, round: 'up', minimum: 1 }, })
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="knowledge-1">
        
      </a>
      
       <code>
        knowledge
      </code>
    </td>
    
    <td>
      (<code>
        config
      </code>
      
      ) => <a href="#knowledge-2">
        <code>
          Knowledge
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A knowledge store: each billing entity's documents in a namespace of their own, plus one the app owns, searched by meaning. Built on Convex's RAG component, which the app installs and mounts (<code>
        app.use(rag)
      </code>
      
      ). Export its <code>
        api
      </code>
      
       from the store's module, under their names: <code>
        add
      </code>
      
       schedules <code>
        embed
      </code>
      
       next to itself. <strong>
        Example
      </strong>
      
       <code>
        // backend/knowledge.ts export const knowledge = ai.knowledge({ model: 'openai/text-embedding-3-small', dimension: 1536, meter: 'credits' }) export const { documents, add, search, remove, embed } = knowledge.api
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="provenanceof">
        
      </a>
      
       <code>
        provenanceOf
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        storageId
      </code>
      
      ) => <code>
        Promise
      </code>
      
      < | <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobprovenance">
        <code>
          JobProvenance
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       What made a stored file (<code>
        ctx.storeImage
      </code>
      
       recorded it): the models, when, and the ids of its inputs; <code>
        null
      </code>
      
       for a file nothing recorded. Reads in a query, a mutation or an action of your own. <strong>
        Example
      </strong>
      
       <code>
        export const panelProvenance = query({ args: { storageId: v.id('_storage') }, handler: (ctx, { storageId }) => ai.provenanceOf(ctx, storageId), })
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="moderate-3">
        
      </a>
      
       <code>
        moderate
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        input
      </code>
      
      , <code>
        about?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#moderationverdict">
        <code>
          ModerationVerdict
        </code>
      </a>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Check text and images with the safety classifier (<code>
        setupAi({ moderation })
      </code>
      
      ) and answer its verdict: <code>
        flagged
      </code>
      
      , <code>
        categories
      </code>
      
      , the classifier's own codes (Llama Guard's <code>
        S1
      </code>
      
       to <code>
        S14
      </code>
      
      ), and what the policy makes of them: <code>
        blocked
      </code>
      
       and <code>
        escalate
      </code>
      
      . A flagged check is recorded for the admin console's Moderation tab, with <code>
        about
      </code>
      
      : who the content came from (default: who is signed in), and your id and stage of what was checked. Images are file storage ids, an upload not yet claimed included. In an action; the call is on the app's gateway bill, its cost recorded against <code>
        spendLimit
      </code>
      
      , and it is refused while <code>
        pause_ai
      </code>
      
       is on (<code>
        unavailable
      </code>
      
      , reason <code>
        ai_paused
      </code>
      
      ). <strong>
        Example
      </strong>
      
       <code>
        const { blocked } = await ai.moderate(ctx, { text: title }, { subject: comicId, stage: 'title' })
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="requiresafe">
        
      </a>
      
       <code>
        requireSafe
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        input
      </code>
      
      , <code>
        about?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       <a href="#moderate-3">
        Ai.moderate
      </a>
      
      , refusing content the policy blocks: <code>
        invalid_input
      </code>
      
       with reason <code>
        content_blocked
      </code>
      
       (on <code>
        prompt
      </code>
      
       when there is text, else on <code>
        images
      </code>
      
      ). Content flagged in a category <code>
        moderation.block
      </code>
      
       leaves out passes, recorded. Call it where your code accepts an upload, before you keep it. <strong>
        Example
      </strong>
      
       <code>
        export const attach = authed.action({ args: { storageId: v.string() }, handler: async (ctx, { storageId }) => { await ai.requireSafe(ctx, { images: [storageId] }) // …now keep it }, })
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="api">
        
      </a>
      
       <code>
        api
      </code>
    </td>
    
    <td>
      <a href="#aiapi">
        <code>
          AiApi
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The admin console's functions, to re-export from <code>
        backend/ai.ts
      </code>
      
      : <code>
        getCosts
      </code>
      
      , what each person's AI calls cost, which the Costs tab reads, and <code>
        listModerationFlags
      </code>
      
      , what the safety classifier flagged, which the Moderation tab reads. <strong>
        Example
      </strong>
      
       <code>
        export const { getCosts, listModerationFlags } = ai.api
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### JobQueueComponents

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

The components `defineJobQueue` reads from your generated `components` object.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="backend-1">
        
      </a>
      
       <code>
        backend
      </code>
    </td>
    
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The <code>
        backend
      </code>
      
       component: the queue's rows live there.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="workflow">
        
      </a>
      
       <code>
        workflow?
      </code>
    </td>
    
    <td>
      <code>
        WorkflowComponent
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The Workflow component the jobs run on, as the scaffold mounts it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### GuestJobs

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

Jobs a signed-out visitor may start (`defineJobQueue({ guest })`).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="pervisitor">
        
      </a>
      
       <code>
        perVisitor
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       How many jobs one visitor (one browser, by its cookie) may start before signing up: <code>
        1
      </code>
      
       is one free try. Counts the jobs that wait, run or are done; a failed or canceled one gives its try back. A done one stays used for the visitor cookie's year, after its record is pruned.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### JobModelLimit

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

Where a model's limit starts, and the range it adapts within, in calls a minute.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="perminute">
        
      </a>
      
       <code>
        perMinute
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="min">
        
      </a>
      
       <code>
        min?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The floor a <code>
        429
      </code>
      
       halves it to. Default <code>
        1
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="max">
        
      </a>
      
       <code>
        max?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The ceiling clean calls grow it to. Default <code>
        30
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### DefineJobQueueOptions

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="ai-1">
        
      </a>
      
       <code>
        ai
      </code>
    </td>
    
    <td>
      <a href="#ai">
        <code>
          Ai
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Your <code>
        setupAi(...)
      </code>
      
       instance: jobs share its billing, its model route, its <code>
        ai
      </code>
      
       rate limit and the <code>
        pause_ai
      </code>
      
       switch.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="concurrency">
        
      </a>
      
       <code>
        concurrency?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       How many jobs run at once across the app. Default <code>
        3
      </code>
      
      ; the admin console changes it without a deploy.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="perowner">
        
      </a>
      
       <code>
        perOwner?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Running jobs one owner may have, for a tier that sets none. Default <code>
        1
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="tiers">
        
      </a>
      
       <code>
        tiers?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <a href="#jobtier">
        <code>
          JobTier
        </code>
      </a>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       What each plan gets in the line, best first. See <a href="#jobtier">
        JobTier
      </a>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="models">
        
      </a>
      
       <code>
        models?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <a href="#jobmodellimit">
        <code>
          JobModelLimit
        </code>
      </a>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Where each model's limit starts. A model not listed starts at 6 calls a minute, between 1 and 30.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="stallafter">
        
      </a>
      
       <code>
        stallAfter?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       How long a running job may go without a sign of life before it fails and is refunded, in ms. Default 5 minutes.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="workflow-1">
        
      </a>
      
       <code>
        workflow?
      </code>
    </td>
    
    <td>
      <code>
        WorkflowComponent
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The Workflow component the jobs run on. Default <code>
        components.workflow
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="guest-1">
        
      </a>
      
       <code>
        guest?
      </code>
    </td>
    
    <td>
      <a href="#guestjobs">
        <code>
          GuestJobs
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Let a signed-out visitor start jobs of the kinds defined with <code>
        guest: true
      </code>
      
      , after <code>
        verifyHuman
      </code>
      
       in the same mutation: free, under the <code>
        aiGlobal
      </code>
      
       limit, at the guest rank, and claimed by the account that signs up in their browser. Needs setupAi's <code>
        rateLimiter
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="onjobend-1">
        
      </a>
      
       <code>
        onJobEnd?
      </code>
    </td>
    
    <td>
      <a href="#onjobend">
        <code>
          OnJobEnd
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Hear of every job's end: done, failed, stalled, or canceled while it waited or ran, with its id, kind, args, error, run (<code>
        retries
      </code>
      
      ) and <code>
        endedAt
      </code>
      
      . Your internal mutation or action, by its reference, taking <code>
        vJobEnd
      </code>
      
      : settle what your own rows say about the job (fail its document, tell its owner) without a sweep of your own. Credits are the queue's: it lets the hold go and schedules the refund as the job ends, or, while a charge is still on its way, once that charge lands. Never settle credits here. <strong>
        Guarantee
      </strong>
      
       - Runs: as its own function, scheduled by the transaction that ended the job, once it commits - Delivery: once per run of a job, whichever way it ended, except a job erased with its owner's account, which ends unheard; a mutation runs exactly once, an action at most once - Order: after the job's row reads its end; a retried job's runs are heard in turn, <code>
        retries
      </code>
      
       counting up; ends of different jobs run in no set order - When it throws: the failure is the hook's own, in the deployment's logs; the job's end and the queue's handling of its credits stand - Idempotency: an administrator's retry runs a failed job again, and it ends again: compare <code>
        retries
      </code>
      
       with the run you last recorded, and let a later run's end win
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="onowedcharge-1">
        
      </a>
      
       <code>
        onOwedCharge?
      </code>
    </td>
    
    <td>
      <a href="#onowedcharge">
        <code>
          OnOwedCharge
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Hear how a charge the queue owed ended: a kind charged by output whose <code>
        job.charge
      </code>
      
       the provider refused for a passing reason ends <code>
        done
      </code>
      
       with <code>
        owed
      </code>
      
       on its <code>
        onJobEnd
      </code>
      
      , and the queue tries the charge again in the background. This hears it <code>
        charged
      </code>
      
       once it lands, or <code>
        given_up
      </code>
      
       after its last try, or at once when the provider refuses it in a way no try changes (a revoked access token), with the job's id, kind, args, run and the credits it owed. Your internal mutation or action, by its reference, taking <code>
        vOwedCharge
      </code>
      
      : settle what your rows say about the charge. Never move credits here. <strong>
        Guarantee
      </strong>
      
       - Runs: as its own function, scheduled by the transaction that recorded how the charge ended, once it commits - Delivery: once per owed charge that ends, <code>
        charged
      </code>
      
       or <code>
        given_up
      </code>
      
      ; an administrator's retry of a given-up charge owes it again, and it ends again - Order: after <code>
        onJobEnd
      </code>
      
       was scheduled for the run that owed it, unless the charge landed or was given up while the job still ran, when it may run first; owed charges of different jobs end in no set order - When it throws: the failure is the hook's own, in the deployment's logs; the charge's outcome stands - Idempotency: a retried charge that lands after it gave up is heard <code>
        charged
      </code>
      
       after <code>
        given_up
      </code>
      
      : let the later one win
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### JobChargeOptions

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

What `job.charge` takes beside the credits.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="metadata">
        
      </a>
      
       <code>
        metadata?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       More of your own string metadata for the usage event, such as the id of what the job made (<code>
        { stripId }
      </code>
      
      ): merged with the queue's <code>
        userId
      </code>
      
       and <code>
        job
      </code>
      
      , which win over keys of the same name. Within the billing provider's limits on a usage event: at most 47 keys (it takes 50, and the queue adds <code>
        userId
      </code>
      
      , <code>
        job
      </code>
      
       and the meter's amount), each of 1 to 40 ASCII characters, not starting with <code>
        _
      </code>
      
       (the provider's own keys, such as <code>
        _cost
      </code>
      
       and <code>
        _llm
      </code>
      
      ) or <code>
        $
      </code>
      
      , and values of at most 500 characters. <code>
        job.charge
      </code>
      
       throws a <code>
        TypeError
      </code>
      
       past them.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### JobContext

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

What a job's handler gets: its id, and the durable calls it orders.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id-2">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The job's id.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="run">
        
      </a>
      
       <code>
        run
      </code>
    </td>
    
    <td>
      <<code>
        Step
      </code>
      
      >(<code>
        step
      </code>
      
      , <code>
        args
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#stepresult">
        <code>
          StepResult
        </code>
      </a>
      
      <<code>
        Step
      </code>
      
      [<code>
        "_returnType"
      </code>
      
      ]>>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Run a step and return what it returned. A step that finds no free turn at its model, or answers <code>
        429
      </code>
      
      , a timeout or a passing provider error, is waited for and run again, up to 4 attempts.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="progress">
        
      </a>
      
       <code>
        progress
      </code>
    </td>
    
    <td>
      (<code>
        progress
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Report how far the job got: <code>
        useJob
      </code>
      
       shows it, and it tells the queue the job is alive.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="charge-1">
        
      </a>
      
       <code>
        charge
      </code>
    </td>
    
    <td>
      (<code>
        credits
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Charge what the job made, for a kind defined with <code>
        charge: 'output'
      </code>
      
      : <code>
        credits
      </code>
      
      , at most the <code>
        cost
      </code>
      
       held when it joined; the rest of the hold goes back unbilled. Once: a later call changes nothing. A job that fails after it is refunded what it was charged. Throws in a kind that charges at start; does nothing in a job put in line <code>
        { free: true }
      </code>
      
      . A balance short of the credits fails the job. A refusal that may pass (the provider down or rate limiting, no billing customer yet) leaves the charge owed: the job runs on and ends <code>
        done
      </code>
      
      , its hold stays taken, and the queue tries the charge again in the background (<code>
        onOwedCharge
      </code>
      
      ). A billing provider that refuses the charge itself, such as a revoked access token, gives it up at once: the job runs on and ends <code>
        done
      </code>
      
       uncharged, its hold back, <code>
        onOwedCharge
      </code>
      
       hears <code>
        given_up
      </code>
      
      , and <code>
        ai.job_charge_refused
      </code>
      
       is logged. <code>
        metadata
      </code>
      
       goes on the usage event beside the queue's own, within the provider's limits (<a href="#metadata">
        JobChargeOptions.metadata
      </a>
      
      ): past them, <code>
        job.charge
      </code>
      
       throws.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### JobDefinition

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

A kind of job: `jobs.define`.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-args-5">
        
      </a>
      
       <code>
        Args
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        PropertyValidators
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-result-4">
        
      </a>
      
       <code>
        Result
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="meter-5">
        
      </a>
      
       <code>
        meter
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        false
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The credit meter its price is held from and charged to, or <code>
        false
      </code>
      
       for a free job.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cost-4">
        
      </a>
      
       <code>
        cost?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
      
       | ((<code>
        args
      </code>
      
      ) => <code>
        number
      </code>
      
      )
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Its price in credits: a number, or read from the args once when it joins. Default <code>
        1
      </code>
      
      . With <code>
        charge: 'output'
      </code>
      
      , the most it may cost: what is held while it waits and runs.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="charge-2">
        
      </a>
      
       <code>
        charge?
      </code>
    </td>
    
    <td>
      <code>
        "output"
      </code>
      
       | <code>
        "start"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       When its credits are charged: <code>
        'start'
      </code>
      
       (the default), the whole <code>
        cost
      </code>
      
       as its first step; or <code>
        'output'
      </code>
      
      , what the handler passes to <code>
        job.charge(n)
      </code>
      
       once it knows what it made, the hold taken again as its first step. An <code>
        'output'
      </code>
      
       job that ends without <code>
        job.charge
      </code>
      
      , or fails, or is canceled before it, costs nothing.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="guest-2">
        
      </a>
      
       <code>
        guest?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A signed-out visitor may start it too (<code>
        defineJobQueue({ guest })
      </code>
      
      ): free for them, the app pays. A member who starts it pays as for any other kind.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="moderate-4">
        
      </a>
      
       <code>
        moderate?
      </code>
    </td>
    
    <td>
      (<code>
        args
      </code>
      
      ) => <a href="#moderationinput">
        <code>
          ModerationInput
        </code>
      </a>
      
       & <code>
        Pick
      </code>
      
      <<a href="#moderationsubject">
        <code>
          ModerationSubject
        </code>
      </a>
      
      , <code>
        "subject"
      </code>
      
       | <code>
        "stage"
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       What to check with the safety classifier (<code>
        setupAi({ moderation })
      </code>
      
      ), from the args: as the job's first step, before the charge. A job the policy blocks fails with <code>
        invalid_input
      </code>
      
      , reason <code>
        content_blocked
      </code>
      
      , and its hold is released; one flagged in a category the policy lets through runs, recorded. Its flag names the job and its starter; add <code>
        subject
      </code>
      
       and <code>
        stage
      </code>
      
       to name them in your words.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="args-4">
        
      </a>
      
       <code>
        args
      </code>
    </td>
    
    <td>
      <code>
        Args
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="handler-2">
        
      </a>
      
       <code>
        handler
      </code>
    </td>
    
    <td>
      (<code>
        job
      </code>
      
      , <code>
        args
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Result
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The steps, in order. Runs as a durable workflow: read data and call models in steps, never here.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### JobStepContext

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

What a step's handler gets beside the action context.

#### Extends

- [`ImageStoreContext`](#imagestorecontext)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Inherited from
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="model-6">
        
      </a>
      
       <code>
        model
      </code>
    </td>
    
    <td>
      (<code>
        model?
      </code>
      
      ) => <code>
        LanguageModelV4
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The model to call: the step's own, or another by id or object.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="image">
        
      </a>
      
       <code>
        image
      </code>
    </td>
    
    <td>
      (<code>
        model?
      </code>
      
      ) => <code>
        ImageModelV4
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The image model to call with the AI SDK's <code>
        generateImage
      </code>
      
      : the step's own, or another by id or object. Through the same route as <code>
        ctx.model()
      </code>
      
       (<code>
        setupAi({ routes })
      </code>
      
       included), and metered the same way: its cost counts in the job's cost report, the Costs tab and <code>
        spendLimit
      </code>
      
      , and <code>
        ctx.storeImage
      </code>
      
       names it in the image's provenance.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="signal">
        
      </a>
      
       <code>
        signal
      </code>
    </td>
    
    <td>
      <code>
        AbortSignal
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Aborted when the step's <code>
        timeout
      </code>
      
       runs out: every <code>
        ctx.model()
      </code>
      
       and <code>
        ctx.image()
      </code>
      
       call gets it unless it brings its own.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="callsettings">
        
      </a>
      
       <code>
        callSettings
      </code>
    </td>
    
    <td>
      { <code>
        maxRetries
      </code>
      
      : <code>
        0
      </code>
      
      ; <code>
        abortSignal
      </code>
      
      : <code>
        AbortSignal
      </code>
      
      ; }
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Settings to spread into <code>
        generateText
      </code>
      
      , <code>
        streamText
      </code>
      
       or <code>
        generateImage
      </code>
      
      : no retries of the AI SDK's own (the queue retries the step, under the model's limit), and the step's <code>
        signal
      </code>
      
      .
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        callSettings.maxRetries
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        callSettings.abortSignal
      </code>
    </td>
    
    <td>
      <code>
        AbortSignal
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="job">
        
      </a>
      
       <code>
        job
      </code>
    </td>
    
    <td>
      <a href="#stepjob">
        <code>
          StepJob
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The job it runs for, which attempt this is, and who it is for: its <code>
        owner
      </code>
      
      , the billing entity that pays (a workspace, an account under <code>
        billTo: 'user'
      </code>
      
      , <code>
        guest:<visitor>
      </code>
      
       or <code>
        app
      </code>
      
      ), and <code>
        userId
      </code>
      
      , the account that started it, when somebody signed in did. <code>
        ai.moderate
      </code>
      
       and <code>
        ai.requireSafe
      </code>
      
       called in the step name them on a flag unless told otherwise.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="storeimage-1">
        
      </a>
      
       <code>
        storeImage
      </code>
    </td>
    
    <td>
      (<code>
        file
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Id
      </code>
      
      <<code>
        "_storage"
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Store an image a model made, with its content credentials: the IPTC source type in its XMP, a C2PA manifest signed with <code>
        PROVENANCE_PRIVATE_KEY
      </code>
      
      , and a provenance record of the models, the time and <code>
        inputs
      </code>
      
      . The image is kept in the <code>
        backend
      </code>
      
       component's storage as the job's owner's (the run's billing entity in a metered action), like an upload <code>
        storage.claim
      </code>
      
       kept: counted in the quota, listed in the owner's export and deleted with it. Resolves with its id there, typed as a storage id: read its URL through <code>
        storage.fileUrl
      </code>
      
      , <code>
        storage.signedUrl
      </code>
      
       or <code>
        getFileUrl
      </code>
      
      , never <code>
        ctx.storage.getUrl
      </code>
      
      , and delete it with <code>
        storage.release
      </code>
      
      .
    </td>
    
    <td>
      <a href="#imagestorecontext">
        <code>
          ImageStoreContext
        </code>
      </a>
      
      .<a href="#storeimage-2">
        <code>
          storeImage
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/provenance.ts" rel="nofollow">
        src/convex/integrations/ai/provenance.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### StepJob

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

The job a step runs for, as `ctx.job` names it.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id-3">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="attempt">
        
      </a>
      
       <code>
        attempt
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="owner">
        
      </a>
      
       <code>
        owner
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="userid-3">
        
      </a>
      
       <code>
        userId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### JobStepDefinition

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

A step of a job: `jobs.step`.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-args-6">
        
      </a>
      
       <code>
        Args
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        PropertyValidators
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-result-5">
        
      </a>
      
       <code>
        Result
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="model-7">
        
      </a>
      
       <code>
        model?
      </code>
    </td>
    
    <td>
      <code>
        LanguageModel
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The model its calls go to, a language or an image model's id: the step takes a turn from this model's limit before it runs, and <code>
        ctx.model()
      </code>
      
       or <code>
        ctx.image()
      </code>
      
       calls it when named no other.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="timeout">
        
      </a>
      
       <code>
        timeout?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       How long its model calls may run, in ms, before they are aborted and the attempt is tried again as a timeout. Default 3 minutes, or 80% of <code>
        stallAfter
      </code>
      
       when that is less; it must be shorter than <code>
        stallAfter
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="args-5">
        
      </a>
      
       <code>
        args
      </code>
    </td>
    
    <td>
      <code>
        Args
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="handler-3">
        
      </a>
      
       <code>
        handler
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        args
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Result
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### JobOwed

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

A charge a job still owes ([JobView.owed](https://nuxt-backend.dev/docs/reference/api/use-job#owed)).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="credits-2">
        
      </a>
      
       <code>
        credits
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="givenup">
        
      </a>
      
       <code>
        givenUp
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### JobRecord

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

A job as `jobs.get` reads it for your own functions: `getJob`'s view, with who owns it and its args.

#### Extends

- `Omit`<[`JobView`](https://nuxt-backend.dev/docs/reference/api/use-job#jobview), `"canCancel"`>

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Inherited from
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id-4">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#id">
        <code>
          id
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="kind-2">
        
      </a>
      
       <code>
        kind
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#kind">
        <code>
          kind
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="status-3">
        
      </a>
      
       <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        "failed"
      </code>
      
       | <code>
        "canceled"
      </code>
      
       | <code>
        "running"
      </code>
      
       | <code>
        "queued"
      </code>
      
       | <code>
        "done"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#status">
        <code>
          status
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="waitingon">
        
      </a>
      
       <code>
        waitingOn?
      </code>
    </td>
    
    <td>
      <code>
        "owner"
      </code>
      
       | <code>
        "paused"
      </code>
      
       | <code>
        "line"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#waitingon">
        <code>
          waitingOn
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="position">
        
      </a>
      
       <code>
        position?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#position">
        <code>
          position
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="estimatedwait">
        
      </a>
      
       <code>
        estimatedWait?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#estimatedwait">
        <code>
          estimatedWait
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="progress-1">
        
      </a>
      
       <code>
        progress?
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobprogress">
        <code>
          JobProgress
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#progress">
        <code>
          progress
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="result">
        
      </a>
      
       <code>
        result?
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#result">
        <code>
          result
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="error-1">
        
      </a>
      
       <code>
        error?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Why it failed, as a catalog error payload: <code>
        { code, ...fields }
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#error">
        <code>
          error
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="joinedat">
        
      </a>
      
       <code>
        joinedAt
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#joinedat">
        <code>
          joinedAt
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="startedat">
        
      </a>
      
       <code>
        startedAt?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#startedat">
        <code>
          startedAt
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="endedat-1">
        
      </a>
      
       <code>
        endedAt?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#endedat">
        <code>
          endedAt
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="provenance-1">
        
      </a>
      
       <code>
        provenance?
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobprovenance">
        <code>
          JobProvenance
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       What made its result, once it is <code>
        done
      </code>
      
       and <code>
        setupAi({ provenance })
      </code>
      
       is on: the models its steps called, when it finished, and the ids of the inputs its <code>
        ctx.storeImage
      </code>
      
       calls named.
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#provenance">
        <code>
          provenance
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="charged-1">
        
      </a>
      
       <code>
        charged
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The credits it was charged so far: its <code>
        cost
      </code>
      
       once charged at start, what <code>
        job.charge
      </code>
      
       charged for a kind charged by output, <code>
        0
      </code>
      
       before a charge. A failed or canceled job's refund may still be on its way.
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#charged">
        <code>
          charged
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="free-1">
        
      </a>
      
       <code>
        free
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Put in line <code>
        { free: true }
      </code>
      
      : it holds, charges and counts nothing.
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#free">
        <code>
          free
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="owed-1">
        
      </a>
      
       <code>
        owed?
      </code>
    </td>
    
    <td>
      <a href="#jobowed">
        <code>
          JobOwed
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A charge it still owes, for a kind charged by output whose <code>
        job.charge
      </code>
      
       the provider refused: the credits, and whether the queue gave up trying (<code>
        givenUp
      </code>
      
      , after its last try or at once for a refusal no try changes) or still tries. <code>
        charged
      </code>
      
       reads <code>
        0
      </code>
      
       until it lands. Absent when nothing is owed.
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
      .<a href="https://nuxt-backend.dev/docs/reference/api/use-job#owed">
        <code>
          owed
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="owner-1">
        
      </a>
      
       <code>
        owner
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Who pays for it: a billing entity, <code>
        guest:<visitor>
      </code>
      
       or <code>
        app
      </code>
      
      .
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="userid-4">
        
      </a>
      
       <code>
        userId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Who put it in line, when somebody signed in did.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="args-6">
        
      </a>
      
       <code>
        args
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The args it was put in line with.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CancelOptions

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

What `jobs.cancel` takes.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="refund">
        
      </a>
      
       <code>
        refund?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Give a running job's charged credits back as well. Default <code>
        false
      </code>
      
      : a running job stays charged for what it made so far.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AdminJobView

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

A job as the admin console lists it.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id-5">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="kind-3">
        
      </a>
      
       <code>
        kind
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="owner-2">
        
      </a>
      
       <code>
        owner
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="userid-5">
        
      </a>
      
       <code>
        userId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="tier">
        
      </a>
      
       <code>
        tier?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="status-4">
        
      </a>
      
       <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        "failed"
      </code>
      
       | <code>
        "canceled"
      </code>
      
       | <code>
        "running"
      </code>
      
       | <code>
        "queued"
      </code>
      
       | <code>
        "done"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="guest-3">
        
      </a>
      
       <code>
        guest
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A job a signed-out visitor started: <code>
        owner
      </code>
      
       is <code>
        guest:<visitor>
      </code>
      
       until a sign-up claims it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="attempts">
        
      </a>
      
       <code>
        attempts
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="retries-2">
        
      </a>
      
       <code>
        retries
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cost-5">
        
      </a>
      
       <code>
        cost
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="price">
        
      </a>
      
       <code>
        price?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       What <code>
        job.charge
      </code>
      
       charged, for a kind charged by output.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="owed-2">
        
      </a>
      
       <code>
        owed?
      </code>
    </td>
    
    <td>
      <a href="#jobowed">
        <code>
          JobOwed
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A charge it still owes (<a href="https://nuxt-backend.dev/docs/reference/api/use-job#owed">
        JobView.owed
      </a>
      
      ): an administrator's retry tries a given-up one again.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="joinedat-1">
        
      </a>
      
       <code>
        joinedAt
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="startedat-1">
        
      </a>
      
       <code>
        startedAt?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="endedat-2">
        
      </a>
      
       <code>
        endedAt?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="error-2">
        
      </a>
      
       <code>
        error?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="lasterror">
        
      </a>
      
       <code>
        lastError?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The provider's own text for the last failed attempt, cut to 500 characters.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="deadletter">
        
      </a>
      
       <code>
        deadLetter
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### QueueChange

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

What `setQueue` takes. Each tier field takes `null` to go back to `backend/jobs.ts`.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="paused">
        
      </a>
      
       <code>
        paused?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="concurrency-1">
        
      </a>
      
       <code>
        concurrency?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="tier-1">
        
      </a>
      
       <code>
        tier?
      </code>
    </td>
    
    <td>
      { <code>
        name
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        perOwner?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        dedicated?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        budget?
      </code>
      
      : | { <code>
        units
      </code>
      
      : <code>
        number
      </code>
      
      ; } | <code>
        null
      </code>
      
      ; }
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        tier.name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        tier.perOwner?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        tier.dedicated?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        tier.budget?
      </code>
    </td>
    
    <td>
      | { <code>
        units
      </code>
      
      : <code>
        number
      </code>
      
      ; } | <code>
        null
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="model-8">
        
      </a>
      
       <code>
        model?
      </code>
    </td>
    
    <td>
      { <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        perMinute?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        min?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        max?
      </code>
      
      : <code>
        number
      </code>
      
      ; }
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        model.id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        model.perMinute?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        model.min?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        model.max?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### JobQueueApi

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

The functions behind `useJob()` and the admin console's Queue tab, to re-export from `backend/jobs.ts`.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="getjob">
        
      </a>
      
       <code>
        getJob
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        jobId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<a href="https://nuxt-backend.dev/docs/reference/api/use-job#jobview">
        <code>
          JobView
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="canceljob">
        
      </a>
      
       <code>
        cancelJob
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        jobId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        refund?
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="getqueue">
        
      </a>
      
       <code>
        getQueue
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        Promise
      </code>
      
      <<code>
        unknown
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="listjobs">
        
      </a>
      
       <code>
        listJobs
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        paginationOpts
      </code>
      
      : { <code>
        numItems
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        cursor
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; }; <code>
        deadLetters?
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        unknown
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="setqueue">
        
      </a>
      
       <code>
        setQueue
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "public"
      </code>
      
      , <a href="#queuechange">
        <code>
          QueueChange
        </code>
      </a>
      
       & <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      >, <code>
        Promise
      </code>
      
      <<code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="retryjob">
        
      </a>
      
       <code>
        retryJob
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        jobId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="discardjob">
        
      </a>
      
       <code>
        discardJob
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        jobId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="runqueue">
        
      </a>
      
       <code>
        runQueue
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "internal"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      >, <code>
        Promise
      </code>
      
      <<code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Internal: the pick, the stall sweep, a job's progress and each job's end.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="billjob">
        
      </a>
      
       <code>
        billJob
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "internal"
      </code>
      
      , { <code>
        op
      </code>
      
      : <code>
        "report"
      </code>
      
       | <code>
        "owed"
      </code>
      
       | <code>
        "refund"
      </code>
      
       | <code>
        "charge"
      </code>
      
       | <code>
        "hold"
      </code>
      
       | <code>
        "moderate"
      </code>
      
      ; <code>
        jobId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        attempt?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        amount?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        metadata?
      </code>
      
      : <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
      >; <code>
        input?
      </code>
      
      : <a href="#moderationinput">
        <code>
          ModerationInput
        </code>
      </a>
      
       & <code>
        Pick
      </code>
      
      <<a href="#moderationsubject">
        <code>
          ModerationSubject
        </code>
      </a>
      
      , <code>
        "subject"
      </code>
      
       | <code>
        "stage"
      </code>
      
      >; }, <code>
        Promise
      </code>
      
      < | { <code>
        blocked
      </code>
      
      : <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      >; } | { <code>
        wait
      </code>
      
      : <code>
        number
      </code>
      
      ; } | <code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Internal: a job's charge, refund and cost report.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### EnqueueOptions

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

What `jobs.enqueue` takes beside the kind and its args.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="billto-1">
        
      </a>
      
       <code>
        billTo?
      </code>
    </td>
    
    <td>
      <code>
        "app"
      </code>
      
       | <code>
        "entity"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Who owns and pays for the job: the caller's billing entity (<code>
        'entity'
      </code>
      
      , the default), or the app itself (<code>
        'app'
      </code>
      
      , a <code>
        meter: false
      </code>
      
       kind).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="free-2">
        
      </a>
      
       <code>
        free?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Run this one job of a metered kind for nothing: it holds no credits, is never charged and counts in no tier's budget. Your mutation decides who gets it, such as a plan's monthly free generation.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### JobQueue

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

The queue `defineJobQueue` returns.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="define">
        
      </a>
      
       <code>
        define
      </code>
    </td>
    
    <td>
      <<code>
        Args
      </code>
      
      , <code>
        Result
      </code>
      
      >(<code>
        definition
      </code>
      
      ) => <code>
        RegisteredMutation
      </code>
      
      <<code>
        "internal"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      >, <code>
        Promise
      </code>
      
      <<code>
        unknown
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Declare a kind of job. Export it: Convex registers it by name.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="step">
        
      </a>
      
       <code>
        step
      </code>
    </td>
    
    <td>
      <<code>
        Args
      </code>
      
      , <code>
        Result
      </code>
      
      >(<code>
        definition
      </code>
      
      ) => <code>
        RegisteredAction
      </code>
      
      <<code>
        "internal"
      </code>
      
      , <code>
        ObjectType
      </code>
      
      <<code>
        Args
      </code>
      
      > & { <code>
        queuedJob?
      </code>
      
      : { <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        attempt
      </code>
      
      : <code>
        number
      </code>
      
      ; }; }, <code>
        Promise
      </code>
      
      < | <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      > | { <code>
        value
      </code>
      
      : <code>
        Result
      </code>
      
      ; }>>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Declare a step a job runs: an internal action whose <code>
        ctx.model()
      </code>
      
       calls its model. Export it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="enqueue">
        
      </a>
      
       <code>
        enqueue
      </code>
    </td>
    
    <td>
      <<code>
        Kind
      </code>
      
      >(<code>
        ctx
      </code>
      
      , <code>
        job
      </code>
      
      , <code>
        args
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <{ <code>
        jobId
      </code>
      
      : <code>
        string
      </code>
      
      ; }>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Put a job in line from a mutation of yours: checks the caller, the <code>
        pause_ai
      </code>
      
       switch, the model route, the <code>
        ai
      </code>
      
       limit, the tier's budget and the credits, in that order; a refusal throws and rolls the mutation back. Resolves with the job's id. <code>
        { billTo: 'app' }
      </code>
      
       puts in line a job the app runs for itself, such as content it seeds for everyone: a <code>
        meter: false
      </code>
      
       kind, owned by the app rather than the caller's billing entity, with nobody signed in needed. It checks <code>
        pause_ai
      </code>
      
      , the model route and the <code>
        aiGlobal
      </code>
      
       limit, counts in no budget, and the images its steps store are the app's: in no account's quota, export or erasure, read with <code>
        storage.fileUrl
      </code>
      
       and deleted with <code>
        storage.release
      </code>
      
      . Decide in your mutation who may start it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="get">
        
      </a>
      
       <code>
        get
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        jobId
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#jobrecord">
        <code>
          JobRecord
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Read a job from a query or mutation of yours, whoever owns it: <code>
        getJob
      </code>
      
      's view, with its owner and args, and its place in line while it waits. <code>
        null
      </code>
      
       for an id that is no job. Decide in your function who may see it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cancel">
        
      </a>
      
       <code>
        cancel
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        jobId
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        "running"
      </code>
      
       | <code>
        "queued"
      </code>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Cancel a job from a mutation of yours, whoever started it: a waiting job leaves the line and its hold goes back; a running one stops after its current step, charged unless <code>
        refund
      </code>
      
      . Resolves with how it was, or <code>
        null
      </code>
      
       for a job that had already ended or is none. <code>
        onJobEnd
      </code>
      
       hears of the end. Decide in your mutation who may cancel it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="api-1">
        
      </a>
      
       <code>
        api
      </code>
    </td>
    
    <td>
      <a href="#jobqueueapi">
        <code>
          JobQueueApi
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### KnowledgeDocument

Defined in: [src/convex/integrations/ai/knowledge.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts)

**Experimental**

A document of a knowledge store, as the page lists it.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id-6">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="title-1">
        
      </a>
      
       <code>
        title
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="status-5">
        
      </a>
      
       <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        "failed"
      </code>
      
       | <code>
        "pending"
      </code>
      
       | <code>
        "ready"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       <code>
        pending
      </code>
      
       while its passages are embedded, <code>
        ready
      </code>
      
       once it is found, <code>
        failed
      </code>
      
       when it could not be (nothing was charged).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="addedby">
        
      </a>
      
       <code>
        addedBy
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The member who added it; empty for the app's own.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="createdat">
        
      </a>
      
       <code>
        createdAt
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       When it was added, in ms.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### KnowledgePassage

Defined in: [src/convex/integrations/ai/knowledge.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts)

**Experimental**

One passage a search found.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="text-2">
        
      </a>
      
       <code>
        text
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="score">
        
      </a>
      
       <code>
        score
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       How close it is to the question, from 0 to 1.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="document">
        
      </a>
      
       <code>
        document
      </code>
    </td>
    
    <td>
      { <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        title
      </code>
      
      : <code>
        string
      </code>
      
      ; }
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        document.id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        document.title
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### KnowledgeConfig

Defined in: [src/convex/integrations/ai/knowledge.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts)

**Experimental**

What `ai.knowledge` takes.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="model-9">
        
      </a>
      
       <code>
        model
      </code>
    </td>
    
    <td>
      <a href="#aiembeddingmodel">
        <code>
          AiEmbeddingModel
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The embedding model: a <code>
        provider/model
      </code>
      
       id from the gateway's model list, or an AI SDK embedding model of your own.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="dimension">
        
      </a>
      
       <code>
        dimension
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The length of the model's vectors: <code>
        1536
      </code>
      
       for <code>
        openai/text-embedding-3-small
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meter-6">
        
      </a>
      
       <code>
        meter
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        false
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The credit meter adding and searching are charged to; <code>
        false
      </code>
      
       makes both free.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cost-6">
        
      </a>
      
       <code>
        cost?
      </code>
    </td>
    
    <td>
      { <code>
        add?
      </code>
      
      : <a href="#knowledgeaddcost">
        <code>
          KnowledgeAddCost
        </code>
      </a>
      
      ; <code>
        search?
      </code>
      
      : <code>
        number
      </code>
      
      ; }
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       What adding and searching cost, in credits. Default <code>
        { add: 1, search: 1 }
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        cost.add?
      </code>
    </td>
    
    <td>
      <a href="#knowledgeaddcost">
        <code>
          KnowledgeAddCost
        </code>
      </a>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        cost.search?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="limit-5">
        
      </a>
      
       <code>
        limit?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        false
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The named rate limit adding and searching count against. Default <code>
        'ai'
      </code>
      
      ; <code>
        false
      </code>
      
       disables it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### KnowledgeApi

Defined in: [src/convex/integrations/ai/knowledge.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts)

**Experimental**

The functions a page calls, and the embedding `add` schedules: export each from the store's module, by these names.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="documents">
        
      </a>
      
       <code>
        documents
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        paginationOpts
      </code>
      
      : { <code>
        numItems
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        cursor
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; }; }, <code>
        Promise
      </code>
      
      <{ <code>
        page
      </code>
      
      : <a href="#knowledgedocument">
        <code>
          KnowledgeDocument
        </code>
      </a>
      
      <span>
        
      </span>
      
      ; <code>
        isDone
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        continueCursor
      </code>
      
      : <code>
        string
      </code>
      
      ; }>>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The active workspace's documents, newest first, paginated.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="add">
        
      </a>
      
       <code>
        add
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        title
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        text?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        storageId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        key?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        string
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Add a document from <code>
        { title, text }
      </code>
      
       or <code>
        { title, storageId }
      </code>
      
      , optionally under a <code>
        key
      </code>
      
       that replaces the older one, and return its id.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="search">
        
      </a>
      
       <code>
        search
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        query
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        limit?
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <{ <code>
        passages
      </code>
      
      : <a href="#knowledgepassage">
        <code>
          KnowledgePassage
        </code>
      </a>
      
      <span>
        
      </span>
      
      ; }>>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Search the active workspace's documents for <code>
        { query, limit? }
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="remove-1">
        
      </a>
      
       <code>
        remove
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        documentId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Remove a document: the member who added it, or the workspace's owners and admins.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="embed">
        
      </a>
      
       <code>
        embed
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "internal"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      >, <code>
        Promise
      </code>
      
      <<code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The embedding <code>
        add
      </code>
      
       schedules, by this name next to itself. Internal.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### Knowledge

Defined in: [src/convex/integrations/ai/knowledge.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts)

**Experimental**

A knowledge store: its `api`, and `add` for your server code.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="api-2">
        
      </a>
      
       <code>
        api
      </code>
    </td>
    
    <td>
      <a href="#knowledgeapi">
        <code>
          KnowledgeApi
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="add-1">
        
      </a>
      
       <code>
        add
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        document
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <{ <code>
        documentId
      </code>
      
      : <code>
        string
      </code>
      
      ; }>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Add a document from server code, charging no one: to the app's own namespace (<code>
        'app'
      </code>
      
      ), which chats the app pays for search, or to a billing entity's by its id. Embeds at once, in this action. A <code>
        key
      </code>
      
       replaces the document added under it before.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts" rel="nofollow">
        src/convex/integrations/ai/knowledge.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ModerationImage

Defined in: [src/convex/integrations/ai/moderation-providers.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts)

**Experimental**

An image a provider reads: its bytes and media type, read once from storage.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="bytes">
        
      </a>
      
       <code>
        bytes
      </code>
    </td>
    
    <td>
      <code>
        Uint8Array
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="mediatype">
        
      </a>
      
       <code>
        mediaType
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ProviderInput

Defined in: [src/convex/integrations/ai/moderation-providers.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts)

**Experimental**

What a provider is asked to read.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="text-3">
        
      </a>
      
       <code>
        text?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="images">
        
      </a>
      
       <code>
        images
      </code>
    </td>
    
    <td>
      <a href="#moderationimage">
        <code>
          ModerationImage
        </code>
      </a>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="stage">
        
      </a>
      
       <code>
        stage?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Where the content is checked (<code>
        upload
      </code>
      
      , <code>
        output
      </code>
      
      …), for a refusal that names it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ModerationProvider

Defined in: [src/convex/integrations/ai/moderation-providers.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts)

**Experimental**

A provider that scores content in the shared categories.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Modifier
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="kind-4">
        
      </a>
      
       <code>
        kind
      </code>
    </td>
    
    <td>
      <code>
        readonly
      </code>
    </td>
    
    <td>
      <code>
        "classifier"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="id-7">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        readonly
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Its id, as a decision records it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="reads">
        
      </a>
      
       <code>
        reads
      </code>
    </td>
    
    <td>
      <code>
        readonly
      </code>
    </td>
    
    <td>
      readonly (<code>
        "text"
      </code>
      
       | <code>
        "image"
      </code>
      
      )<span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       What it reads.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="imagecategories">
        
      </a>
      
       <code>
        imageCategories?
      </code>
    </td>
    
    <td>
      <code>
        readonly
      </code>
    </td>
    
    <td>
      readonly <a href="#moderationcategory">
        <code>
          ModerationCategory
        </code>
      </a>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The categories it judges in an image. One it leaves out reads as not judged; without <code>
        minors_sexual
      </code>
      
       here, <code>
        setupAi
      </code>
      
       asks the classifier about the images for it, and has <code>
        block
      </code>
      
       cover <code>
        sexual
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="env">
        
      </a>
      
       <code>
        env
      </code>
    </td>
    
    <td>
      <code>
        readonly
      </code>
    </td>
    
    <td>
      readonly <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The deployment env names it needs: what doctor checks.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="region">
        
      </a>
      
       <code>
        region?
      </code>
    </td>
    
    <td>
      <code>
        readonly
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Where it processes content, as the app declares it: named in the record and checked by doctor.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="check">
        
      </a>
      
       <code>
        check
      </code>
    </td>
    
    <td>
      <code>
        public
      </code>
    </td>
    
    <td>
      (<code>
        input
      </code>
      
      , <code>
        env
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#providerreading">
        <code>
          ProviderReading
        </code>
      </a>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Read the content, or refuse <code>
        unavailable
      </code>
      
       when the provider cannot.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### KnownAbuseProvider

Defined in: [src/convex/integrations/ai/moderation-providers.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts)

**Experimental**

A known-abuse hash match: whether an image is on a list of known abuse material.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Modifier
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="kind-5">
        
      </a>
      
       <code>
        kind
      </code>
    </td>
    
    <td>
      <code>
        readonly
      </code>
    </td>
    
    <td>
      <code>
        "known-abuse"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="id-8">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        readonly
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="env-1">
        
      </a>
      
       <code>
        env
      </code>
    </td>
    
    <td>
      <code>
        readonly
      </code>
    </td>
    
    <td>
      readonly <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="region-1">
        
      </a>
      
       <code>
        region?
      </code>
    </td>
    
    <td>
      <code>
        readonly
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="match">
        
      </a>
      
       <code>
        match
      </code>
    </td>
    
    <td>
      <code>
        public
      </code>
    </td>
    
    <td>
      (<code>
        image
      </code>
      
      , <code>
        env
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <{ <code>
        matched
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        code?
      </code>
      
      : <code>
        string
      </code>
      
      ; }>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Match one image's bytes against the list: its hash, kept as evidence, and whether it matched.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AzureContentSafetyOptions

Defined in: [src/convex/integrations/ai/moderation-providers.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts)

**Experimental**

Options of [azureContentSafety](#azurecontentsafety).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="region-2">
        
      </a>
      
       <code>
        region
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The Azure region your Content Safety resource runs in, such as <code>
        francecentral
      </code>
      
      : recorded with each decision, and checked by doctor against an app that keeps its processing in the EU.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-providers.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CategoryScore

Defined in: [src/convex/integrations/ai/moderation-taxonomy.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-taxonomy.ts)

**Experimental**

One category's reading: how strongly it was found, from 0 to 1, and whether it could be judged at all.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="score-1">
        
      </a>
      
       <code>
        score
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-taxonomy.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-taxonomy.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="supported">
        
      </a>
      
       <code>
        supported
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-taxonomy.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-taxonomy.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ProviderReading

Defined in: [src/convex/integrations/ai/moderation-taxonomy.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-taxonomy.ts)

**Experimental**

What one provider read in the content: a score per category it reports, and its own codes for what it found.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="provider">
        
      </a>
      
       <code>
        provider
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The provider, as <code>
        setupAi({ moderation })
      </code>
      
       names it: <code>
        azure-content-safety
      </code>
      
      , <code>
        openai-moderation
      </code>
      
      , <code>
        llama-guard
      </code>
      
      …
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-taxonomy.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-taxonomy.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="scores">
        
      </a>
      
       <code>
        scores
      </code>
    </td>
    
    <td>
      <code>
        Partial
      </code>
      
      <<code>
        Record
      </code>
      
      <<a href="#moderationcategory">
        <code>
          ModerationCategory
        </code>
      </a>
      
      , <a href="#categoryscore">
        <code>
          CategoryScore
        </code>
      </a>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-taxonomy.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-taxonomy.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="codes">
        
      </a>
      
       <code>
        codes
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The provider's own codes for what it found, such as <code>
        S12
      </code>
      
       or <code>
        Sexual:4
      </code>
      
      ; empty when nothing was.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-taxonomy.ts" rel="nofollow">
        src/convex/integrations/ai/moderation-taxonomy.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ModerationInput

Defined in: [src/convex/integrations/ai/moderation.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts)

**Experimental**

What to check: text, and images as file storage ids.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="text-4">
        
      </a>
      
       <code>
        text?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The text a person wrote: a prompt, a caption, a message.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="images-1">
        
      </a>
      
       <code>
        images?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Images, as file storage ids: an upload (claimed or not) or a file the app stored.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ModerationVerdict

Defined in: [src/convex/integrations/ai/moderation.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts)

**Experimental**

What the providers said, and what the app's policy makes of it. An
escalated verdict is always blocked too: content an administrator is to
look at is held back, never published while it waits.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="flagged">
        
      </a>
      
       <code>
        flagged
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Whether it found anything: a category at its threshold, or a classifier's code.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="categories">
        
      </a>
      
       <code>
        categories
      </code>
    </td>
    
    <td>
      <a href="#moderationcategory">
        <code>
          ModerationCategory
        </code>
      </a>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The shared categories at or above their threshold (<code>
        sexual
      </code>
      
      , <code>
        violence
      </code>
      
      …); empty when none is.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="codes-1">
        
      </a>
      
       <code>
        codes
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The providers' own codes for what they found, such as Llama Guard's <code>
        S1
      </code>
      
       to <code>
        S14
      </code>
      
       or Azure's <code>
        Sexual:4
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="scores-1">
        
      </a>
      
       <code>
        scores
      </code>
    </td>
    
    <td>
      <code>
        Partial
      </code>
      
      <<code>
        Record
      </code>
      
      <<a href="#moderationcategory">
        <code>
          ModerationCategory
        </code>
      </a>
      
      , <a href="#categoryscore">
        <code>
          CategoryScore
        </code>
      </a>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The combined score per shared category, and whether any provider could judge it for this content.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="providers">
        
      </a>
      
       <code>
        providers
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Every provider the check asked, in order.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="knownabuse">
        
      </a>
      
       <code>
        knownAbuse?
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A known-abuse match (<code>
        moderation.knownAbuse
      </code>
      
      ): blocked and escalated whatever the policy says.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="blocked">
        
      </a>
      
       <code>
        blocked
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Whether the policy refuses it (<code>
        moderation.block
      </code>
      
      , or an escalated category): what <code>
        requireSafe
      </code>
      
       throws on.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="escalate">
        
      </a>
      
       <code>
        escalate
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Whether it falls in a category the policy has an administrator look at (<code>
        moderation.escalate
      </code>
      
      ): blocked as well, and recorded.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ModerationSubject

Defined in: [src/convex/integrations/ai/moderation.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts)

**Experimental**

What a check was about, for the flag it records: who the content came from, and what and where.

#### Extended by

- [`ModerationFlag`](#moderationflag)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="userid-6">
        
      </a>
      
       <code>
        userId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The account the content came from. Default: who is signed in, or in a job's step (<code>
        jobs.step
      </code>
      
      ), who started the job.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="owner-3">
        
      </a>
      
       <code>
        owner?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The billing entity it was checked for: a workspace, or the account under <code>
        billTo: 'user'
      </code>
      
      . Default in a job's step: the job's owner.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="subject">
        
      </a>
      
       <code>
        subject?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Your id of what was checked: a document, an upload, a job.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="stage-1">
        
      </a>
      
       <code>
        stage?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Where it was checked, in your words: <code>
        'title'
      </code>
      
      , <code>
        'upload'
      </code>
      
      , <code>
        'output'
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ModerationFlag

Defined in: [src/convex/integrations/ai/moderation.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts)

**Experimental**

A flagged check as the Moderation tab lists it (`listModerationFlags`).

#### Extends

- [`ModerationSubject`](#moderationsubject)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Inherited from
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="userid-7">
        
      </a>
      
       <code>
        userId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The account the content came from. Default: who is signed in, or in a job's step (<code>
        jobs.step
      </code>
      
      ), who started the job.
    </td>
    
    <td>
      <a href="#moderationsubject">
        <code>
          ModerationSubject
        </code>
      </a>
      
      .<a href="#userid-6">
        <code>
          userId
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="owner-4">
        
      </a>
      
       <code>
        owner?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The billing entity it was checked for: a workspace, or the account under <code>
        billTo: 'user'
      </code>
      
      . Default in a job's step: the job's owner.
    </td>
    
    <td>
      <a href="#moderationsubject">
        <code>
          ModerationSubject
        </code>
      </a>
      
      .<a href="#owner-3">
        <code>
          owner
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="subject-1">
        
      </a>
      
       <code>
        subject?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Your id of what was checked: a document, an upload, a job.
    </td>
    
    <td>
      <a href="#moderationsubject">
        <code>
          ModerationSubject
        </code>
      </a>
      
      .<a href="#subject">
        <code>
          subject
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="stage-2">
        
      </a>
      
       <code>
        stage?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Where it was checked, in your words: <code>
        'title'
      </code>
      
      , <code>
        'upload'
      </code>
      
      , <code>
        'output'
      </code>
      
      .
    </td>
    
    <td>
      <a href="#moderationsubject">
        <code>
          ModerationSubject
        </code>
      </a>
      
      .<a href="#stage-1">
        <code>
          stage
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="id-9">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="at-1">
        
      </a>
      
       <code>
        at
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       When it was checked, in epoch ms.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="categories-1">
        
      </a>
      
       <code>
        categories
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="blocked-1">
        
      </a>
      
       <code>
        blocked
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="escalate-1">
        
      </a>
      
       <code>
        escalate
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="model-10">
        
      </a>
      
       <code>
        model
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The classifier that flagged it.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="codes-2">
        
      </a>
      
       <code>
        codes?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="providers-1">
        
      </a>
      
       <code>
        providers?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="scores-2">
        
      </a>
      
       <code>
        scores?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <a href="#categoryscore">
        <code>
          CategoryScore
        </code>
      </a>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="thresholds">
        
      </a>
      
       <code>
        thresholds?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        number
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="policyversion">
        
      </a>
      
       <code>
        policyVersion?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="automated">
        
      </a>
      
       <code>
        automated?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="hash">
        
      </a>
      
       <code>
        hash?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A known-abuse match's evidence: the image's SHA-256.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="playbook">
        
      </a>
      
       <code>
        playbook?
      </code>
    </td>
    
    <td>
      <code>
        "csam"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="policy">
        
      </a>
      
       <code>
        policy?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The policy it was judged under, as <code>
        setupAi({ moderation })
      </code>
      
       set it then: <code>
        block all; escalate S4
      </code>
      
      .
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="legalhold">
        
      </a>
      
       <code>
        legalHold?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Kept through the account's erasure until it expires, under a pseudonym: an escalated flag, or child sexual exploitation (<code>
        S4
      </code>
      
      ) refused. The record is evidence the app may be obliged to keep.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ModerationStatement

Defined in: [src/convex/integrations/ai/moderation.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts)

**Experimental**

A decision's statement of reasons (DSA Art. 17), as `getModerationStatement`
gives it to the person it was about: what was decided, the categories it
rests on, that it was decided by automated means, by which providers,
and under which version of your policy. Your page adds the redress: how
to appeal, and to whom.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id-10">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="at-2">
        
      </a>
      
       <code>
        at
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       When it was decided, in epoch ms.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="decision">
        
      </a>
      
       <code>
        decision
      </code>
    </td>
    
    <td>
      <code>
        "blocked"
      </code>
      
       | <code>
        "flagged"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       <code>
        blocked
      </code>
      
      : the content was refused; <code>
        flagged
      </code>
      
      : recorded and let through.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="automated-1">
        
      </a>
      
       <code>
        automated
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Decided by automated means, with no person in the loop.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="categories-2">
        
      </a>
      
       <code>
        categories
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="providers-2">
        
      </a>
      
       <code>
        providers
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="policyversion-1">
        
      </a>
      
       <code>
        policyVersion?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="subject-2">
        
      </a>
      
       <code>
        subject?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="stage-3">
        
      </a>
      
       <code>
        stage?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ModerationLog

Defined in: [src/convex/integrations/ai/moderation.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts)

**Experimental**

How long flags are kept, and whether at all (`moderation.log`).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="days-1">
        
      </a>
      
       <code>
        days
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Days a flag is kept before the maintenance pass prunes it. Default <code>
        183
      </code>
      
      , the six months a person has to complain about a decision.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ModerationConfig

Defined in: [src/convex/integrations/ai/moderation.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts)

**Experimental**

`setupAi({ moderation })`: the classifier content is checked with, and the policy over its verdicts.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="model-11">
        
      </a>
      
       <code>
        model?
      </code>
    </td>
    
    <td>
      <code>
        LanguageModel
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The classifier, a <code>
        provider/model
      </code>
      
       id or a model object, always used when named. By default, the one the gateway that answers serves: <code>
        meta-llama/llama-guard-4-12b
      </code>
      
       through the Convex AI Gateway, which reads images too; <code>
        openai/gpt-oss-safeguard-20b
      </code>
      
       through the Vercel AI Gateway (a pinned <code>
        inferenceRegion
      </code>
      
      , a Vercel-first order with the key, or the Convex one unable to serve the deployment), which reads text only: a check with images is then refused as unchecked.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="text-5">
        
      </a>
      
       <code>
        text?
      </code>
    </td>
    
    <td>
      <code>
        LanguageModel
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The text classifier: <code>
        model
      </code>
      
      's name beside the providers. Name one or the other.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="images-2">
        
      </a>
      
       <code>
        images?
      </code>
    </td>
    
    <td>
      readonly <a href="#moderationprovider">
        <code>
          ModerationProvider
        </code>
      </a>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Providers that check images in place of the text classifier, each with the app's own account: <code>
        azureContentSafety({ region })
      </code>
      
      . Any one that flags blocks. A check with images and no provider here goes to the classifier, which must read images.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="secondopinion">
        
      </a>
      
       <code>
        secondOpinion?
      </code>
    </td>
    
    <td>
      <a href="#moderationprovider">
        <code>
          ModerationProvider
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A provider asked only when a score sits just under its threshold (a gray band of 0.15): <code>
        openaiModeration()
      </code>
      
      . It can raise a score, never lower one.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="knownabuse-1">
        
      </a>
      
       <code>
        knownAbuse?
      </code>
    </td>
    
    <td>
      <a href="#knownabuseprovider">
        <code>
          KnownAbuseProvider
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       A known-abuse hash match, run on every image before any other provider sees it: <code>
        arachnidShield()
      </code>
      
      . A match blocks the content whatever <code>
        block
      </code>
      
       says, escalates it with the CSAM playbook, sends the image nowhere else, and records its SHA-256, never the image.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="thresholds-1">
        
      </a>
      
       <code>
        thresholds?
      </code>
    </td>
    
    <td>
      <code>
        Partial
      </code>
      
      <<code>
        Record
      </code>
      
      <<a href="#moderationcategory">
        <code>
          ModerationCategory
        </code>
      </a>
      
      , <code>
        number
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The score, from 0 to 1, at or above which a shared category flags. The defaults suit an app that takes no sexual content (<code>
        sexual
      </code>
      
       0.3, <code>
        minors_sexual
      </code>
      
       0.05, <code>
        suggestive
      </code>
      
       0.7, <code>
        violence
      </code>
      
      , <code>
        self_harm
      </code>
      
       and <code>
        hate
      </code>
      
       0.5); a prompt or a model's output flags any sexual signal.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="policy-1">
        
      </a>
      
       <code>
        policy?
      </code>
    </td>
    
    <td>
      { <code>
        version
      </code>
      
      : <code>
        string
      </code>
      
      ; }
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Your moderation policy's version, named in every statement of reasons.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        policy.version
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="block">
        
      </a>
      
       <code>
        block?
      </code>
    </td>
    
    <td>
      <code>
        "all"
      </code>
      
       | readonly <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The categories that refuse content, as shared names (<code>
        sexual
      </code>
      
      ) or Llama Guard's codes <code>
        S1
      </code>
      
       to <code>
        S14
      </code>
      
      : <code>
        requireSafe
      </code>
      
      , a <code>
        moderate
      </code>
      
       option and a job's check throw on them, and <code>
        moderate
      </code>
      
       answers <code>
        blocked
      </code>
      
      . The rest are recorded and let through. Default <code>
        'all'
      </code>
      
      : any flag refuses. A flag naming no category, or a code beyond <code>
        S14
      </code>
      
      , is refused under any policy. <strong>
        Example
      </strong>
      
       <code>
        // Family photos trip privacy (S7) and intellectual property (S8) without harm. moderation: { block: ['S1', 'S3', 'S4', 'S9', 'S10', 'S11', 'S12'] }
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="escalate-2">
        
      </a>
      
       <code>
        escalate?
      </code>
    </td>
    
    <td>
      readonly <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The categories an administrator looks at: their content is refused, their flags read <code>
        escalate
      </code>
      
      , stand out in the admin console's Moderation tab, and log <code>
        ai.content_escalated
      </code>
      
       as an error, which reaches your error monitoring. <code>
        block
      </code>
      
       names each too, or its code or category (unless <code>
        block
      </code>
      
       is <code>
        'all'
      </code>
      
      ), and each needs <code>
        log
      </code>
      
      : an escalation leaves a record. Default none.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="log">
        
      </a>
      
       <code>
        log?
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
      
       | <a href="#moderationlog">
        <code>
          ModerationLog
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Keep a record of every flagged check, categories only, never the content: who, what, where, under which policy, and whether it was refused. Default <code>
        { days: 183 }
      </code>
      
      ; <code>
        false
      </code>
      
       keeps none, and takes no <code>
        escalate
      </code>
      
      . An account's erasure deletes the records about it, but for those on legal hold (<code>
        legalHold
      </code>
      
      ), kept under a pseudonym until they expire.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ModelPrice

Defined in: [src/convex/integrations/ai/pricing.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/pricing.ts)

**Experimental**

What one model charges, in credits per [ModelPrice.per](#per) tokens.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="input-1">
        
      </a>
      
       <code>
        input
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Credits per block of input (prompt) tokens.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/pricing.ts" rel="nofollow">
        src/convex/integrations/ai/pricing.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="output-1">
        
      </a>
      
       <code>
        output
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Credits per block of output (completion) tokens.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/pricing.ts" rel="nofollow">
        src/convex/integrations/ai/pricing.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cachedinput">
        
      </a>
      
       <code>
        cachedInput?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Credits per block of cache-read input tokens, when the model prices them separately. Omit and cached tokens are billed as ordinary input.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/pricing.ts" rel="nofollow">
        src/convex/integrations/ai/pricing.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="per">
        
      </a>
      
       <code>
        per?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Tokens each rate covers. Default 1; use <code>
        1_000_000
      </code>
      
       for per-million rates.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/pricing.ts" rel="nofollow">
        src/convex/integrations/ai/pricing.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### TokenUsage

Defined in: [src/convex/integrations/ai/pricing.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/pricing.ts)

**Experimental**

A model call's token counts, as the SDKs report them.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="model-12">
        
      </a>
      
       <code>
        model
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The model id — the key looked up in the price table.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/pricing.ts" rel="nofollow">
        src/convex/integrations/ai/pricing.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="input-2">
        
      </a>
      
       <code>
        input
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Input (prompt) tokens billed at the full rate.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/pricing.ts" rel="nofollow">
        src/convex/integrations/ai/pricing.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="output-2">
        
      </a>
      
       <code>
        output
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Output (completion) tokens.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/pricing.ts" rel="nofollow">
        src/convex/integrations/ai/pricing.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cachedinput-1">
        
      </a>
      
       <code>
        cachedInput?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Cache-read input tokens, when the model reports them separately.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/pricing.ts" rel="nofollow">
        src/convex/integrations/ai/pricing.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### StoreImageOptions

Defined in: [src/convex/integrations/ai/provenance.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/provenance.ts)

**Experimental**

What `ctx.storeImage` records beside the image.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="inputs">
        
      </a>
      
       <code>
        inputs?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Ids of your own rows and files the image was made from: recorded, never read.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/provenance.ts" rel="nofollow">
        src/convex/integrations/ai/provenance.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="sourcetype">
        
      </a>
      
       <code>
        sourceType?
      </code>
    </td>
    
    <td>
      <code>
        "generated"
      </code>
      
       | <code>
        "composite"
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The IPTC digital source type: <code>
        generated
      </code>
      
       (<code>
        trainedAlgorithmicMedia
      </code>
      
      , the default) for an image a model made, <code>
        composite
      </code>
      
       (<code>
        compositeWithTrainedAlgorithmicMedia
      </code>
      
      ) for a photo a model edited in part.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/provenance.ts" rel="nofollow">
        src/convex/integrations/ai/provenance.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="model-13">
        
      </a>
      
       <code>
        model?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The model the manifest names as the image's generator. Default: the image model this run called last (<code>
        ctx.image()
      </code>
      
      ), else the last model it called, so a caption or a vision check after the image never signs it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/provenance.ts" rel="nofollow">
        src/convex/integrations/ai/provenance.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ImageStoreContext

Defined in: [src/convex/integrations/ai/provenance.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/provenance.ts)

**Experimental**

`ctx.storeImage` in a job step or a metered action.

#### Extended by

- [`MeteredContext`](#meteredcontext)
- [`JobStepContext`](#jobstepcontext)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="storeimage-2">
        
      </a>
      
       <code>
        storeImage
      </code>
    </td>
    
    <td>
      (<code>
        file
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Id
      </code>
      
      <<code>
        "_storage"
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Store an image a model made, with its content credentials: the IPTC source type in its XMP, a C2PA manifest signed with <code>
        PROVENANCE_PRIVATE_KEY
      </code>
      
      , and a provenance record of the models, the time and <code>
        inputs
      </code>
      
      . The image is kept in the <code>
        backend
      </code>
      
       component's storage as the job's owner's (the run's billing entity in a metered action), like an upload <code>
        storage.claim
      </code>
      
       kept: counted in the quota, listed in the owner's export and deleted with it. Resolves with its id there, typed as a storage id: read its URL through <code>
        storage.fileUrl
      </code>
      
      , <code>
        storage.signedUrl
      </code>
      
       or <code>
        getFileUrl
      </code>
      
      , never <code>
        ctx.storage.getUrl
      </code>
      
      , and delete it with <code>
        storage.release
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/provenance.ts" rel="nofollow">
        src/convex/integrations/ai/provenance.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### JobTier

Defined in: [src/convex/jobs-policy.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/jobs-policy.ts)

**Experimental**

One tier of the queue, as `defineJobQueue({ tiers })` declares it.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="feature">
        
      </a>
      
       <code>
        feature?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The plan feature that puts a job in this tier. The last tier may leave it out and catch everyone else.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/jobs-policy.ts" rel="nofollow">
        src/convex/jobs-policy.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="headstart">
        
      </a>
      
       <code>
        headStart?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       How far up the line its jobs score, in ms. Default <code>
        0
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/jobs-policy.ts" rel="nofollow">
        src/convex/jobs-policy.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="perowner-1">
        
      </a>
      
       <code>
        perOwner?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Running jobs one owner of this tier may have. Default: the queue's <code>
        perOwner
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/jobs-policy.ts" rel="nofollow">
        src/convex/jobs-policy.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="dedicated">
        
      </a>
      
       <code>
        dedicated?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Slots of <code>
        concurrency
      </code>
      
       kept for this tier and the tiers listed above it. Default <code>
        0
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/jobs-policy.ts" rel="nofollow">
        src/convex/jobs-policy.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="budget-1">
        
      </a>
      
       <code>
        budget?
      </code>
    </td>
    
    <td>
      { <code>
        units
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        period
      </code>
      
      : <code>
        number
      </code>
      
      ; }
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Credits of jobs one owner may queue per window. Default none.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/jobs-policy.ts" rel="nofollow">
        src/convex/jobs-policy.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        budget.units
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/jobs-policy.ts" rel="nofollow">
        src/convex/jobs-policy.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        budget.period
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/jobs-policy.ts" rel="nofollow">
        src/convex/jobs-policy.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Type Aliases

### AiModel

```ts
type AiModel = LanguageModel;
```

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

A model to call: a `provider/model` id (`'openai/gpt-5-mini'`), or a model
object from any AI SDK provider package, called with that provider's own
key. The AI SDK (`ai`) is an optional peer: install it to name one.

An id goes through the gateways `setupAi({ gateway })` names, in order. By
default that is the Convex AI Gateway first, on Convex Cloud with a paid
plan (install `@convex-dev/ai-sdk-provider`, an optional peer too), then
the Vercel AI Gateway with the deployment's `AI_GATEWAY_API_KEY`. When no
gateway in the order answers, the call is refused, saying why: no model
answers in their place.

---

### AiGateway

```ts
type AiGateway = "convex" | "vercel";
```

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

A gateway a `provider/model` id goes through (`setupAi({ gateway })`):

- `convex`: the Convex AI Gateway. Convex holds the providers' keys and
bills the team: no key to keep, paid plans only, no region pinning.
- `vercel`: the Vercel AI Gateway, with the deployment's
`AI_GATEWAY_API_KEY`. Any plan and any host, budgets per key, region
pinning, and Vercel's own routing options.

See [https://nuxt-backend.dev/docs/services/ai-gateway#choose-a-gateway](https://nuxt-backend.dev/docs/services/ai-gateway#choose-a-gateway).

#### Example

```ts
setupAi(components, { billing, gateway: 'convex' })             // the Convex AI Gateway alone: the key is never read
setupAi(components, { billing, gateway: 'vercel' })             // the Vercel AI Gateway alone, even on a paid Convex plan
setupAi(components, { billing, gateway: ['vercel', 'convex'] }) // the Vercel AI Gateway where the key is set, else the Convex one
```

---

### ModelRoutes

```ts
type ModelRoutes = Readonly<Record<string, AiGateway | readonly AiGateway[]>>;
```

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

The gateways some models go through instead of `setupAi({ gateway })`'s
order (`setupAi({ routes })`), keyed by a `provider/model` id or by a
pattern ending in `*`: `google/*` for every model of a provider,
`google/gemini-3-*` for a family. One [AiGateway](#aigateway) sends them to
that gateway alone, a list in that order. An id's own key beats a
pattern, and a longer pattern beats a shorter one.

#### Example

```ts
setupAi(components, {
  billing,
  routes: {
    'google/*': 'vercel',                       // a provider the Vercel AI Gateway serves better
    'openai/gpt-image-2': ['vercel', 'convex'], // the Vercel AI Gateway first for one model
  },
})
```

---

### MeteredModel

```ts
type MeteredModel = Extract<LanguageModel, {
  specificationVersion: "v4";
}>;
```

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

The model a metered handler calls (`ctx.model()`): an AI SDK language
model, so `generateText`, `streamText` and the rest of the SDK take it
as they take any other. Every call made through it counts toward the run's
cost.

---

### InferenceRegion

```ts
type InferenceRegion = "eu";
```

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

A region the Vercel AI Gateway pins inference to (`setupAi({ inferenceRegion })`).

---

### GuestClaim

```ts
type GuestClaim = {
  jobIds: string[];
  workspaceId: string;
  userId: string;
};
```

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

What `setupAi({ guest: { claim } })`'s mutation receives.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="jobids">
        
      </a>
      
       <code>
        jobIds
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      The visitor's jobs, now the new account's.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="workspaceid">
        
      </a>
      
       <code>
        workspaceId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The new account's workspace: the one it signed up into.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="userid-1">
        
      </a>
      
       <code>
        userId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The new account.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts" rel="nofollow">
        src/convex/integrations/ai/config.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### MeteredCost

```ts
type MeteredCost<Args, Result> = 
  | number
  | ((args) => number)
  | FinalizedCost<Args, Result>
| ReportedCost<Args>;
```

Defined in: [src/convex/integrations/ai/config.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/config.ts)

**Experimental**

Credits per call: fixed, derived from the args, estimated then finalized,
or settled from the cost the model reports.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-args-2">
        
      </a>
      
       <code>
        Args
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        PropertyValidators
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-result-1">
        
      </a>
      
       <code>
        Result
      </code>
    </td>
  </tr>
</tbody>
</table>

---

### AiEmbeddingModel

```ts
type AiEmbeddingModel = string | Exclude<EmbeddingModel, string>;
```

Defined in: [src/convex/integrations/ai/embeddings.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/embeddings.ts)

**Experimental**

An embedding model: a `provider/model` id from the gateway's list, or an AI SDK embedding model object.

---

### AiImageModel

```ts
type AiImageModel = string | Exclude<ImageModel, string>;
```

Defined in: [src/convex/integrations/ai/images.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/images.ts)

**Experimental**

An image model: a `provider/model` id from the gateway's list, or an AI SDK image model object.

---

### JobEnd

```ts
type JobEnd = {
  jobId: string;
  kind: string;
  status: "done" | "failed" | "canceled";
  error?: Record<string, unknown>;
  args: unknown;
  retries: number;
  endedAt: number;
  charged: number;
  free: boolean;
  owed?: number;
};
```

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

A job's end as `onJobEnd` receives it ([vJobEnd](#vjobend)).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="jobid">
        
      </a>
      
       <code>
        jobId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="kind">
        
      </a>
      
       <code>
        kind
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="status-1">
        
      </a>
      
       <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        "done"
      </code>
      
       | <code>
        "failed"
      </code>
      
       | <code>
        "canceled"
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="error">
        
      </a>
      
       <code>
        error?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      >
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="args-2">
        
      </a>
      
       <code>
        args
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="retries">
        
      </a>
      
       <code>
        retries
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="endedat">
        
      </a>
      
       <code>
        endedAt
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="charged">
        
      </a>
      
       <code>
        charged
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="free">
        
      </a>
      
       <code>
        free
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="owed">
        
      </a>
      
       <code>
        owed?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### OnJobEnd

```ts
type OnJobEnd = FunctionReference<"mutation" | "action", "internal", JobEnd>;
```

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

Your internal mutation, or action, that hears of every job's end: taking
`vJobEnd` as its args, passed by its reference (`internal.prints.ended`).

---

### OwedCharge

```ts
type OwedCharge = {
  jobId: string;
  kind: string;
  args: unknown;
  retries: number;
  status: "charged" | "given_up";
  credits: number;
  at: number;
};
```

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

An owed charge's end as `onOwedCharge` receives it ([vOwedCharge](#vowedcharge)).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="jobid-1">
        
      </a>
      
       <code>
        jobId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="kind-1">
        
      </a>
      
       <code>
        kind
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="args-3">
        
      </a>
      
       <code>
        args
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="retries-1">
        
      </a>
      
       <code>
        retries
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="status-2">
        
      </a>
      
       <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        "charged"
      </code>
      
       | <code>
        "given_up"
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="credits-1">
        
      </a>
      
       <code>
        credits
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="at">
        
      </a>
      
       <code>
        at
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### OnOwedCharge

```ts
type OnOwedCharge = FunctionReference<"mutation" | "action", "internal", OwedCharge>;
```

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

Your internal mutation, or action, that hears how an owed charge ended: taking `vOwedCharge` as its args.

---

### StepResult

```ts
type StepResult<Returned> = 0 extends 1 & Returned ? unknown : Returned extends {
  value: infer Value;
} ? string extends keyof Returned ? never : Value : never;
```

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

What a step returned, as `job.run` hands it back: the `value` member of the
step's registered return type. Its other member, a record of any keys,
is the queue's own outcome and never reaches the handler.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-returned">
        
      </a>
      
       <code>
        Returned
      </code>
    </td>
  </tr>
</tbody>
</table>

---

### KnowledgeAddCost

```ts
type KnowledgeAddCost = number | ((document) => number);
```

Defined in: [src/convex/integrations/ai/knowledge.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/knowledge.ts)

**Experimental**

What adding a document costs, from the length of the text it embeds.

---

### ProviderEnv

```ts
type ProviderEnv = Readonly<Record<string, string | undefined>>;
```

Defined in: [src/convex/integrations/ai/moderation-providers.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts)

**Experimental**

The deployment's env, as a provider reads its keys: `process.env` on a deployment.

---

### ModerationCategory

```ts
type ModerationCategory = 
  | "sexual"
  | "suggestive"
  | "minors_sexual"
  | "violence"
  | "self_harm"
  | "hate"
  | "weapons"
  | "drugs"
  | "csam_match";
```

Defined in: [src/convex/integrations/ai/moderation-taxonomy.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-taxonomy.ts)

**Experimental**

A category every moderation provider maps onto.

---

### ModerationCtx

```ts
type ModerationCtx = Pick<GenericActionCtx<GenericDataModel>, "runAction" | "runQuery" | "runMutation"> & Partial<Pick<GenericActionCtx<GenericDataModel>, "storage" | "auth">> & {
  job?: {
     owner?: string;
     userId?: string;
  };
};
```

Defined in: [src/convex/integrations/ai/moderation.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts)

**Experimental**

The context a check runs in: an action's, which can call a model, read a file and record what the call cost.

#### Type Declaration

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        job?
      </code>
    </td>
    
    <td>
      { <code>
        owner?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId?
      </code>
      
      : <code>
        string
      </code>
      
      ; }
    </td>
    
    <td>
      The job a step runs for (<code>
        jobs.step
      </code>
      
      's <code>
        ctx.job
      </code>
      
      ): who a flag names when the check names nobody.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        job.owner?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        job.userId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation.ts" rel="nofollow">
        src/convex/integrations/ai/moderation.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### TokenPriceTable

```ts
type TokenPriceTable = Record<string, ModelPrice>;
```

Defined in: [src/convex/integrations/ai/pricing.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/pricing.ts)

**Experimental**

The app's price list: model id → [ModelPrice](#modelprice).

---

### ProvenanceConfig

```ts
type ProvenanceConfig = 
  | boolean
  | {
  name?: string;
};
```

Defined in: [src/convex/integrations/ai/provenance.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/provenance.ts)

**Experimental**

`setupAi({ provenance })`: `true` for the defaults, or the generator name each manifest shows.

#### Union Members

`boolean`

---

##### Type Literal

```ts
{
  name?: string;
}
```

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        name?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The generator name each manifest shows: your app's name. Default: <code>
        SITE_URL
      </code>
      
      's host.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/provenance.ts" rel="nofollow">
        src/convex/integrations/ai/provenance.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### GeneratedImage

```ts
type GeneratedImage = 
  | Blob
  | Uint8Array
  | {
  uint8Array: Uint8Array;
  mediaType?: string;
};
```

Defined in: [src/convex/integrations/ai/provenance.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/provenance.ts)

**Experimental**

A generated image, as `ctx.storeImage` takes it: the AI SDK's generated file, a `Blob`, or its bytes.

## Variables

### vJobEnd

```ts
const vJobEnd: {
  jobId: VString<string, "required">;
  kind: VString<string, "required">;
  status: VUnion<"failed" | "canceled" | "done", [VLiteral<"done", "required">, VLiteral<"failed", "required">, VLiteral<"canceled", "required">], "required", never>;
  error: VAny<any, "optional", string>;
  args: VAny<any, "required", string>;
  retries: VFloat64<number, "required">;
  endedAt: VFloat64<number, "required">;
  charged: VFloat64<number, "required">;
  free: VBoolean<boolean, "required">;
  owed: VFloat64<number | undefined, "optional">;
};
```

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

How a job ended, as `onJobEnd` receives it: use these as your function's
`args` (`internalMutation({ args: vJobEnd, handler })`).

#### Type Declaration

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="property-jobid">
        
      </a>
      
       <code>
        jobId
      </code>
    </td>
    
    <td>
      <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >
    </td>
    
    <td>
      The job's id, as <code>
        jobs.enqueue
      </code>
      
       returned it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-kind">
        
      </a>
      
       <code>
        kind
      </code>
    </td>
    
    <td>
      <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >
    </td>
    
    <td>
      Its <code>
        jobs.define
      </code>
      
       export, as <code>
        module:name
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-status">
        
      </a>
      
       <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        VUnion
      </code>
      
      <<code>
        "failed"
      </code>
      
       | <code>
        "canceled"
      </code>
      
       | <code>
        "done"
      </code>
      
      , [<code>
        VLiteral
      </code>
      
      <<code>
        "done"
      </code>
      
      , <code>
        "required"
      </code>
      
      >, <code>
        VLiteral
      </code>
      
      <<code>
        "failed"
      </code>
      
      , <code>
        "required"
      </code>
      
      >, <code>
        VLiteral
      </code>
      
      <<code>
        "canceled"
      </code>
      
      , <code>
        "required"
      </code>
      
      >], <code>
        "required"
      </code>
      
      , <code>
        never
      </code>
      
      >
    </td>
    
    <td>
      How it ended. A stall is <code>
        failed
      </code>
      
      , its <code>
        error
      </code>
      
       reason <code>
        stalled
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-error">
        
      </a>
      
       <code>
        error
      </code>
    </td>
    
    <td>
      <code>
        VAny
      </code>
      
      <<code>
        any
      </code>
      
      , <code>
        "optional"
      </code>
      
      , <code>
        string
      </code>
      
      >
    </td>
    
    <td>
      Why it failed, as a catalog error payload: <code>
        { code, ...fields }
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-args">
        
      </a>
      
       <code>
        args
      </code>
    </td>
    
    <td>
      <code>
        VAny
      </code>
      
      <<code>
        any
      </code>
      
      , <code>
        "required"
      </code>
      
      , <code>
        string
      </code>
      
      >
    </td>
    
    <td>
      The args it was put in line with.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-retries">
        
      </a>
      
       <code>
        retries
      </code>
    </td>
    
    <td>
      <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >
    </td>
    
    <td>
      Which run ended: <code>
        0
      </code>
      
       for the first, one more for each administrator's retry. Every run ends, and is heard, once: a later run's end is the newer news, so a retried job's <code>
        done
      </code>
      
       wins over its earlier <code>
        failed
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-endedat">
        
      </a>
      
       <code>
        endedAt
      </code>
    </td>
    
    <td>
      <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >
    </td>
    
    <td>
      When this run ended, in ms since the epoch.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-charged">
        
      </a>
      
       <code>
        charged
      </code>
    </td>
    
    <td>
      <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >
    </td>
    
    <td>
      The credits this run was charged: its <code>
        cost
      </code>
      
      , or what <code>
        job.charge
      </code>
      
       charged; <code>
        0
      </code>
      
       for a run charged nothing. A refund may still be on its way for a failed or canceled one: the queue gives it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-free">
        
      </a>
      
       <code>
        free
      </code>
    </td>
    
    <td>
      <code>
        VBoolean
      </code>
      
      <<code>
        boolean
      </code>
      
      , <code>
        "required"
      </code>
      
      >
    </td>
    
    <td>
      Put in line <code>
        { free: true }
      </code>
      
      : it held, charged and counted nothing.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-owed">
        
      </a>
      
       <code>
        owed
      </code>
    </td>
    
    <td>
      <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >
    </td>
    
    <td>
      The credits its charge still owes, for a kind charged by output whose <code>
        job.charge
      </code>
      
       the provider refused for now: the job is <code>
        done
      </code>
      
       (or canceled without a refund), its result stands, its hold stays taken and the queue tries the charge again in the background. <code>
        onOwedCharge
      </code>
      
       hears how that ends. Absent when nothing is owed.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### vOwedCharge

```ts
const vOwedCharge: {
  jobId: VString<string, "required">;
  kind: VString<string, "required">;
  args: VAny<any, "required", string>;
  retries: VFloat64<number, "required">;
  status: VUnion<"charged" | "given_up", [VLiteral<"charged", "required">, VLiteral<"given_up", "required">], "required", never>;
  credits: VFloat64<number, "required">;
  at: VFloat64<number, "required">;
};
```

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

How an owed charge ended, as `onOwedCharge` receives it: use these as
your function's `args` (`internalMutation({ args: vOwedCharge, handler })`).

#### Type Declaration

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="property-jobid-1">
        
      </a>
      
       <code>
        jobId
      </code>
    </td>
    
    <td>
      <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >
    </td>
    
    <td>
      The job's id, as <code>
        jobs.enqueue
      </code>
      
       returned it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-kind-1">
        
      </a>
      
       <code>
        kind
      </code>
    </td>
    
    <td>
      <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >
    </td>
    
    <td>
      Its <code>
        jobs.define
      </code>
      
       export, as <code>
        module:name
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-args-1">
        
      </a>
      
       <code>
        args
      </code>
    </td>
    
    <td>
      <code>
        VAny
      </code>
      
      <<code>
        any
      </code>
      
      , <code>
        "required"
      </code>
      
      , <code>
        string
      </code>
      
      >
    </td>
    
    <td>
      The args it was put in line with.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-retries-1">
        
      </a>
      
       <code>
        retries
      </code>
    </td>
    
    <td>
      <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >
    </td>
    
    <td>
      Which run of the job charged it, as <code>
        vJobEnd
      </code>
      
       counts them.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-status-1">
        
      </a>
      
       <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        VUnion
      </code>
      
      <<code>
        "charged"
      </code>
      
       | <code>
        "given_up"
      </code>
      
      , [<code>
        VLiteral
      </code>
      
      <<code>
        "charged"
      </code>
      
      , <code>
        "required"
      </code>
      
      >, <code>
        VLiteral
      </code>
      
      <<code>
        "given_up"
      </code>
      
      , <code>
        "required"
      </code>
      
      >], <code>
        "required"
      </code>
      
      , <code>
        never
      </code>
      
      >
    </td>
    
    <td>
      <code>
        charged
      </code>
      
      : the provider took the charge at last, under the same idempotency key, so it is billed once. <code>
        given_up
      </code>
      
      : every try failed, or the provider refused it in a way no try changes (a revoked access token), so it was given up at once; the hold went back and the job stays uncharged, for an administrator's retry from the Queue tab (<code>
        retryJob
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-credits">
        
      </a>
      
       <code>
        credits
      </code>
    </td>
    
    <td>
      <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >
    </td>
    
    <td>
      The credits it owed: what <code>
        job.charge
      </code>
      
       charged.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-at">
        
      </a>
      
       <code>
        at
      </code>
    </td>
    
    <td>
      <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >
    </td>
    
    <td>
      When it ended, in ms since the epoch.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts" rel="nofollow">
        src/convex/integrations/ai/jobs.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### MODERATION_CATEGORIES

```ts
const MODERATION_CATEGORIES: readonly ModerationCategory[];
```

Defined in: [src/convex/integrations/ai/moderation-taxonomy.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-taxonomy.ts)

**Experimental**

Every category, in the order a statement of reasons lists them.

---

### DEFAULT_THRESHOLDS

```ts
const DEFAULT_THRESHOLDS: Readonly<Record<ModerationCategory, number>>;
```

Defined in: [src/convex/integrations/ai/moderation-taxonomy.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-taxonomy.ts)

**Experimental**

The score at or above which a category flags the content. The defaults
suit an app that takes no sexual content, as card processors ask of AI
image generation: anything sexual flags, a suggestive image does not on
its own, and anything about minors flags at the faintest signal.

## Functions

### retryable()

```ts
function retryable(message): Error;
```

Defined in: [src/convex/integrations/ai/job-errors.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/job-errors.ts)

**Experimental**

An error a job step throws for a failure another attempt may not meet,
such as a model that answered with no image: the queue waits and runs
the step again, up to 4 attempts, as for a provider's passing error,
instead of failing the job at once.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        message
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Returns

`Error`

#### Example

```ts
if (!image) throw retryable(`The model returned no image (${result.finishReason})`)
```

---

### defineJobQueue()

```ts
function defineJobQueue(components, options): JobQueue;
```

Defined in: [src/convex/integrations/ai/jobs.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/jobs.ts)

**Experimental**

Declare the app's generation queue, once, in `backend/jobs.ts`: kinds of
jobs (`jobs.define`) run their steps (`jobs.step`) in a fair line with
tiers from plan features, each model under a limit that adapts to `429`s,
credits held while a job waits, charged when it starts and refunded when
it fails, and each job's cost reported to the billing provider.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        components
      </code>
    </td>
    
    <td>
      <a href="#jobqueuecomponents">
        <code>
          JobQueueComponents
        </code>
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options
      </code>
    </td>
    
    <td>
      <a href="#definejobqueueoptions">
        <code>
          DefineJobQueueOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`JobQueue`](#jobqueue)

#### Example

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

export const jobs = defineJobQueue(components, {
  ai,
  concurrency: 3,
  tiers: { priority: { feature: 'priority_queue', headStart: 10 * MINUTE }, standard: {} },
})

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

---

### azureContentSafety()

```ts
function azureContentSafety(options): ModerationProvider;
```

Defined in: [src/convex/integrations/ai/moderation-providers.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts)

**Experimental**

Azure AI Content Safety, on your own Azure resource: text and images, in
the region you created it in (processing stays there, and inputs are
neither stored nor trained on). It scores Hate, Sexual, Violence and
SelfHarm, artwork included, and is no check for child sexual abuse
material: pair it with `knownAbuse`. Reads `CONTENT_SAFETY_ENDPOINT`
and `CONTENT_SAFETY_KEY`. An image over 4 MB or 7200 px a side is
refused `invalid_input` (reason `too_large`), naming the stage it was
checked at: downscale it first, a model's output included.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        options
      </code>
    </td>
    
    <td>
      <a href="#azurecontentsafetyoptions">
        <code>
          AzureContentSafetyOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`ModerationProvider`](#moderationprovider)

---

### openaiModeration()

```ts
function openaiModeration(): ModerationProvider;
```

Defined in: [src/convex/integrations/ai/moderation-providers.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts)

**Experimental**

OpenAI's moderation endpoint (`omni-moderation-latest`), free with an
OpenAI API key: text and images. For images it scores sexual content,
violence and self-harm only. Its usual place is `secondOpinion`, asked
when another provider's score sits just under a threshold, never for
suspected abuse material. Reads `SECOND_OPINION_KEY`.

#### Returns

[`ModerationProvider`](#moderationprovider)

---

### arachnidShield()

```ts
function arachnidShield(): KnownAbuseProvider;
```

Defined in: [src/convex/integrations/ai/moderation-providers.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/moderation-providers.ts)

**Experimental**

Project Arachnid Shield (the Canadian Centre for Child Protection): a
match of an image's hashes against known child sexual abuse material,
free once your organization is vetted. Run as `knownAbuse`, on every
image before any other provider sees it. A match blocks the content,
sends the image nowhere else, escalates it with the CSAM playbook, and
keeps the image's SHA-256 as evidence, never the image. Reads
`KNOWN_ABUSE_KEY`, as `username:password`.

Built against Shield's published API: `POST /v1/media/` with the raw
bytes and basic auth, answering a `classification` of `no-known-match`,
`csam` or `harmful-abusive-material`; any other answer, or none, refuses
the content as unchecked. Not yet checked against a live account.

#### Returns

[`KnownAbuseProvider`](#knownabuseprovider)

---

### priceTokens()

```ts
function priceTokens(
   usage, 
   table, 
   options?
): number;
```

Defined in: [src/convex/integrations/ai/pricing.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/pricing.ts)

**Experimental**

Price a model call in credits from its token usage and a price table the app
owns. No provider knows what a model costs you — rates change weekly and
only your margin decides the credit price — so the table is yours; this is
the arithmetic, pure and testable.

Rates are credits per `per` tokens (default 1). Express per-million pricing
as `per: 1_000_000` on the entry or as a table-wide `options.per`.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        usage
      </code>
    </td>
    
    <td>
      <a href="#tokenusage">
        <code>
          TokenUsage
        </code>
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        table
      </code>
    </td>
    
    <td>
      <a href="#tokenpricetable">
        <code>
          TokenPriceTable
        </code>
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      { <code>
        per?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        round?
      </code>
      
      : <code>
        "none"
      </code>
      
       | <code>
        "up"
      </code>
      
       | <code>
        "nearest"
      </code>
      
      ; <code>
        minimum?
      </code>
      
      : <code>
        number
      </code>
      
      ; }
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options.per?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options.round?
      </code>
    </td>
    
    <td>
      <code>
        "none"
      </code>
      
       | <code>
        "up"
      </code>
      
       | <code>
        "nearest"
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options.minimum?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Returns

`number`

#### Example

```ts
const prices = {
  'fast-1': { input: 3, output: 15, per: 1_000_000 },
  'deep-1': { input: 15, output: 75, cachedInput: 1.5, per: 1_000_000 },
}
priceTokens({ model: 'fast-1', input: 12_000, output: 800 }, prices) // → 0.048
```

#### Throws

when the model is missing from the table — a silent 0 would be a
revenue leak, and an unpriced model is a deployment mistake worth surfacing.

---

### setupAi()

```ts
function setupAi(components, config): Ai;
```

Defined in: [src/convex/integrations/ai/setup.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/ai/setup.ts)

**Experimental**

Configure the AI rails over billing + rate limiting + streaming.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        components
      </code>
    </td>
    
    <td>
      <a href="#aicomponents">
        <code>
          AiComponents
        </code>
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        config
      </code>
    </td>
    
    <td>
      <a href="#setupaiconfig">
        <code>
          SetupAiConfig
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`Ai`](#ai)

#### Example

```ts
// backend/ai.ts
import { setupAi } from 'nuxt-backend/ai'
import { components } from './_generated/api'
import { billing } from './billing'
import { rateLimiter } from './rateLimiter'

export const ai = setupAi(components, { billing, rateLimiter, model: 'openai/gpt-5-mini' })
export const generate = ai.meteredAction({ ... })
export const { start: startEcho, body: echoBody } = ai.stream({ name: 'echo', ... })
export const { getCosts } = ai.api
```

## References

### JobProvenance

Re-exports [JobProvenance](https://nuxt-backend.dev/docs/reference/api/use-job#jobprovenance)

---

### JobProgress

Re-exports [JobProgress](https://nuxt-backend.dev/docs/reference/api/use-job#jobprogress)

---

### JobView

Re-exports [JobView](https://nuxt-backend.dev/docs/reference/api/use-job#jobview)


## Sitemap

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