---
title: Workers AI Changelog
image: https://edgetunnel-b2h.pages.dev/cf-twitter-card.png
---

> Documentation Index  
> Fetch the complete documentation index at: https://edgetunnel-b2h.pages.dev/changelog/llms.txt  
> Use this file to discover all available pages before exploring further. 

[Skip to content](#%5Ftop) 

# Changelog

New updates and improvements at Cloudflare.

[ Subscribe to RSS ](https://edgetunnel-b2h.pages.dev/changelog/rss/index.xml) [ View RSS feeds ](https://edgetunnel-b2h.pages.dev/fundamentals/new-features/available-rss-feeds/) 

Workers AI

![hero image](https://edgetunnel-b2h.pages.dev/_astro/hero.CVYJHPAd_26AMqX.svg) 

Feb 25, 2025
1. ### [Workers AI now supports structured JSON outputs.](https://edgetunnel-b2h.pages.dev/changelog/post/2025-02-25-json-mode/)  
[ Workers AI ](https://edgetunnel-b2h.pages.dev/workers-ai/)  
Workers AI now supports structured JSON outputs with [JSON mode](https://edgetunnel-b2h.pages.dev/workers-ai/features/json-mode/), which allows you to request a structured output response when interacting with AI models.  
This makes it much easier to retrieve structured data from your AI models, and avoids the (error prone!) need to parse large unstructured text responses to extract your data.  
JSON mode in Workers AI is compatible with the OpenAI SDK's [structured outputs ↗](https://platform.openai.com/docs/guides/structured-outputs) `response_format` API, which can be used directly in a Worker:

  * [  JavaScript ](#tab-panel-3255)
  * [  TypeScript ](#tab-panel-3256)

**JavaScript**  
```js  
import { OpenAI } from "openai";  
// Define your JSON schema for a calendar event  
const CalendarEventSchema = {  
  type: "object",  
  properties: {  
    name: { type: "string" },  
    date: { type: "string" },  
    participants: { type: "array", items: { type: "string" } },  
  },  
  required: ["name", "date", "participants"],  
};  
export default {  
  async fetch(request, env) {  
    const client = new OpenAI({  
      apiKey: env.OPENAI_API_KEY,  
      // Optional: use AI Gateway to bring logs, evals & caching to your AI requests  
      // https://edgetunnel-b2h.pages.dev/ai-gateway/usage/providers/openai/  
      // baseUrl: "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/openai"  
    });  
    const response = await client.chat.completions.create({  
      model: "gpt-4o-2024-08-06",  
      messages: [  
        { role: "system", content: "Extract the event information." },  
        {  
          role: "user",  
          content: "Alice and Bob are going to a science fair on Friday.",  
        },  
      ],  
      // Use the `response_format` option to request a structured JSON output  
      response_format: {  
        // Set json_schema and provide ra schema, or json_object and parse it yourself  
        type: "json_schema",  
        schema: CalendarEventSchema, // provide a schema  
      },  
    });  
    // This will be of type CalendarEventSchema  
    const event = response.choices[0].message.parsed;  
    return Response.json({  
      calendar_event: event,  
    });  
  },  
};  
```

**TypeScript**  
```ts  
import { OpenAI } from "openai";  
interface Env {  
  OPENAI_API_KEY: string;  
}  
// Define your JSON schema for a calendar event  
const CalendarEventSchema = {  
  type: "object",  
  properties: {  
    name: { type: "string" },  
    date: { type: "string" },  
    participants: { type: "array", items: { type: "string" } },  
  },  
  required: ["name", "date", "participants"],  
};  
export default {  
  async fetch(request: Request, env: Env) {  
    const client = new OpenAI({  
      apiKey: env.OPENAI_API_KEY,  
      // Optional: use AI Gateway to bring logs, evals & caching to your AI requests  
      // https://edgetunnel-b2h.pages.dev/ai-gateway/usage/providers/openai/  
      // baseUrl: "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/openai"  
    });  
    const response = await client.chat.completions.create({  
      model: "gpt-4o-2024-08-06",  
      messages: [  
        { role: "system", content: "Extract the event information." },  
        {  
          role: "user",  
          content: "Alice and Bob are going to a science fair on Friday.",  
        },  
      ],  
      // Use the `response_format` option to request a structured JSON output  
      response_format: {  
        // Set json_schema and provide ra schema, or json_object and parse it yourself  
        type: "json_schema",  
        schema: CalendarEventSchema, // provide a schema  
      },  
    });  
    // This will be of type CalendarEventSchema  
    const event = response.choices[0].message.parsed;  
    return Response.json({  
      calendar_event: event,  
    });  
  },  
};  
```  
To learn more about JSON mode and structured outputs, visit the [Workers AI documentation](https://edgetunnel-b2h.pages.dev/workers-ai/features/json-mode/).

Feb 24, 2025
1. ### [Workers AI larger context windows](https://edgetunnel-b2h.pages.dev/changelog/post/2025-02-24-context-windows/)  
[ Workers AI ](https://edgetunnel-b2h.pages.dev/workers-ai/)  
We've updated the Workers AI text generation models to include context windows and limits definitions and changed our APIs to estimate and validate the number of tokens in the input prompt, not the number of characters.  
This update allows developers to use larger context windows when interacting with Workers AI models, which can lead to better and more accurate results.  
Our [catalog page](https://edgetunnel-b2h.pages.dev/workers-ai/models/) provides more information about each model's supported context window.

Feb 20, 2025
1. ### [Workers AI updated pricing](https://edgetunnel-b2h.pages.dev/changelog/post/2025-02-20-updated-pricing-docs/)  
[ Workers AI ](https://edgetunnel-b2h.pages.dev/workers-ai/)  
We've updated the Workers AI [pricing](https://edgetunnel-b2h.pages.dev/workers-ai/platform/pricing/) to include the latest models and how model usage maps to Neurons.

  * Each model's core input format(s) (tokens, audio seconds, images, etc) now include mappings to Neurons, making it easier to understand how your included Neuron volume is consumed and how you are charged at scale
  * Per-model pricing, instead of the previous bucket approach, allows us to be more flexible on how models are charged based on their size, performance and capabilities. As we optimize each model, we can then pass on savings for that model.
  * You will still only pay for what you consume: Workers AI inference is serverless, and not billed by the hour.  
Going forward, models will be launched with their associated Neuron costs, and we'll be updating the Workers AI dashboard and API to reflect consumption in both raw units and Neurons. Visit the [Workers AI pricing](https://edgetunnel-b2h.pages.dev/workers-ai/platform/pricing/) page to learn more about Workers AI pricing.

```json
{"@context":"https://schema.org","@type":"BlogPosting","@id":"https://edgetunnel-b2h.pages.dev/changelog/product/workers-ai/2/#page","headline":"Workers AI Changelog | Cloudflare Docs","url":"https://edgetunnel-b2h.pages.dev/changelog/product/workers-ai/2/","inLanguage":"en","image":"https://edgetunnel-b2h.pages.dev/cf-twitter-card.png","publisher":{"@type":"Organization","name":"Cloudflare","url":"https://www.cloudflare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://edgetunnel-b2h.pages.dev/#website","name":"Cloudflare Docs","url":"https://edgetunnel-b2h.pages.dev/"}}
```
