# Workers AI Features

Adds chat, embeddings, search, transcription and other AI features using the Workers AI binding.

- Repository: https://github.com/cloudflare/vibesdk (5447 stars)
- Category: AI and agents
- License: MIT
- Last updated: 2026-10-22
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add cloudflare/vibesdk --skill app-ai-binding -g -a claude-code -y`
Codex: `npx skills add cloudflare/vibesdk --skill app-ai-binding -g -a codex -y`
Cursor: `npx skills add cloudflare/vibesdk --skill app-ai-binding -g -a cursor -y`
Gemini CLI: `npx skills add cloudflare/vibesdk --skill app-ai-binding -g -a gemini-cli -y`

## Description

Build AI features in generated apps using the platform-provided Workers AI binding. Load this skill for chatbots, summarization, classification, embeddings, semantic search, image understanding, transcription, translation, or other model inference.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

Generated apps can call Workers AI from the `App` Durable Object through `this.env.AI`. The platform provides this binding automatically in Dynamic Worker previews and native Cloudflare deployments. Do not add an `ai` section to the generated app's `wrangler.json`.

Use only `AI.run(model, inputs, options?)`. Preview uses a restricted proxy with this method, while deployed Workers receive the native Workers AI binding. Methods such as `AI.gateway()`, `AI.models()`, `AI.autorag()`, and `AI.toMarkdown()` are not portable between preview and deployment.

## Type and usage

```ts
import { DurableObject } from "cloudflare:workers";

interface Env {
  AI: Ai;
}

export class App extends DurableObject<Env> {
  async fetch(request: Request): Promise<Response> {
    const { prompt } = await request.json<{ prompt: string }>();
    const result = await this.env.AI.run("@cf/meta/llama-4-scout-17b-16e-instruct", {
      messages: [
        { role: "system", content: "Answer clearly and concisely." },
        { role: "user", content: prompt },
      ],
    });
    return Response.json(result);
  }
}
```

Keep AI calls in the server-side `App` class. Browser code should call an app API route; it must never receive model credentials or call the binding directly.

## Common tasks

### Text generation

Use `@cf/meta/llama-4-scout-17b-16e-instruct` with either `prompt` or `messages`:

```ts
const result = await this.env.AI.run("@cf/meta/llama-4-scout-17b-16e-instruct", {
  messages: [{ role: "user", content: userPrompt }],
  max_tokens: 512,
});
```

### Embeddings

Use `@cf/baai/bge-base-en-v1.5`. The response contains embedding vectors in `data`:

```ts
const result = await this.env.AI.run("@cf/baai/bge-base-en-v1.5", {
  text: ["first document", "second document"],
});
```

### Image classification

Use `@cf/microsoft/resnet-50` with image bytes converted to a number array:

The rest: https://github.com/cloudflare/vibesdk/blob/HEAD/worker/agents/think/skills/app-ai-binding/SKILL.md
