Close Menu
    Latest Post

    Build Resilient Generative AI Agents

    January 8, 2026

    Accelerating Stable Diffusion XL Inference with JAX on Cloud TPU v5e

    January 8, 2026

    Older Tech In The Browser Stack

    January 8, 2026
    Facebook X (Twitter) Instagram
    Trending
    • Build Resilient Generative AI Agents
    • Accelerating Stable Diffusion XL Inference with JAX on Cloud TPU v5e
    • Older Tech In The Browser Stack
    • If you hate Windows Search, try Raycast for these 3 reasons
    • The Rotel DX-5: A Compact Integrated Amplifier with Mighty Performance
    • Drones to Diplomas: How Russia’s Largest Private University is Linked to a $25M Essay Mill
    • Amazon’s 55-inch 4-Series Fire TV Sees First-Ever $100 Discount
    • Managing Cloudflare at Enterprise Scale with Infrastructure as Code and Shift-Left Principles
    Facebook X (Twitter) Instagram Pinterest Vimeo
    NodeTodayNodeToday
    • Home
    • AI
    • Dev
    • Guides
    • Products
    • Security
    • Startups
    • Tech
    • Tools
    NodeTodayNodeToday
    Home»Tools»Workers AI Now Supports Structured JSON Outputs
    Tools

    Workers AI Now Supports Structured JSON Outputs

    Samuel AlejandroBy Samuel AlejandroDecember 21, 2025Updated:December 22, 2025No Comments3 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    src pnuuqg featured
    Share
    Facebook Twitter LinkedIn Pinterest Email

    hero image

    Workers AI now offers structured JSON outputs through its JSON mode, enabling users to request structured responses directly from AI models.

    This feature significantly simplifies the retrieval of structured data from AI models, eliminating the error-prone process of parsing extensive unstructured text to extract specific information.

    Workers AI’s JSON mode is compatible with the OpenAI SDK’s structured outputs ↗ response_format API, which can be directly implemented within a Worker:

    JavaScript Example

    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://developers.cloudflare.com/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 Example

    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://developers.cloudflare.com/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,
    });
    },
    };

    Further details on JSON mode and structured outputs are available in the Workers AI documentation.

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleCompletion of the Core 2Africa System: Advancing Global Connectivity
    Next Article Seventh-generation server hardware at Dropbox: our most efficient and capable architecture yet
    Samuel Alejandro

    Related Posts

    Tools

    Build Resilient Generative AI Agents

    January 8, 2026
    Tools

    Managing Cloudflare at Enterprise Scale with Infrastructure as Code and Shift-Left Principles

    January 8, 2026
    Tools

    Design System Annotations: Why Accessibility is Often Overlooked in Component Design (Part 1)

    January 7, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Latest Post

    ChatGPT Mobile App Surpasses $3 Billion in Consumer Spending

    December 21, 202512 Views

    Automate Your iPhone’s Always-On Display for Better Battery Life and Privacy

    December 21, 202510 Views

    Creator Tayla Cannon Lands $1.1M Investment for Rebuildr PT Software

    December 21, 20259 Views
    Stay In Touch
    • Facebook
    • YouTube
    • TikTok
    • WhatsApp
    • Twitter
    • Instagram
    About

    Welcome to NodeToday, your trusted source for the latest updates in Technology, Artificial Intelligence, and Innovation. We are dedicated to delivering accurate, timely, and insightful content that helps readers stay ahead in a fast-evolving digital world.

    At NodeToday, we cover everything from AI breakthroughs and emerging technologies to product launches, software tools, developer news, and practical guides. Our goal is to simplify complex topics and present them in a clear, engaging, and easy-to-understand way for tech enthusiasts, professionals, and beginners alike.

    Latest Post

    Build Resilient Generative AI Agents

    January 8, 20260 Views

    Accelerating Stable Diffusion XL Inference with JAX on Cloud TPU v5e

    January 8, 20260 Views

    Older Tech In The Browser Stack

    January 8, 20260 Views
    Recent Posts
    • Build Resilient Generative AI Agents
    • Accelerating Stable Diffusion XL Inference with JAX on Cloud TPU v5e
    • Older Tech In The Browser Stack
    • If you hate Windows Search, try Raycast for these 3 reasons
    • The Rotel DX-5: A Compact Integrated Amplifier with Mighty Performance
    Facebook X (Twitter) Instagram Pinterest
    • About Us
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    • Disclaimer
    • Cookie Policy
    © 2026 NodeToday.

    Type above and press Enter to search. Press Esc to cancel.