app-ai-binding
하는 일
이 스킬은 Cloudflare에서 실행되는 앱에 모델 기반 AI 기능을 추가하는 방법을 에이전트에게 가르칩니다. 내장 AI 바인딩이 서버 측에서 어떻게 쓰이는지, 어떤 호출에 안심하고 의존할 수 있는지 설명합니다.
사용하는 경우
- ✓사용자가 Cloudflare의 앱에 채팅봇, 요약, 분류기를 추가하고 싶을 때.
- ✓사용자가 Cloudflare 앱에 임베딩이나 의미 검색을 구축하고 싶은 경우.
- ✓사용자가 Workers AI 모델로 이미지 이해나 전사를 처리하고 싶을 때.
스킬 링크
https://github.com/cloudflare/vibesdk/blob/main/worker/agents/think/skills/app-ai-binding/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“Cloudflare의 제 앱에 내장 AI 바인딩을 사용해 질문에 답하는 채팅봇을 추가해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 서버 쪽 앱 클래스에서 선택한 모델과 입력 메시지로 AI 바인딩을 호출합니다. 브라우저는 앱 경로만 호출하므로, 모델 접근은 서버에 머뭅니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
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
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:
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:
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:
const image = [...new Uint8Array(await request.arrayBuffer())];
const result = await this.env.AI.run("@cf/microsoft/resnet-50", { image });
Speech transcription
Use @cf/openai/whisper with audio bytes:
const audio = [...new Uint8Array(await request.arrayBuffer())];
const result = await this.env.AI.run("@cf/openai/whisper", { audio });
Model input and output shapes differ. Keep model-specific parsing close to the call and validate user input before inference. Use only active model IDs from the current Workers AI model catalog; never generate code with a deprecated model.
Limits and errors
Dynamic Worker previews enforce a per-app AI call limit. AI features must fail transparently when inference is unavailable.
- Never return canned, random, mock, placeholder, or hard-coded content as a fallback for an AI response.
- Never catch an
AI.run()error and continue with an apparently successful response. - Never return
200with fields such asfallbackUsedafter inference fails. - Return a non-2xx JSON response containing a safe, useful error message. The frontend must display that error to the user.
- Do not retry rate-limit failures in a loop.
try {
const result = await this.env.AI.run("@cf/meta/llama-4-scout-17b-16e-instruct", {
messages: [{ role: "user", content: userPrompt }],
});
return Response.json(result);
} catch (error) {
const message = error instanceof Error ? error.message : "AI inference failed";
return Response.json({ error: "AI inference failed", details: message }, { status: 503 });
}
Frontend callers must inspect both the HTTP status and error body:
const response = await fetch("./api/chat", requestOptions);
const body = await response.json<{ content?: string; error?: string; details?: string }>();
if (!response.ok) throw new Error(body.details || body.error || "AI request failed");
Use non-streaming calls for preview-compatible code. Native Workers AI deployments support { stream: true }, but streaming across the preview proxy is not guaranteed.
자주 묻는 질문
설정 파일에 AI 섹션을 추가해야 하나요?
아닙니다. 스킬은 플랫폼이 AI 바인딩을 자동으로 제공한다고 설명합니다.
브라우저가 모델을 직접 호출할 수 있나요?
아닙니다. 스킬은 브라우저 코드가 바인딩이 아니라 앱 경로를 호출해야 한다고 설명합니다.
어떤 AI 메서드를 써도 안전한가요?
스킬은 run 메서드를 쓰라고 설명합니다. 다른 AI 메서드는 미리 보기와 배포 사이에서 유지되지 않기 때문입니다.
상세 정보
작성자의 원본 설명
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.
repo: cloudflare/vibesdk
인기도
- GitHub 스타
- 5.4k
- 순위
- #14845
- 라이선스
- MIT
- 업데이트
- 2026. 10. 21.
댓글
- …
이 저장소의 다른 스킬
cloudflare-bundler-apps
5.4k에이전트가 Cloudflare Worker 프로젝트를 번들러로 올바르게 빌드하고 미리 보도록 설정하도록 돕습니다. 설정, 레이아웃, 에셋, 의존성 제한을 다룹니다.
frontend-design-landing-page
5.4k에이전트가 명확한 히어로 섹션, 기능 그리드, 가격, 행동 유도 버튼을 갖춘 따뜻하고 전환에 초점을 맞춘 마케팅 랜딩 페이지를 디자인하도록 돕습니다.
frontend-design-saas
5.4k에이전트가 대시보드, 설정 페이지, 결제 화면, 데이터 표 같은 밀도 높고 깔끔한 제품 인터페이스를 차분한 중립 SaaS 스타일로 디자인하도록 돕습니다.
비슷한 스킬
api-connector-builder
280k에이전트가 기존 패턴을 따라 새로운 API 연결을 만들도록 합니다. 새로운 방식을 도입하지 않고 연동을 하나 더 추가할 때 씁니다.
api-design
280k에이전트가 모범 사례에 따라 REST API를 설계하도록 돕습니다. API가 통신하는 방식, 오류를 보여 주는 방식, 데이터를 정리하는 방식을 정하는 데 유용합니다.
backend-patterns
280k에이전트가 서버 쪽 아키텍처 패턴과 데이터베이스 최적화를 다루도록 돕습니다. 서버에서 실행되는 코드를 만들거나 검토할 때 유용합니다.