{"id":18137,"date":"2026-07-13T12:50:53","date_gmt":"2026-07-13T05:50:53","guid":{"rendered":"https:\/\/www.cipher.co.th\/blogs\/cloudflare-workers-ai-vs-openai-2\/"},"modified":"2026-07-13T12:50:53","modified_gmt":"2026-07-13T05:50:53","slug":"cloudflare-workers-ai-vs-openai","status":"publish","type":"post","link":"https:\/\/www.cipher.co.th\/en\/blogs\/cloudflare-workers-ai-vs-openai\/","title":{"rendered":"Cloudflare Workers AI vs the OpenAI API: When to Run Models at the Edge"},"content":{"rendered":"<p><strong>Quick answer:<\/strong> Use Workers AI when the task is small and you run it a lot: classification, embeddings, moderation, transcription and short summarisation. The model runs inside the same network as your Worker, so there is no round trip to an external provider and your content never leaves the platform. Use the OpenAI API when the task needs frontier-grade reasoning: analysing long documents, writing code, or agents that plan across several steps. The open models on Workers AI are meaningfully smaller and weaker, and they are not a drop-in substitute. The pragmatic middle path for most teams is to keep calling OpenAI but put AI Gateway in front of it for caching, rate limiting and observability.<\/p>\n<p>The Workers AI versus OpenAI question is usually framed as a contest, and that framing is wrong. Real systems use both. What matters is not which model is smarter in the abstract, but which task you are running, how many times per day you run it, and what constraints apply to the data.<\/p>\n<p>This article compares them on the things an engineering lead actually has to decide: architecture, billing model, latency, data handling and published limits. Every price and limit here comes from the official Cloudflare and OpenAI documentation and is current as of July 2026. Prices change; check the source pages before you commit a budget.<\/p>\n<h2>Two architectures that differ at the root<\/h2>\n<h3>Workers AI: the model lives on the same network as your code<\/h3>\n<p>Workers AI is GPU capacity that Cloudflare operates inside its own network. When your Worker calls the AI binding, the request does not leave over the public internet to a third-party endpoint. It stays inside the same network your code is already running in.<\/p>\n<p>Three consequences follow. There is no TLS handshake across a continent. There is no third-party API key to rotate, scope and leak. And the content you send to the model does not leave the boundary of the platform you already use, which matters when your legal or compliance team asks where customer data goes.<\/p>\n<p>Billing is measured in Neurons, priced at 0.011 USD per 1,000 Neurons, with 10,000 Neurons per day included free on both the Workers Free and Workers Paid plans. Cloudflare also publishes each model rate in dollars per million tokens, which makes it directly comparable to any other inference provider.<\/p>\n<h3>OpenAI API: the code is at the edge, the model is on another continent<\/h3>\n<p>When a Worker calls OpenAI, what happens is a subrequest that leaves the Cloudflare network, travels to an OpenAI endpoint, and comes back. The upside is that you get one of the strongest models in the world. The downside is an extra network hop in the request path, plus the fact that your user content is now being sent to a second vendor, which is something you have to be able to explain in a data-handling policy.<\/p>\n<p>The point most teams get wrong is the cost of waiting. Workers bills CPU time, not wall-clock time. The seconds a Worker spends idle waiting for an OpenAI response are not billed as CPU time. Being a thin proxy in front of OpenAI is therefore very cheap on the compute side. If you are still reasoning about serverless cost as duration multiplied by memory, the billing model comparison in <a href=\"https:\/\/www.cipher.co.th\/en\/blogs\/cloudflare-workers-vs-aws-lambda\/\">Cloudflare Workers vs AWS Lambda<\/a> is worth reading first.<\/p>\n<p>What you do have to design around are the other Worker limits. A single Worker can hold a maximum of 6 simultaneous outgoing connections, which bites the moment you fan out parallel calls to a model provider. Memory is 128 MB per isolate on both Free and Paid and cannot be raised, so you cannot hold many large payloads in memory at once. The full set of edges is covered in <a href=\"https:\/\/www.cipher.co.th\/en\/blogs\/when-not-to-use-cloudflare-workers\/\">when not to use Cloudflare Workers<\/a>.<\/p>\n<h2>The blunt part: Cloudflare models are smaller and weaker<\/h2>\n<p>This is where most vendor-adjacent content goes soft, so let us not. The Workers AI catalogue is open-weight models: the Llama family, Mistral, Qwen, Gemma, the gpt-oss models and others. These have improved a great deal over the past two years. They are still not frontier models.<\/p>\n<p>If your task is to read a 40-page contract and explain which clause creates a liability, to write correct application code, or to run an agent that plans a multi-step job and recovers when a step fails, a frontier model wins clearly and the gap is not marginal. Do not deploy a 8B open model into that job and hope. It will demo acceptably and then fail in an embarrassing way on the long tail of real inputs, which is the worst possible failure mode.<\/p>\n<p>The reverse is equally true. Calling a frontier model to decide whether a support message is about shipping or about billing is spending a large amount of money on a capability you are not using. Classification, toxicity checks, sentiment, embeddings, transcription and one-paragraph summarisation are jobs a small model does well, and they are jobs where latency and unit cost matter far more than raw intelligence.<\/p>\n<h2>Pricing as of July 2026<\/h2>\n<p>The tables below are taken directly from the Cloudflare and OpenAI pricing pages in July 2026. Both vendors change prices; treat these as a snapshot, not a contract.<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<thead>\n<tr>\n<th>Workers AI model<\/th>\n<th>Input (per M tokens)<\/th>\n<th>Output (per M tokens)<\/th>\n<th>Good for<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>@cf\/meta\/llama-3.2-1b-instruct<\/td>\n<td>0.027 USD<\/td>\n<td>0.201 USD<\/td>\n<td>Routing, tagging, very high volume<\/td>\n<\/tr>\n<tr>\n<td>@cf\/meta\/llama-3.1-8b-instruct-fp8-fast<\/td>\n<td>0.045 USD<\/td>\n<td>0.384 USD<\/td>\n<td>Summarisation, triage, short answers<\/td>\n<\/tr>\n<tr>\n<td>@cf\/openai\/gpt-oss-20b<\/td>\n<td>0.200 USD<\/td>\n<td>0.300 USD<\/td>\n<td>Tasks needing moderate reasoning<\/td>\n<\/tr>\n<tr>\n<td>@cf\/openai\/gpt-oss-120b<\/td>\n<td>0.350 USD<\/td>\n<td>0.750 USD<\/td>\n<td>The strongest open model in the catalogue<\/td>\n<\/tr>\n<tr>\n<td>@cf\/baai\/bge-m3 (embeddings)<\/td>\n<td>0.012 USD<\/td>\n<td>No output tokens<\/td>\n<td>Vectors for semantic search<\/td>\n<\/tr>\n<tr>\n<td>@cf\/meta\/llama-guard-3-8b<\/td>\n<td>0.484 USD<\/td>\n<td>0.030 USD<\/td>\n<td>Content moderation, prompt screening<\/td>\n<\/tr>\n<tr>\n<td>@cf\/huggingface\/distilbert-sst-2-int8<\/td>\n<td>0.026 USD<\/td>\n<td>No output tokens<\/td>\n<td>Sentiment classification<\/td>\n<\/tr>\n<tr>\n<td>@cf\/openai\/whisper<\/td>\n<td colspan=\"2\">0.0005 USD per audio minute<\/td>\n<td>Speech to text<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>On the OpenAI side, the rates below are standard short-context pricing per million tokens as of July 2026. Routing work through the Batch API roughly halves these numbers, at the cost of latency.<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<thead>\n<tr>\n<th>OpenAI model<\/th>\n<th>Input (per M tokens)<\/th>\n<th>Cached input<\/th>\n<th>Output (per M tokens)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>gpt-5.6-sol<\/td>\n<td>5.00 USD<\/td>\n<td>0.50 USD<\/td>\n<td>30.00 USD<\/td>\n<\/tr>\n<tr>\n<td>gpt-5.6-terra<\/td>\n<td>2.50 USD<\/td>\n<td>0.25 USD<\/td>\n<td>15.00 USD<\/td>\n<\/tr>\n<tr>\n<td>gpt-5.6-luna<\/td>\n<td>1.00 USD<\/td>\n<td>0.10 USD<\/td>\n<td>6.00 USD<\/td>\n<\/tr>\n<tr>\n<td>gpt-5.4-mini<\/td>\n<td>0.75 USD<\/td>\n<td>0.075 USD<\/td>\n<td>4.50 USD<\/td>\n<\/tr>\n<tr>\n<td>gpt-5.4-nano<\/td>\n<td>0.20 USD<\/td>\n<td>0.02 USD<\/td>\n<td>1.25 USD<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>Put the two tables next to each other and the shape is clear. Even gpt-5.4-nano, the cheapest model OpenAI publishes, costs roughly four times more per input token than llama-3.1-8b-instruct-fp8-fast on Workers AI, and about three times more per output token. And the model you actually want when quality matters is several rows further up. That is the arithmetic that makes routing by task difficulty a much larger lever than switching providers.<\/p>\n<h2>Where Workers AI genuinely wins<\/h2>\n<h3>Latency<\/h3>\n<p>Inference that happens on the same network as the Worker removes an entire round trip to an external endpoint. For users in Thailand calling a model whose endpoint sits in the United States, that is not a rounding error, and it is a fixed cost paid on every single request regardless of how fast the model itself is. The effect compounds for pipelines that call a small model several times inside one request, for example embed, then classify, then rank.<\/p>\n<h3>Privacy and staying inside one trust boundary<\/h3>\n<p>Cloudflare documents in its Workers AI data usage page that Cloudflare does not use your Customer Content to train the models available on Workers AI, does not use it to improve Cloudflare or third-party services without your explicit consent, and does not make your content available to any other Cloudflare customer. It is worth being precise about what this does and does not say: Cloudflare neither creates nor trains these models, and the models themselves are third-party services under their own licence terms, which you should read.<\/p>\n<p>What this buys you in practice is a defensible answer when legal asks where the data goes. Content processed by Workers AI stays within the platform your application already runs on. For public sector work, insurance, or financial services in Thailand, being able to draw one trust boundary instead of two is often the deciding argument, independent of price.<\/p>\n<h3>Unit cost at volume on small tasks<\/h3>\n<p>If you are embedding a product catalogue of hundreds of thousands of items, or moderating every comment on a busy platform, the cost curve is what decides the design, not the per-request price. This is exactly where Workers AI earns its place. Pair it with Vectorize, which is billed at 0.01 USD per million queried vector dimensions and 0.05 USD per 100 million stored vector dimensions, with 50 million queried and 10 million stored dimensions included on Workers Paid, and no egress charges at all.<\/p>\n<h2>AI Gateway: the middle path most teams should start with<\/h2>\n<p>You do not have to pick a side this week. AI Gateway is a proxy that sits in front of model providers, including OpenAI. You change a base URL; the code behind it stays as it is. In return you get caching, rate limiting, logs and analytics in one place. AI Gateway core features are free on all plans as of July 2026.<\/p>\n<p>The numbers worth knowing: persistent logs hold 100,000 entries in total across all gateways on Workers Free, and 10,000,000 entries per gateway on Workers Paid. Guardrails, which screen prompts and responses, run llama-guard-3-8b on Workers AI and are billed as Workers AI token inference, so the cost scales with the length of what you are screening. If you use Unified Billing to buy provider credits through Cloudflare, a 5 percent fee applies to credits purchased, while the provider inference rates themselves are passed through with no markup.<\/p>\n<p>The recommendation is straightforward. If you already call OpenAI directly from your backend, putting AI Gateway in front is a single afternoon of work, and it will immediately tell you which prompts are repeated, which are expensive, and what your real cache hit rate is. That data is what you need before you have any sensible argument about moving models at all.<\/p>\n<h2>A worked example: support ticket triage for an e-commerce business<\/h2>\n<p>Take an online retailer handling 200,000 support tickets per month. Most tickets are repetitive questions: where is my order, how do I return this item, which size should I buy. A minority are genuinely complex, for example a dispute about a payment.<\/p>\n<p><strong>Approach A, send everything to a frontier model.<\/strong> Assume gpt-5.6-terra at 2,000 input tokens and 500 output tokens per ticket. Input totals 400 million tokens at 2.50 USD per million, which is 1,000 USD. Output totals 100 million tokens at 15.00 USD per million, which is 1,500 USD. That is roughly 2,500 USD per month.<\/p>\n<p><strong>Approach B, triage on Workers AI and escalate.<\/strong> Send every ticket to llama-3.1-8b-instruct-fp8-fast to classify it and draft a short answer: 400 input tokens and 60 output tokens each. Input totals 80 million tokens at 0.045 USD per million, which is 3.60 USD. Output totals 12 million tokens at 0.384 USD per million, which is 4.61 USD. That is about 8.20 USD. Then escalate only the 5 percent the small model flags as complex, that is 10,000 tickets, to gpt-5.6-terra at 2,000 input and 500 output tokens: 50 USD of input plus 75 USD of output, which is 125 USD. Total for Approach B is roughly 133 USD per month.<\/p>\n<p>That is close to a twentyfold difference, and the quality of the answers in the cases that matter is unchanged, because those cases still reach the strong model. What you have paid for is the complexity of one extra hop in the code and the risk that the classifier is wrong. That risk is manageable: set the escalation threshold to be biased toward escalating when uncertain, and measure the rate.<\/p>\n<p>One limit to design around. Workers AI rate limits are set per task type. Text generation defaults to 300 requests per minute, and text embeddings to 3,000 requests per minute. Averaged out, 200,000 tickets per month is only about 4 or 5 requests per minute, which is comfortable. But if you have a peak-hour spike, or you backfill historical data in a batch, you will hit that ceiling. Put a queue in front, or request a higher limit from Cloudflare, before you find out in production.<\/p>\n<h2>When OpenAI is simply the right answer<\/h2>\n<p>There are cases where choosing Workers AI is a clear engineering mistake, and knowing them in advance saves you a wasted sprint.<\/p>\n<p><strong>Multi-step reasoning and agents.<\/strong> If your agent must plan, call tools, evaluate the result and adapt, small models fall apart in the middle of the chain. The usual failure is calling the wrong tool, or repeating a loop it has already run. Frontier models are noticeably more reliable here, and reliability is the whole product.<\/p>\n<p><strong>Long-context work with high accuracy requirements.<\/strong> Reading a 100-page document and answering which paragraph contains a given obligation is a task a small model can appear to do while being wrong in ways that are expensive to detect.<\/p>\n<p><strong>Capabilities that do not exist in the open catalogue.<\/strong> High-quality code generation, strong multimodal reasoning, and API-level features such as strict structured-output schemas are reasons to stay with the commercial provider.<\/p>\n<p><strong>Provider independence.<\/strong> If your team wants to avoid being locked to one model vendor, note that binding to Cloudflare is still binding to a host you do not control. Models can be removed from the catalogue, exactly as they can from any other provider. AI Gateway helps here too, because it gives you one place to switch providers rather than a change scattered across your codebase.<\/p>\n<h2>Decision table<\/h2>\n<figure class=\"wp-block-table\">\n<table>\n<thead>\n<tr>\n<th>If you need<\/th>\n<th>Use<\/th>\n<th>Why<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Classification, tagging, routing at high volume<\/td>\n<td>Workers AI<\/td>\n<td>Small models are accurate enough and cost an order of magnitude less<\/td>\n<\/tr>\n<tr>\n<td>Embeddings for semantic search<\/td>\n<td>Workers AI plus Vectorize<\/td>\n<td>Very low per-token rate and no egress charges<\/td>\n<\/tr>\n<tr>\n<td>Content moderation and prompt screening<\/td>\n<td>Workers AI (llama-guard) or AI Gateway Guardrails<\/td>\n<td>Already inside the request path<\/td>\n<\/tr>\n<tr>\n<td>Speech to text in bulk<\/td>\n<td>Workers AI (whisper)<\/td>\n<td>Billed per audio minute, so the cost is predictable<\/td>\n<\/tr>\n<tr>\n<td>Reading long documents and reasoning about them<\/td>\n<td>OpenAI<\/td>\n<td>Small models fail on the cases that are hard to verify<\/td>\n<\/tr>\n<tr>\n<td>Agents that plan and call tools over many steps<\/td>\n<td>OpenAI<\/td>\n<td>Requires frontier-grade reasoning to stay reliable<\/td>\n<\/tr>\n<tr>\n<td>Writing or reviewing code<\/td>\n<td>OpenAI<\/td>\n<td>The quality gap is still wide<\/td>\n<\/tr>\n<tr>\n<td>Already on OpenAI, but with no visibility into cost<\/td>\n<td>AI Gateway in front of OpenAI<\/td>\n<td>Caching, rate limiting and logs without moving models<\/td>\n<\/tr>\n<tr>\n<td>Data that must not leave for a second vendor<\/td>\n<td>Workers AI<\/td>\n<td>Processing stays on the same platform as the app<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h2>Practical recommendation<\/h2>\n<p>Start by segmenting the work, not by choosing a model. Push the repetitive, high-volume, low-difficulty tasks to a small model running on the same network as your code. Keep the hard, low-volume tasks on the strongest model you can afford. Put a gateway in the middle so that you can see what is actually happening. That shape makes the bill roughly an order of magnitude smaller without conceding quality where quality counts.<\/p>\n<p>Cipher designs and implements systems on the Cloudflare Developer Platform for businesses in Thailand, and can assess an existing AI architecture to say which parts should be re-routed, which model each path should use, and where the money is actually going.<\/p>\n<h2>Frequently Asked Questions<\/h2>\n<h3>Can Workers AI replace GPT-class models?<\/h3>\n<p>No. For multi-step reasoning, code generation, or analytical reading of long documents, the open models on Workers AI are clearly behind frontier models. What Workers AI does well is high-volume small tasks: classification, embeddings, moderation and short summarisation.<\/p>\n<h3>How is Workers AI billed?<\/h3>\n<p>Workers AI is billed in Neurons at 0.011 USD per 1,000 Neurons, with 10,000 Neurons per day included free on both the Free and Paid plans. Cloudflare also publishes per-model rates in dollars per million tokens, for example llama-3.1-8b-instruct-fp8-fast at 0.045 USD per million input tokens and 0.384 USD per million output tokens. Pricing as of July 2026.<\/p>\n<h3>Does calling the OpenAI API from a Worker make the Worker expensive?<\/h3>\n<p>Not in the way most teams fear, because Workers bills CPU time rather than wall-clock time. The seconds a Worker spends waiting for an OpenAI response do not count as CPU time. The real constraint is the limit of 6 simultaneous outgoing connections per Worker if you fan out requests in parallel.<\/p>\n<h3>Do I need Workers AI to use AI Gateway?<\/h3>\n<p>No. AI Gateway works as a proxy in front of external model providers, including OpenAI. You change the base URL and immediately get caching, rate limiting, logs and analytics. AI Gateway core features are free on all plans as of July 2026.<\/p>\n<h3>Is data sent to Workers AI used to train models?<\/h3>\n<p>Cloudflare data usage documentation states that Cloudflare does not use your Customer Content to train the models available on Workers AI, nor to improve Cloudflare or third-party services, unless you give explicit consent. It also states your content is not made available to any other Cloudflare customer.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Quick answer: Use Workers AI when the task is small and you run it a lot: classification, embeddings, moderation, transcription [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_angie_page":false,"content-type":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"page_builder":"","footnotes":""},"categories":[152],"tags":[],"class_list":["post-18137","post","type-post","status-publish","format-standard","hentry","category-technology-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.cipher.co.th\/en\/wp-json\/wp\/v2\/posts\/18137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cipher.co.th\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cipher.co.th\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cipher.co.th\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cipher.co.th\/en\/wp-json\/wp\/v2\/comments?post=18137"}],"version-history":[{"count":0,"href":"https:\/\/www.cipher.co.th\/en\/wp-json\/wp\/v2\/posts\/18137\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cipher.co.th\/en\/wp-json\/wp\/v2\/media?parent=18137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cipher.co.th\/en\/wp-json\/wp\/v2\/categories?post=18137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cipher.co.th\/en\/wp-json\/wp\/v2\/tags?post=18137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}