cloudflare-ai
БесплатноБез исполняемых скриптовНе проверенCloudflare Workers AI runs open-source AI models (LLMs, embeddings, image generation, speech-to-text, translation) on Cloudflare's GPU network and calls them…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Cloudflare Workers AI
Overview
Workers AI is Cloudflare's serverless inference service. A Worker gets an AI binding and calls env.AI.run(model, input); the same models are reachable over REST (https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/<model>) and, for chat and embedding models, through OpenAI-compatible /ai/v1/chat/completions and /ai/v1/embeddings endpoints. Models are named @cf/<vendor>/<model> and the catalog changes often, so check it before you pick one.
Billing is in Neurons: $0.011 per 1,000 Neurons, with 10,000 Neurons per day free on both the Free and Paid Workers plans (resets 00:00 UTC). Past the free allocation you need the Workers Paid plan. Some large frontier models need a paid billing method even for the first call.
Instructions
Step 1: Create the project and the binding
npm create cloudflare@latest -- support-bot-ai
cd support-bot-ai
npx wrangler vectorize create support-docs --dimensions=768 --metric=cosine
The 768 dimensions match @cf/baai/bge-base-en-v1.5; the dimension and metric of an index cannot be changed later. Add the bindings to wrangler.jsonc:
{
"ai": { "binding": "AI" },
"vectorize": [{ "binding": "VECTORIZE", "index_name": "support-docs" }]
}
wrangler.toml works too ([ai] with binding = "AI", and vectorize). Run npx wrangler types to generate the Env type, then npx wrangler dev to test (inference calls hit the real service and use your Neurons even in dev) and npx wrangler deploy to ship.
Step 2: Pick a model from the catalog
Read the current list at https://developers.cloudflare.com/workers-ai/models/ (or /workers-ai/llms.txt) and the Pricing page. Models seen there in October 2026 and used below: @cf/meta/llama-3.1-8b-instruct-fp8 (chat), @cf/baai/bge-base-en-v1.5 (embeddings), @cf/black-forest-labs/flux-1-schnell (images), @cf/openai/whisper-large-v3-turbo (speech to text), @cf/meta/m2m100-1.2b (translation). Older and larger entries such as Llama 3.3 70B, gpt-oss-120b and Qwen3 are also listed. Do not guess model names: an unknown id fails at run time.
Step 3: Call the models
// src/index.ts
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const url = new URL(request.url);
if (url.pathname === "/api/chat") {
const { messages } = await request.json<{ messages: { role: string; content: string }[] }>();
const stream = await env.AI.run("@cf/meta/llama-3.1-8b-instruct-fp8", {
messages,
max_tokens: 1024, // default is 256
stream: true,
});
return new Response(stream as ReadableStream, {
headers: { "content-type": "text/event-stream" },
});
}
if (url.pathname === "/api/image") {
const { prompt } = await request.json<{ prompt: string }>();
// flux-1-schnell: prompt up to 2048 chars, steps max 8, returns { image: base64 JPEG }
const out = await env.AI.run("@cf/black-forest-labs/flux-1-schnell", { prompt, steps: 4 });
const bytes = Uint8Array.from(atob(out.image), (c) => c.charCodeAt(0));
return new Response(bytes, { headers: { "content-type": "image/jpeg" } });
}
if (url.pathname === "/api/transcribe") {
const audio = btoa(String.fromCharCode(...new Uint8Array(await request.arrayBuffer())));
const out = await env.AI.run("@cf/openai/whisper-large-v3-turbo", { audio }); // base64 string
return Response.json({ text: out.text });
}
if (url.pathname === "/api/translate") {
const { text } = await request.json<{ text: string }>();
const out = await env.AI.run("@cf/meta/m2m100-1.2b", {
text,
source_lang: "english",
target_lang: "french",
});
return Response.json(out);
}
return new Response("Not Found", { status: 404 });
},
} satisfies ExportedHandler<Env>;
Without stream: true a chat call resolves to an object with a response string. The String.fromCharCode(...) spread above is fine for short clips only; for long audio, chunk the file (Cloudflare has a Whisper chunking tutorial).
Step 4: RAG with Vectorize
async function ingest(env: Env, docs: { id: string; text: string }[]) {
const emb = await env.AI.run("@cf/baai/bge-base-en-v1.5", { text: docs.map((d) => d.text) });
await env.VECTORIZE.upsert(
docs.map((d, i) => ({ id: d.id, values: emb.data[i], metadata: { text: d.text } })),
);
}
async function answer(env: Env, question: string) {
const q = await env.AI.run("@cf/baai/bge-base-en-v1.5", { text: [question] });
const hits = await env.VECTORIZE.query(q.data[0], { topK: 5, returnMetadata: "all" });
const context = hits.matches.map((m) => m.metadata?.text).join("\n\n");
const res = await env.AI.run("@cf/meta/llama-3.1-8b-instruct-fp8", {
messages: [
{ role: "system", content: `Answer only from this context:\n${context}` },
{ role: "user",
Установить cloudflare-ai в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл cloudflare-ai?
Cloudflare Workers AI runs open-source AI models (LLMs, embeddings, image generation, speech-to-text, translation) on Cloudflare's GPU network and calls them from a Worker binding, a REST API or an OpenAI-compatible endpoint. Use when a user asks to add serverless AI inference to a Worker, call env.AI.run, build RAG with Vectorize, stream LLM output, transcribe audio or generate images without managing GPUs, or estimate Neuron costs.
Как установить скилл cloudflare-ai?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cloudflare-ai запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic