Serverless AI inference
How to use
Cloudflare Workers AI.
Running open-source text, embedding, image, speech, and classification models in serverless Workers and combining them with AI Gateway and Vectorize.
Cloudflare Workers AI is a serverless GPU inference platform for running AI models on Cloudflare's global network. Running open-source text, embedding, image, speech, and classification models in serverless Workers and combining them with AI Gateway and Vectorize. This guide covers the whole path in one place: official access, a first session that produces something reviewable, the checks that make output trustworthy, and the permissions worth limiting before you connect real work.
AI should make the work easier to inspect. If the workflow removes the source, the owner, or the review step, redesign the workflow.
Access & setup
Find, install, and sign in to Cloudflare Workers AI
Get into the official Cloudflare Workers AI experience with the right account and a setup you understand.
- 01
Start at https://developers.cloudflare.com/workers-ai/ and confirm the domain before entering account or payment information.
- 02
Availability: Workers AI is available through Workers bindings, the Cloudflare REST API, dashboard, Wrangler development tooling, and integrations with AI Gateway and Vectorize.
- 03
A Cloudflare account, Worker or scoped API token and account ID, an approved catalog model, Wrangler for local development where used, and usage controls.
- 04
Sign in with the account you intend to keep using, then review plan, data, notification, and permission settings.
- 05
Run one low-risk test task before connecting sensitive files, repositories, or workspace data.
- Use official download pages.
- Review permissions during setup.
- Keep installers and applications updated.
First session
Your first useful Cloudflare Workers AI session
Learn the interaction loop using a small task with a clear outcome.
- 01
Create a development Worker and add a Workers AI binding without exposing account credentials to the client.
- 02
Choose a catalog model for one narrow task and record its ID, input schema, limits, pricing, and license information.
- 03
Implement a validated test endpoint with authentication, bounded inputs and outputs, timeouts, and structured errors.
- 04
Run quality, safety, latency, rate-limit, and cost fixtures before deploying the endpoint or retaining user data.
- State the outcome before the background.
- Provide the real source material.
- Review the result before expanding the task.
Quality control
Check the quality of Cloudflare Workers AI output
Establish that a change is safe to run in production and reversible if it is not.
- 01
Restate the intended end state and the blast radius before applying anything.
- 02
Review the generated configuration line by line against the provider's current documentation.
- 03
Apply to a non-production environment first and confirm the observed result matches the intended one.
- 04
Confirm the rollback path works by actually exercising it, not by assuming it exists.
- 05
Check cost, scaling limits, and network exposure before the change reaches production traffic.
- Test the rollback, do not assume it.
- Check what a configuration exposes to the public internet.
- Watch cost and rate limits as closely as correctness.
Privacy & permissions
Use Cloudflare Workers AI safely
Keep credentials, network exposure, and cost under deliberate control.
- 01
Use scoped, short-lived credentials, and never paste production secrets into a prompt or config file.
- 02
Confirm what each change exposes publicly before applying it, especially storage, databases, and admin endpoints.
- 03
Separate environments so a mistake in development cannot reach production data.
- 04
Set billing alerts and hard quotas before enabling autoscaling or usage-based services.
- 05
Review audit logs and revoke access for integrations that are no longer in use.
- Serverless inference can still expose sensitive inputs, unsafe outputs, public endpoints, logs, and unbounded cost. Protect bindings and tokens, authenticate and validate Workers, pin and benchmark model IDs, understand model licenses and limits, minimize logs and caching for sensitive data, set AI Gateway rate and spend controls, make retries safe, and preserve source identity and access rules in Vectorize.
- Follow your organisation's approved-use policy.
- Never treat fluent output as authorization to act.
Core workflows
Step-by-step ways to use Cloudflare Workers AI for the work it does best.
Each workflow below has its own outcome, steps and review checkpoints.
Run a catalog model from a Cloudflare Worker with protected bindings, validation, Gateway controls, and production limits.
↓ 02 WorkflowBuild a source-aware RAG service with Workers AI and VectorizeCreate embeddings, index governed records in Vectorize, retrieve context, and generate answers with traceable evidence.
↓Workflow 01
Deploy a controlled Workers AI inference endpoint
Run a catalog model from a Cloudflare Worker with protected bindings, validation, Gateway controls, and production limits.
Outcome: Expose a stable AI endpoint without leaking credentials or allowing unbounded requests, output, retries, or spend.
- 01
Define the task, model requirements, input and output schema, abuse cases, latency target, traffic limits, retention, and budget.
- 02
Create a development Worker with an AI binding or least-privilege REST token, keeping secrets in bindings and separate from code and clients.
- 03
Pin a catalog model and validate request size and type, authentication, generation limits, response schema, errors, and timeouts in the Worker.
- 04
Test quality, safety, streaming, concurrency, throttling, retries, and model changes with fixtures before exposing the endpoint publicly.
- 05
Add AI Gateway observability and appropriate caching, rate and spend limits, redact logs, deploy gradually, and keep a tested fallback.
What good use looks like
- Keep inference behind a validated Worker.
- Pin and benchmark catalog models.
- Set rate and spend limits before launch.
Workflow 02
Build a source-aware RAG service with Workers AI and Vectorize
Create embeddings, index governed records in Vectorize, retrieve context, and generate answers with traceable evidence.
Outcome: Operate a compact edge RAG service whose vector configuration, sources, access rules, and refresh lifecycle are controlled.
- 01
Define corpus ownership, permissions, update and deletion rules, benchmark queries, source citations, and the approved Worker and storage boundaries.
- 02
Choose an embedding model, dimensions, distance metric, namespaces, and metadata schema before creating separate development and production indexes.
- 03
Chunk approved documents, create stable vector IDs linked to source objects, generate embeddings, and upsert records with minimal searchable metadata.
- 04
Embed queries with the same model, apply namespace and metadata filters, retrieve candidates, and pass only verified context to generation.
- 05
Evaluate recall and answer support, handle asynchronous index updates, test deletion and model migration, and monitor query latency and inference spend.
What good use looks like
- Fix dimensions and metric deliberately.
- Map every vector to a source object.
- Test asynchronous updates and deletions.
Official references
Check the current product documentation.
Features, plan limits, availability, and data controls change. These official pages are the starting points used for this guide.