Complete Beginner's Guide

Moltworker Tutorial: How to Run Your AI Agent on Cloudflare

Learn how Moltworker works, how to deploy OpenClaw on Cloudflare, connect AI models, configure messaging integrations, protect your agent, and get started with practical examples.

What Is Moltworker?

Moltworker is an open-source project from Cloudflare that provides a way to run OpenClaw, an open-source personal AI agent, on Cloudflare's infrastructure. Instead of keeping the agent on a computer at home or managing a traditional server, developers can use Cloudflare Workers and Sandbox containers to host the runtime.

The project combines a Worker-based entry point with an adapted OpenClaw runtime. It can also use Cloudflare services such as R2 storage, Access, AI Gateway, and Browser Rendering.

This tutorial explains the main ideas and takes you through the practical stages of getting started. You do not need to understand every part of the architecture before beginning, but basic terminal and Cloudflare knowledge will help.

Project status: Cloudflare describes Moltworker as an experimental proof of concept, not an officially supported Cloudflare product. Features and instructions can change, so check the official repository before deploying or updating it.

✦

Personal AI Agent

Run an AI assistant that can interact with supported tools and messaging platforms.

☁

Cloudflare Infrastructure

Use Cloudflare Workers and Sandbox containers instead of maintaining a dedicated local machine.

⌘

Flexible Integrations

Explore AI providers, messaging connections, storage, and browser-related capabilities.

How Does Moltworker Work?

Understanding the basic architecture makes the deployment process easier. Moltworker connects incoming requests to an OpenClaw runtime running inside a Cloudflare Sandbox container.

Understanding the Main Components

1. Cloudflare Worker

The Worker acts as the entry point. It handles incoming requests and connects them to the running agent environment.

2. Sandbox Container

The container runs the adapted OpenClaw Gateway runtime, which manages the agent and its supported connections.

3. AI Provider

The configured AI model processes prompts and generates responses through the selected provider.

4. Cloudflare R2

R2 can provide persistent storage and backup support for data that needs to survive container restarts.

5. Cloudflare Access

Access adds an authentication layer to protect the remote administrative interface.

6. Browser Rendering

Browser-related capabilities can be connected through Cloudflare's browser infrastructure.

This architecture is different from simply installing OpenClaw on a Linux VPS. Moltworker adapts the runtime for Cloudflare's platform and its Sandbox environment.

Why Use Moltworker?

Moltworker is useful for developers who want to explore a hosted personal AI agent without maintaining a dedicated computer for its runtime. Its main advantages come from combining OpenClaw with Cloudflare's developer services.

💻

No Dedicated Mini PC

You can explore a cloud-hosted deployment without buying a separate machine just to run the agent.

🔗

Messaging Connections

Connect supported messaging services such as Telegram, Discord, and Slack.

🔒

Access Protection

Use Cloudflare Access and device pairing to control access to the administrative interface.

📦

Persistent Data

Configure R2 to preserve supported data and backups across container restarts.

⚙

Custom Configuration

Choose supported AI providers and adjust the deployment to suit your requirements.

🌐

Cloud-Based Access

Access your deployed agent through its configured remote interface and integrations.

What Do You Need Before Starting?

Before following this Moltworker tutorial, prepare the accounts, software, and credentials required for deployment.

Requirements Checklist

  • A Cloudflare account.
  • An active Workers Paid plan for Sandbox containers.
  • Node.js and npm installed on your computer.
  • Git installed to clone the project repository.
  • Wrangler CLI and access to your Cloudflare account.
  • An AI provider API key or a suitable AI Gateway configuration.
  • Basic knowledge of terminal commands and environment secrets.

Cost reminder: The Workers Paid plan is a starting requirement, not a guarantee that the complete deployment will cost only the plan price. Container compute, AI usage, and other services can add charges.

How to Deploy Moltworker on Cloudflare

The following is a beginner-friendly overview of the deployment process. For the exact latest commands and repository changes, use the official Cloudflare instructions.

01

Get the Official Moltworker Repository

Start by downloading the project from Cloudflare's official GitHub repository. Open a terminal and clone the repository:

Terminal command
git clone https://github.com/cloudflare/moltworker.git
cd moltworker

This creates a local project directory containing the files needed for the deployment process.

02

Install the Project Dependencies

Make sure Node.js and npm are available. Inside the project directory, install the required dependencies:

npm install

Wait for the installation to finish. If npm reports an error, check your Node.js version and the repository's current requirements.

03

Configure Your AI Provider

Moltworker needs an AI provider to generate responses. The official repository documents direct Anthropic access and Cloudflare AI Gateway configuration.

Direct Anthropic configuration

npx wrangler secret put ANTHROPIC_API_KEY

Enter your API key when Wrangler asks for it. Do not put private credentials into public source code.

Cloudflare AI Gateway configuration

npx wrangler secret put CLOUDFLARE_AI_GATEWAY_API_KEY
npx wrangler secret put CF_AI_GATEWAY_ACCOUNT_ID
npx wrangler secret put CF_AI_GATEWAY_GATEWAY_ID

These are the current native AI Gateway secret names documented by the repository. Older third-party articles may show legacy variable names, so check the current README before copying configuration from another guide.

04

Generate a Secure Gateway Token

Generate a random gateway token and save it as a Worker secret:

export MOLTBOT_GATEWAY_TOKEN=$(openssl rand -hex 32)
echo "$MOLTBOT_GATEWAY_TOKEN" | npx wrangler secret put MOLTBOT_GATEWAY_TOKEN

Keep the token in a secure location. It is used when accessing the remote Control UI.

05

Deploy the Worker

After completing the required configuration, deploy the project:

npm run deploy

Wrangler will build and deploy the application. When deployment completes, use the Worker URL provided by the deployment process.

Note: The first request may take longer while the Sandbox container starts. Follow the current README for the correct access URL and authentication procedure.

Secure Your Moltworker Dashboard

A working deployment is not the same as a secure deployment. Before using your agent remotely, configure the required access controls.

Configure Cloudflare Access

  1. Open your Cloudflare dashboard.
  2. Go to Workers & Pages and select your deployed Worker.
  3. Open the Worker settings and locate the domains and routes area.
  4. Follow the repository's instructions to protect the workers.dev address with Cloudflare Access.
  5. Create an Access application and an allow policy for approved users.
  6. Obtain the Access team domain and Application Audience value.

Add the required secrets:

npx wrangler secret put CF_ACCESS_TEAM_DOMAIN
npx wrangler secret put CF_ACCESS_AUD

Deploy the updated configuration:

npm run deploy

Approve Connected Devices

Device pairing is another important part of the access process. New device requests may remain pending until an administrator approves them.

  1. Open the Moltworker admin interface.
  2. Navigate to the admin pairing area at /_admin/.
  3. Review any pending device requests.
  4. Approve only devices that you recognize and trust.
  5. Return to the Control UI and verify the connection.

Set Up Persistent Storage with R2

A container can restart or enter a sleep state. If important data exists only inside the container, it may not remain available after a restart. Cloudflare R2 can provide persistent storage for supported Moltworker data.

Configure R2 Credentials

  1. Create an R2 bucket in your Cloudflare account.
  2. Generate the required R2 access credentials.
  3. Open your Moltworker project environment.
  4. Add the required values as Worker secrets.
npx wrangler secret put R2_ACCESS_KEY_ID
npx wrangler secret put R2_SECRET_ACCESS_KEY
npx wrangler secret put CF_ACCOUNT_ID

Once configured, check the admin interface for R2 status and available backup controls. Verify that backups are working before relying on them for important data.

Connect Messaging Integrations

One of the useful features of an AI agent is the ability to interact through messaging platforms. The Moltworker repository documents configuration options for several integrations.

✉

Telegram

Create a bot using Telegram's BotFather and configure its token as a Worker secret.

npx wrangler secret put TELEGRAM_BOT_TOKEN
◈

Discord

Create a Discord application and bot. Configure the bot token and follow the required permissions.

npx wrangler secret put DISCORD_BOT_TOKEN
#

Slack

Configure a Slack application and provide the required bot and app-level tokens.

npx wrangler secret put SLACK_BOT_TOKEN
npx wrangler secret put SLACK_APP_TOKEN

Adding a token is only one part of an integration. You may also need to configure permissions, application settings, and the relevant channel setup in the agent. Follow the current project documentation for each platform.

Explore Browser Automation

Browser-related capabilities can help an AI agent work with web content and browser-based tasks. Moltworker's Cloudflare architecture includes an optional connection to Browser Rendering.

What Can Browser Capabilities Help With?

  • Working with browser-rendered web pages.
  • Supporting certain web research workflows.
  • Interacting with browser-based content where supported.
  • Building automation workflows around web information.

The available features depend on the deployed version and its configuration. Review the Cloudflare Browser Rendering documentation before enabling this functionality.

How to Test Your Moltworker AI Agent

After deployment and configuration, test the main functions before depending on the agent for regular tasks.

Basic Testing Checklist

  • Open the deployed Worker URL using the correct access method.
  • Confirm that Cloudflare Access authentication works.
  • Check that the Control UI loads correctly.
  • Verify that the device has been paired and approved.
  • Send a simple test prompt to the AI agent.
  • Check that the selected AI provider returns a response.
  • Test each messaging integration separately.
  • Review R2 status and backup functionality if enabled.
  • Inspect Worker logs for errors.

Useful Wrangler Commands

List configured Worker secrets:

npx wrangler secret list

Monitor live Worker logs:

npx wrangler tail

These commands can help you identify missing configuration and runtime errors. The secret list shows configured secret names, not their private values.

Common Moltworker Problems and Fixes

If something does not work as expected, check the relevant configuration before changing multiple settings at once.

Problem What to Check
AI agent does not respond Check the provider API key, AI Gateway secrets, and model configuration.
Dashboard access denied Review Cloudflare Access policies, team domain, and Application Audience.
Device remains pending Open the admin interface and review the pairing request.
Data is missing after restart Check R2 credentials, bucket configuration, and backup status.
Telegram or Discord does not connect Verify the bot token, app configuration, and permissions.
Container takes time to respond Allow the Sandbox to initialize and inspect the Worker logs.
Windows shell script error Check Git line endings if a script fails with an exit code such as 126.

For version-specific errors, the official GitHub issues and README should be your first reference.

How Much Does It Cost to Run Moltworker?

Moltworker is not automatically a completely free service. The official repository identifies a Cloudflare Workers Paid plan as a requirement for Sandbox containers. Additional charges may depend on how much compute and which services you use.

Cloudflare Workers

The Workers Paid plan is required for the Sandbox deployment. Check current plan pricing and usage limits.

AI Provider Usage

Model requests may have separate charges depending on your provider, model, and usage.

Additional Services

Review R2, Browser Rendering, and other service allowances and charges for your account.

Always check the latest Cloudflare pricing documentation and your AI provider's pricing before deploying. Costs and free-tier limits can change.

Important Security Tips

An AI agent may be connected to external services and tools. Its credentials and access permissions should be treated carefully.

🔐

Keep API Keys Private

Use Worker secrets instead of exposing credentials in public code, frontend scripts, or screenshots.

🛡

Restrict Dashboard Access

Use Cloudflare Access and allow policies to limit access to approved users.

✓

Review Permissions

Grant integrations only the permissions they need and approve trusted devices.

Moltworker Tutorial Quick Checklist

Review these main tasks before considering your initial deployment complete.

Read the official repository instructions
Prepare Cloudflare and development tools
Clone the Moltworker repository
Install project dependencies
Configure an AI provider
Generate a secure gateway token
Deploy the Cloudflare Worker
Protect the Control UI
Review device pairing
Configure R2 if needed
Connect supported messaging platforms
Test the agent and inspect logs

Frequently Asked Questions

What is a Moltworker tutorial?

A Moltworker tutorial explains how to understand, deploy, configure, and use the Cloudflare project for running an OpenClaw-based AI agent. It typically covers architecture, requirements, AI providers, security, storage, integrations, and troubleshooting.

Is Moltworker the same as OpenClaw?

No. OpenClaw is the AI agent runtime. Moltworker is Cloudflare's project for adapting and running OpenClaw on Cloudflare infrastructure. They are related, but they are not the same project.

Can beginners use Moltworker?

Beginners can follow a tutorial, but some technical knowledge is helpful. You should be comfortable with basic terminal commands, API keys, Cloudflare settings, and software deployment.

Do I need a Mac Mini to run Moltworker?

No dedicated Mac Mini is required for the Cloudflare deployment approach. Moltworker uses Cloudflare infrastructure and Sandbox containers, although you still need a computer to manage the setup and deployment.

Can I connect Telegram to Moltworker?

Yes. The official repository documents Telegram integration using a bot token stored as a Worker secret. Additional configuration may be needed to complete and test the connection.

Does Moltworker support persistent storage?

Yes. The project includes Cloudflare R2 integration for supported persistent storage and backup functionality. You need to configure the required R2 credentials and verify that backups are working.

Is Moltworker free to use?

Not necessarily. A Workers Paid plan is required for Sandbox containers, and additional compute or AI provider usage may create further costs. Check current Cloudflare and provider pricing.

Is Moltworker production-ready?

Cloudflare describes Moltworker as an experimental proof of concept, not an officially supported product. Review the current repository, assess security requirements, and test carefully before using it for important workloads.

Where can I find the latest Moltworker documentation?

You can find the latest project instructions, configuration details, and changes in the official Cloudflare Moltworker GitHub repository.

Start Exploring Moltworker Today

You now have an overview of how Moltworker works and the main steps involved in deploying and configuring an AI agent on Cloudflare. Continue with the official documentation to check the latest instructions and supported features.

Explore the Official Project ↗