Agent skill

Cloudflare Workers AI

by secondsky in secondsky/claude-skills

Cloudflare Workers AI for serverless GPU inference. An agent skill from secondsky/claude-skills.

MITAuto-check passedAI & LLM Engineering

Install Cloudflare Workers AI

skills CLI
$ npx skills add secondsky/claude-skills --skill cloudflare-workers-ai -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install secondsky/claude-skills cloudflare-workers-ai --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/secondsky/claude-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/cloudflare-workers-ai/skills/cloudflare-workers-ai .claude/skills/cloudflare-workers-ai && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
cloudflare-workers-ai
GitHub stars
227
Token cost
~2.4k tokens
SKILL.md length
594 words
Files
10 (incl. references)
Skills in repo
169
Repo updated
First seen
Licence
MIT

At a glance

Cloudflare Workers AI for serverless GPU inference. An agent skill from secondsky/claude-skills.

  • Works in 3 steps: Add AI Binding → Run Your First Model → Add Streaming (Recommended)
  • Text/image generation
  • SKILL.md covers Table of Contents, Quick Start (5 minutes), Workers AI API Reference and Model Selection Guide, plus 8 more sections
  • Runs TypeScript scripts from its folder; reaches api.cloudflare.com; needs CLOUDFLARE_API_KEY

What it does

Cloudflare Workers AI is an agent skill from secondsky/claude-skills. Cloudflare Workers AI for serverless GPU inference. Use for LLMs, text/image generation, embeddings, or encountering AIERROR, rate limits, token exceeded errors.

Its SKILL.md is about 2.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 11 other files, including reference files (for example `references/best-practices.md`, `references/integrations.md` and `references/models-catalog.md`).

It sits in AI & LLM Engineering, covering Rate limiting, Embeddings and Image generation. It works with Workers AI and Cloudflare Workers. The repository describes itself as: Production-ready skills for Claude Code CLI - Cloudflare, React, Tailwind v4, and AI integrations. The licence is MIT.

When your agent uses it

  • Text/image generation
  • Encountering AIERROR
  • Token exceeded errors

Example prompts

  • “/cloudflare-workers-ai”

Requirements

  • Node.js
  • A credential in CLOUDFLARE_API_KEY

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Add AI Binding
  2. Run Your First Model
  3. Add Streaming (Recommended)

What it can do on your machine

Read from SKILL.md and the folder at commit 8837836. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (TypeScript), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • api.cloudflare.com

    Also links to:

    • developers.cloudflare.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • CLOUDFLARE_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Cloudflare Workers AI loads about 2.4k tokens when it runs, and up to ~8.6k if it reads all its reference files. Until then it costs about 46 tokens; SKILL.md has 594 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~46
When it runs · the whole SKILL.md, loaded when a task matches
~2.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~8.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from secondsky/claude-skills at commit 8837836, republished under its MIT licence (© secondsky). 594 words, ~2,441 tokens.

Download SKILL.mdSave it as .claude/skills/cloudflare-workers-ai/SKILL.md (or your agent's skills folder). This skill also uses 9 other files; get the full folder from GitHub.
name
cloudflare-workers-ai
description
Cloudflare Workers AI for serverless GPU inference. Use for LLMs, text/image generation, embeddings, or encountering AI_ERROR, rate limits, token exceeded errors.
metadata.keywords
workers ai, cloudflare ai, ai bindings, llm workers, @cf/meta/llama, workers ai models, ai inference, cloudflare llm, ai streaming, text generation ai, ai…
license
MIT

Cloudflare Workers AI - Complete Reference

Production-ready knowledge domain for building AI-powered applications with Cloudflare Workers AI.

Status: Production Ready ✅ Last Updated: 2025-11-21 Dependencies: cloudflare-worker-base (for Worker setup) Latest Versions: wrangler@4.81.0, @cloudflare/workers-types@4.20260408.0


Table of Contents

  1. Quick Start (5 minutes)
  2. Workers AI API Reference
  3. Model Selection Guide
  4. Common Patterns
  5. AI Gateway Integration
  6. Rate Limits & Pricing
  7. Production Checklist

Quick Start (5 minutes)

1. Add AI Binding

wrangler.jsonc:

jsonc
{
  "ai": {
    "binding": "AI"
  }
}
2. Run Your First Model
typescript
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    const response = await env.AI.run('@cf/meta/llama-3.1-8b-instruct', {
      prompt: 'What is Cloudflare?',
    });

    return Response.json(response);
  },
};
typescript
const stream = await env.AI.run('@cf/meta/llama-3.1-8b-instruct', {
  messages: [{ role: 'user', content: 'Tell me a story' }],
  stream: true, // Always use streaming for text generation!
});

return new Response(stream, {
  headers: { 'content-type': 'text/event-stream' },
});

Why streaming?

  • Prevents buffering large responses in memory
  • Faster time-to-first-token
  • Better user experience for long-form content
  • Avoids Worker timeout issues

Workers AI API Reference

Core API: env.AI.run()
typescript
const response = await env.AI.run(model, inputs, options?);
ParameterTypeDescription
modelstringModel ID (e.g., @cf/meta/llama-3.1-8b-instruct)
inputsobjectModel-specific inputs (see model type below)
options.gateway.idstringAI Gateway ID for caching/logging
options.gateway.skipCachebooleanSkip AI Gateway cache

Returns: Promise<ModelOutput> (non-streaming) or ReadableStream (streaming)

Input Types by Model Category
CategoryKey InputsOutput
Text Generationmessages[], stream, max_tokens, temperature{ response: string }
Embeddingstext: string | string[]{ data: number[][], shape: number[] }
Image Generationprompt, num_steps, guidanceBinary PNG
Visionmessages[].content[].image_url{ response: string }

📄 Full model details: Load references/models-catalog.md for complete model list, parameters, and rate limits.


Model Selection Guide

Text Generation (LLMs)
ModelBest ForRate LimitSize
@cf/meta/llama-3.1-8b-instructGeneral purpose, fast300/min8B
@cf/meta/llama-3.2-1b-instructUltra-fast, simple tasks300/min1B
@cf/qwen/qwen1.5-14b-chat-awqHigh quality, complex reasoning150/min14B
@cf/deepseek-ai/deepseek-r1-distill-qwen-32bCoding, technical content300/min32B
@hf/thebloke/mistral-7b-instruct-v0.1-awqFast, efficient400/min7B
Text Embeddings
ModelDimensionsBest ForRate Limit
@cf/baai/bge-base-en-v1.5768General purpose RAG3000/min
@cf/baai/bge-large-en-v1.51024High accuracy search1500/min
@cf/baai/bge-small-en-v1.5384Fast, low storage3000/min
Image Generation
ModelBest ForRate LimitSpeed
@cf/black-forest-labs/flux-1-schnellHigh quality, photorealistic720/minFast
@cf/stabilityai/stable-diffusion-xl-base-1.0General purpose720/minMedium
@cf/lykon/dreamshaper-8-lcmArtistic, stylized720/minFast
Vision Models
ModelBest ForRate Limit
@cf/meta/llama-3.2-11b-vision-instructImage understanding720/min
@cf/unum/uform-gen2-qwen-500mFast image captioning720/min

Common Patterns

Pattern 1: Chat with Streaming
typescript
app.post('/chat', async (c) => {
  const { messages } = await c.req.json<{ messages: Array<{ role: string; content: string }> }>();
  const stream = await c.env.AI.run('@cf/meta/llama-3.1-8b-instruct', { messages, stream: true });
  return new Response(stream, { headers: { 'content-type': 'text/event-stream' } });
});
Pattern 2: RAG (Retrieval Augmented Generation)
typescript
// 1. Generate embedding for query
const embeddings = await env.AI.run('@cf/baai/bge-base-en-v1.5', { text: [userQuery] });
// 2. Search Vectorize
const matches = await env.VECTORIZE.query(embeddings.data[0], { topK: 3 });
// 3. Build context
const context = matches.matches.map((m) => m.metadata.text).join('\n\n');
// 4. Generate with context
const stream = await env.AI.run('@cf/meta/llama-3.1-8b-instruct', {
  messages: [
    { role: 'system', content: `Answer using this context:\n${context}` },
    { role: 'user', content: userQuery },
  ],
  stream: true,
});
return new Response(stream, { headers: { 'content-type': 'text/event-stream' } });

📄 More patterns: Load references/best-practices.md for structured output, image generation, multi-model consensus, and production patterns.


AI Gateway Integration

Enable caching, logging, and cost tracking with AI Gateway:

typescript
const response = await env.AI.run('@cf/meta/llama-3.1-8b-instruct', { prompt: 'Hello' }, {
  gateway: { id: 'my-gateway', skipCache: false },
});

Benefits: Cost tracking, response caching (50-90% savings on repeated queries), request logging, rate limiting, analytics.


Show full SKILL.md (240 more words)Show less

Rate Limits & Pricing

Information last verified: 2025-01-14

Rate limits and pricing vary significantly by model. Always check the official documentation for the most current information:

Free Tier: 10,000 neurons/day Paid Tier: $0.011 per 1,000 neurons

📄 Per-model details: See references/models-catalog.md for specific rate limits and pricing for each model.


Production Checklist

Essential before deploying:

  • Enable AI Gateway for cost tracking
  • Implement streaming for text generation
  • Add rate limit retry with exponential backoff
  • Validate input length (prevent token limit errors)
  • Add input sanitization (prevent prompt injection)

📄 Full checklist: Load references/best-practices.md for complete production checklist, error handling patterns, monitoring, and cost optimization.


External SDK Integrations

Workers AI supports OpenAI SDK compatibility and Vercel AI SDK:

typescript
// OpenAI SDK - use same patterns with Workers AI models
const openai = new OpenAI({
  apiKey: env.CLOUDFLARE_API_KEY,
  baseURL: `https://api.cloudflare.com/client/v4/accounts/${env.CLOUDFLARE_ACCOUNT_ID}/ai/v1`,
});

// Vercel AI SDK - native integration
import { createWorkersAI } from 'workers-ai-provider';
const workersai = createWorkersAI({ binding: env.AI });

📄 Full integration guide: Load references/integrations.md for OpenAI SDK, Vercel AI SDK, and REST API examples.


Limits Summary

FeatureLimit
Concurrent requestsNo hard limit (rate limits apply)
Max input tokensVaries by model (typically 2K-128K)
Max output tokensVaries by model (typically 512-2048)
Streaming chunk size~1 KB
Image size (output)~5 MB
Request timeoutWorkers timeout applies (30s default, 5m max CPU)
Daily free neurons10,000
Rate limitsSee "Rate Limits & Pricing" section

When to Load References

Reference FileLoad When...
references/models-catalog.mdChoosing a model, checking rate limits, comparing model capabilities
references/best-practices.mdProduction deployment, error handling, cost optimization, security
references/integrations.mdUsing OpenAI SDK, Vercel AI SDK, or REST API instead of native binding

References

© secondsky, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 9 other files (references) in plugins/cloudflare-workers-ai/skills/cloudflare-workers-ai of secondsky/claude-skills.

  • SKILL.md
  • references/best-practices.md
  • references/integrations.md
  • references/models-catalog.md
  • templates/ai-embeddings-rag.ts
  • templates/ai-gateway-integration.ts
  • templates/ai-image-generation.ts
  • templates/ai-text-generation.ts
  • templates/ai-vision-models.ts
  • templates/wrangler-ai-config.jsonc

Open the folder on GitHubat commit 8837836

Compare with similar skills

Cloudflare Workers AI next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Cloudflare Workers AI compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cloudflare Workers AI this skillsecondsky/claude-skills227—~2.4kAutomated safety check: PassMIT
Local AI App Integrationamd/skills395—~6kAutomated safety check: PassMIT
Openai APIynulihao/AgentSkillOS6171 repos~5.9kAutomated safety check: NotesNone
Apikerhodgef/apiker127—~1.4kAutomated safety check: PassMIT
Upstash Redisgithub/awesome-copilot40k—~1.7kAutomated safety check: PassMIT
Cloudflare Worker Devcuriositech/some_claude_skills243—~3.4kAutomated safety check: NotesMIT

Similar skills

  • Integrates local AI capabilities into applications using Embeddable Lemonade.

    395 GitHub stars~6k tokensUpdated today
    Media & CreativeAuto-check passed
  • Openai API

    ynulihao/AgentSkillOS

    Build with OpenAI's stateless APIs - Chat Completions (GPT-5, GPT-4o), Embeddings, Images (DALL-E 3), Audio (Whisper + TTS), and Moderation.

    617 GitHub starsUsed in 1 repo~5.9k tokens
    AI & LLM EngineeringAuto-check: notes
  • Apiker

    hodgef/apiker

    Develop, review, and extend the Apiker library — a framework for building serverless REST APIs on Cloudflare Workers + Durable Objects.

    127 GitHub stars~1.4k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • Upstash Redis

    github/awesome-copilot

    Official

    Use Redis over HTTP from serverless and edge runtimes with @upstash/redis, and add rate limiting with @upstash/ratelimit.

    40k GitHub stars~1.7k tokensUpdated today
    Backend & APIsAuto-check passed
  • Cloudflare Worker Dev

    curiositech/some_claude_skills

    Cloudflare Workers, KV, Durable Objects, and edge computing development.

    243 GitHub stars~3.4k tokensUpdated 1 mo ago
    Backend & APIsAuto-check: notes
  • Databricks Model Serving

    databricks/databricks-agent-skills

    Official

    Databricks Model Serving endpoint lifecycle and ops. An agent skill from databricks/databricks-agent-skills.

    345 GitHub starsUsed in 1 repo~3.3k tokens
    AI & LLM EngineeringAuto-check passed

More from secondsky/claude-skills

All 169 skills in this repo
  • Tanstack AI

    secondsky/claude-skills

    TanStack AI (alpha) provider-agnostic type-safe chat with streaming for OpenAI, Anthropic, Gemini, Ollama.

    227 GitHub starsUsed in 1 repo~3.6k tokens
    Auto-check: notes
  • Auto Animate

    secondsky/claude-skills

    AutoAnimate (@formkit/auto-animate) zero-config animations for React.

    227 GitHub stars~2.9k tokensUpdated 9 days ago
    Auto-check passed
  • Base UI React

    secondsky/claude-skills

    MUI Base UI unstyled React components with Floating UI. An agent skill from secondsky/claude-skills.

    227 GitHub stars~1.9k tokensUpdated 9 days ago
    Auto-check passed
  • Cloudflare Images

    secondsky/claude-skills

    This skill should be used when the user asks to "upload images to Cloudflare", "implement direct creator upload", "configure image transformations", "optimize WebP/AVIF", "create image variants"…

    227 GitHub stars~3.6k tokensUpdated 9 days ago
    Auto-check: notes
  • Cloudflare Nextjs

    secondsky/claude-skills

    Deploy Next.js to Cloudflare Workers via the OpenNext adapter (@opennextjs/cloudflare).

    227 GitHub stars~5.3k tokensUpdated 9 days ago
    Auto-check: notes
  • Cloudflare Sandbox

    secondsky/claude-skills

    Cloudflare Sandboxes SDK for secure code execution in Linux containers at edge.

    227 GitHub stars~4.5k tokensUpdated 9 days ago
    Auto-check passed

Questions about Cloudflare Workers AI

What does Cloudflare Workers AI do?

Cloudflare Workers AI for serverless GPU inference. An agent skill from secondsky/claude-skills. Cloudflare Workers AI is an agent skill from secondsky/claude-skills. Cloudflare Workers AI for serverless GPU inference.

When should I use Cloudflare Workers AI?

Cloudflare Workers AI fits situations like: text/image generation; encountering AIERROR; token exceeded errors.

How do I install Cloudflare Workers AI in Claude Code?

Run `npx skills add secondsky/claude-skills --skill cloudflare-workers-ai -a claude-code`. Or copy the skill folder (plugins/cloudflare-workers-ai/skills/cloudflare-workers-ai in secondsky/claude-skills) into .claude/skills/cloudflare-workers-ai in your project. Claude Code loads it when a task matches its description.

How do I install Cloudflare Workers AI in Codex?

Run `npx skills add secondsky/claude-skills --skill cloudflare-workers-ai -a codex`. Or copy the skill folder (plugins/cloudflare-workers-ai/skills/cloudflare-workers-ai in secondsky/claude-skills) into .agents/skills/cloudflare-workers-ai in your project. Codex loads it when a task matches its description.

Can I use Cloudflare Workers AI in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add secondsky/claude-skills --skill cloudflare-workers-ai -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cloudflare-workers-ai, .gemini/skills/cloudflare-workers-ai, .github/skills/cloudflare-workers-ai and .opencode/skills/cloudflare-workers-ai in your project.

What does Cloudflare Workers AI need to run?

Going by SKILL.md and its folder, Cloudflare Workers AI needs TypeScript for the scripts in its folder and credentials named CLOUDFLARE_API_KEY. Our summary lists: Node.js; A credential in CLOUDFLARE_API_KEY.

Does Cloudflare Workers AI access the network?

SKILL.md names 2 domains. In commands or code: api.cloudflare.com; the agent is likely to contact it when it follows the instructions. As links in the text: developers.cloudflare.com. This is read from the text; nothing was executed.

Is Cloudflare Workers AI safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Cloudflare Workers AI use?

Cloudflare Workers AI is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Cloudflare Workers AI use?

About 2.4k tokens (SKILL.md is roughly 9.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 6.2k tokens, read only when the agent opens those files.

What are the alternatives to Cloudflare Workers AI?

Skills that share tags, products or a category with Cloudflare Workers AI: Local AI App Integration (amd/skills, 395 stars), Openai API (ynulihao/AgentSkillOS, 617 stars), Apiker (hodgef/apiker, 127 stars) and Upstash Redis (github/awesome-copilot, 40k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cloudflare Workers AI?

secondsky (a GitHub user) maintains it in secondsky/claude-skills, which has 227 GitHub stars. The repository holds 169 skills in this directory. The repository was last updated on September 28, 2026.

Source: secondsky/claude-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.