Cloudflare Integration Overview

August 1, 2026 ยท View on GitHub

!!! warning "Experimental; hosted API not yet available" Cloud execution is experimental. Workers, R2, D1, and Workers AI run against your own Cloudflare account. The hosted Bernstein Cloud API at api.bernstein.run does not resolve in DNS, so bernstein cloud login, run, status, runs, and cost report that the service is unreachable and exit non-zero.

Bernstein can run agents locally or in the cloud. The Cloudflare integration lets you execute agents on Cloudflare's edge infrastructure using Workers, Durable Objects, and Workflows -- while the orchestrator stays deterministic and local.


When to use cloud vs local

ScenarioRecommendedWhy
Solo developer, small codebaseLocalZero setup, fastest iteration
CI/CD pipelineLocal (Docker/K8s)Full filesystem access, no network hops
Team with shared orchestrationCloudflareCentralized billing, no shared server to maintain
Global team, low-latency agent dispatchCloudflare WorkersEdge execution near developers
SaaS / hosted BernsteinCloudflare (full stack)D1 analytics, R2 storage

Architecture

graph TD
    User["Developer / CI"]
    CLI["bernstein cloud CLI"]
    Orch["Local Orchestrator<br/>(deterministic tick loop)"]
    Bridge["RuntimeBridge<br/>(cloudflare / cloudflare-workflow)"]

    subgraph Cloudflare["Cloudflare Edge"]
        Worker["Workers + Durable Objects<br/>(agent lifecycle)"]
        Workflow["Workflows<br/>(durable multi-step execution)"]
        R2["R2 Object Storage<br/>(workspace sync)"]
        D1["D1 (SQLite)<br/>(analytics & billing)"]
        AI["Workers AI<br/>(free LLM provider)"]
        Browser["Browser Rendering<br/>(web browsing)"]
    end

    MCP["MCP Remote Transport<br/>(streamable HTTP)"]

    User --> CLI --> Orch
    Orch --> Bridge
    Bridge --> Worker & Workflow
    Worker --> R2
    Workflow --> Worker
    Orch --> AI
    Orch --> D1
    Orch --> Browser
    MCP --> Orch

Module map

ModuleImport pathPurpose
Workers RuntimeBridgebernstein.bridges.cloudflareSpawn agents on Cloudflare Workers with Durable Objects
Workflow Bridgebernstein.bridges.cloudflare_workflowDurable multi-step workflows with auto-retry and approval gates
Browser Renderingbernstein.bridges.browser_renderingHeadless browsing, screenshots, scraping, PDF generation
R2 Workspace Syncbernstein.bridges.r2_syncContent-addressed file sync between local and R2
Workers AI Providerbernstein.core.routing.cloudflare_aiFree-tier LLM completions for planning and decomposition
Codex-on-Cloudflare Adapterbernstein.adapters.codex_cloudflareRuns Codex in a sandbox container via an operator-deployed @cloudflare/sandbox bridge Worker; needs a Workers Paid plan
D1 Analyticsbernstein.core.cost.d1_analyticsUsage metering, billing tiers, quota enforcement
MCP Remote Transportbernstein.mcp.remote_transportStreamable HTTP transport for remote MCP server access
Cloud CLIbernstein.cli.commands.cloud_cmdbernstein cloud subcommands (init, deploy are local; login/run/status/cost target the experimental, currently-unavailable api.bernstein.run)

What you need

At minimum:

  • A Cloudflare account (free tier works for Workers AI and basic Workers)
  • A Cloudflare API token with appropriate permissions
  • Your Cloudflare account ID

For the full stack, you also need:

  • An R2 bucket for workspace sync
  • A D1 database for analytics

See Setup for step-by-step provisioning instructions.