Workers AI
Call powerful AI models with a single line of code — no GPU to buy, no server to manage.
What is Workers AI?
Workers AI lets you run ready-made, open-source AI models (chatbots, translation, image generation, speech-to-text and more) directly on Cloudflare's global network of GPUs, just by calling an API.
Normally, running an AI model means renting an expensive GPU server, installing complex software, and keeping it online 24/7. Workers AI removes all of that: Cloudflare owns the GPUs, you just send a request and get the answer back.
Think of it like a restaurant
You don't build a kitchen or hire chefs to eat a great meal — you just order from the menu. Workers AI is the kitchen of GPUs; the model catalog is the menu; you simply place your order (a request) and the dish (the answer) arrives.
Why use it?
Workers AI removes the three biggest pains of doing AI yourself: cost, complexity, and distance from your users.
No GPU to buy
GPUs cost thousands of dollars. Here you pay only for what you use, and get a free daily allowance to experiment.
Runs near users
Models run on Cloudflare's worldwide network, so answers come back fast wherever your users are.
Open-source models
Use popular open models like Llama, Mistral and Whisper without signing separate contracts with each provider.
One simple API
Every model is called the same way — swap one model name for another to switch tasks.
When should you use it?
Chatbots & assistants
Build a Q&A bot or writing helper using a large language model (LLM, 大型語言模型).
Translate & summarize
Turn text into other languages or shrink long articles into short summaries.
Generate images
Create pictures from a text description using text-to-image models.
Speech to text
Transcribe audio into text with speech models like Whisper.
Embeddings for search
Turn text into embeddings (向量, number lists that capture meaning) to power semantic search and RAG.
Classify content
Detect sentiment, tag images, or sort messages into categories automatically.
How do you start?
You'll use Wrangler, Cloudflare's command-line tool for Workers. The steps below create a Worker, connect it to AI, and deploy it.
Install Wrangler & log in
Install the CLI globally, then log in to your Cloudflare account in the browser.
npm install -g wrangler wrangler loginAdd the AI binding
A binding (繫結) is a setting that wires your Worker to a Cloudflare service. Add this to wrangler.jsonc so env.AI becomes available in your code.
{ "name": "my-ai-worker", "main": "src/index.js", "compatibility_date": "2025-06-01", "ai": { "binding": "AI" } }Call a model
Use env.AI.run() with a model name and an input. Here we ask Llama 3.1 a question.
export default { async fetch(request, env) { const result = await env.AI.run( "@cf/meta/llama-3.1-8b-instruct", { prompt: "What is Cloudflare in one sentence?" } ); return Response.json(result); } };Deploy
Publish your Worker to the world with one command.
wrangler deploy
Prefer no Worker? Use the REST API
You can also call any model straight from the command line (or any backend) with a single HTTP request and an API token.
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/@cf/meta/llama-3.1-8b-instruct \
-H "Authorization: Bearer {api_token}" \
-d '{ "prompt": "Tell me a joke" }'Key concepts
Inference 推論
Inference is the moment a trained model 'thinks' and produces an answer for your input. Each call you make is one inference.
Model catalog
A menu of 50+ models, each with an ID like @cf/meta/llama-3.1-8b-instruct. Pick one for your task.
Binding 繫結
The wiring that exposes AI inside your Worker as env.AI — no API keys to paste into your code.
Neuron 神經元
Cloudflare's unit for measuring AI usage (the GPU work a request needs). You get 10,000 free every day.
Embedding 向量
A list of numbers that captures the meaning of text. Store them in Vectorize to build search and RAG.
Tips & billing
Start free
You get 10,000 Neurons free every day (resets at 00:00 UTC). Beyond that, the paid plan is $0.011 per 1,000 Neurons — only pay for what you actually use.
- Different models cost different amounts of Neurons — bigger models cost more per request.
- Put AI Gateway in front of Workers AI to cache repeated answers and cut cost.
- Test locally with 'wrangler dev' before deploying.
- Browse all models and their IDs in the Cloudflare dashboard or docs.
Related products
menu_bookOfficial docsopen_in_new