Complete Configuration Guide

How to Set Up Moltworker on Cloudflare

Learn how to configure Moltworker after deployment. Set up your AI model, secure the Control UI, connect messaging platforms, enable persistent storage, and customize your AI agent.

What Is Included in a Moltworker Setup?

Deploying Moltworker is only the first part of getting your AI agent ready. After deployment, you need to configure the services that allow it to connect to an AI model, securely communicate with users, and retain important information.

Moltworker combines OpenClaw with Cloudflare's infrastructure. Its configuration can include AI provider credentials, Cloudflare Access, device pairing, R2 storage, messaging integrations, and browser automation.

✦

AI Model Configuration

Connect an AI provider or configure Cloudflare AI Gateway for model requests.

⌘

Control UI Access

Access the dashboard and manage your AI agent through a browser.

♧

Security & Pairing

Protect the interface with Cloudflare Access and approve trusted devices.

▣

Persistent Storage

Use Cloudflare R2 to preserve configuration and conversation data.

✉

Messaging Integrations

Connect supported platforms such as Telegram, Discord, and Slack.

◉

Browser Automation

Configure browser-related capabilities using Cloudflare Browser Rendering.

Before You Start Configuring Moltworker

Make sure your initial deployment is complete before following the configuration steps. You will need access to your Cloudflare account and the project files.

Requirements

  • A Cloudflare account with an active Workers Paid plan.
  • The Moltworker project cloned from its official GitHub repository.
  • Node.js and npm installed on your computer.
  • Wrangler CLI configured for your Cloudflare account.
  • An AI provider API key or a configured Cloudflare AI Gateway.
  • Access to your Cloudflare Worker settings and secrets.

Important: Cloudflare's official Moltworker repository describes the project as an experimental proof of concept. It is not an officially supported Cloudflare product and may change or break without notice.

If you have not deployed Moltworker yet, follow our Moltworker Installation Guide first.

Step-by-Step Moltworker Setup Guide

Follow these configuration steps to connect your AI provider, secure your dashboard, and enable the features you need.

01

Check Your Moltworker Deployment

Start by confirming that your project has been installed and deployed. Open your project directory in the terminal and check that the required packages are installed.

Terminal
npm install

If you have already completed installation, you can move directly to the configuration steps. For deployment instructions, see the Moltworker installation tutorial.

02

Configure Your AI Model

Moltworker needs access to an AI model to process prompts and generate responses. You can configure direct provider access or use Cloudflare AI Gateway.

Option A: Connect Anthropic Directly

If you want to connect directly to Anthropic, add your API key as a Worker secret:

npx wrangler secret put ANTHROPIC_API_KEY

Enter your API key when prompted. Keep the key private and never publish it in frontend code or public repositories.

Option B: Use Cloudflare AI Gateway

Cloudflare AI Gateway can route model requests and provide features such as analytics and request monitoring. Configure the required secrets using the current variable names:

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

The gateway API key is used for authentication with your upstream model provider. Follow the current repository instructions for the provider and billing method you choose.

You can optionally specify a model using:

npx wrangler secret put CF_AI_GATEWAY_MODEL

A model identifier uses the format provider/model-id. Check the official repository for currently supported providers and model identifiers.

Configuration note: Older guides may show AI_GATEWAY_API_KEY and AI_GATEWAY_BASE_URL. The current repository documents CLOUDFLARE_AI_GATEWAY_API_KEY, CF_AI_GATEWAY_ACCOUNT_ID, and CF_AI_GATEWAY_GATEWAY_ID for its native AI Gateway setup.

03

Generate Your Gateway Authentication Token

The gateway token helps protect access to the Moltworker Control UI. Generate a strong random token instead of choosing a simple password.

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

Store the generated token securely. You will need it when accessing the remote Control UI.

04

Deploy Your Configuration

After adding the required secrets, deploy your updated Worker:

npm run deploy

Once deployment finishes, open your Worker URL. The first request may take a little longer while the container starts.

https://your-worker.workers.dev/?token=YOUR_GATEWAY_TOKEN

Replace the example domain and token with your actual Worker URL and securely stored gateway token. Do not share this URL with its authentication token publicly.

05

Protect the Control UI with Cloudflare Access

Cloudflare Access adds an authentication layer before users can reach the protected interface. This is an important security step for a remotely accessible AI agent.

  1. Open your Cloudflare dashboard.
  2. Go to Workers & Pages.
  3. Select your deployed Moltworker Worker.
  4. Open Settings → Domains & Routes.
  5. Use the workers.dev Access option to enable Cloudflare Access.
  6. Create or configure an Access application and an allow policy.
  7. Add the email addresses that should be allowed to access the interface.

After configuring the Access application, obtain its team domain and Application Audience (AUD) value.

Add them as Worker secrets:

npx wrangler secret put CF_ACCESS_TEAM_DOMAIN
npx wrangler secret put CF_ACCESS_AUD

Deploy the updated configuration:

npm run deploy

Security reminder: Do not rely only on the gateway token. Follow the official Cloudflare Access configuration for remote dashboard access.

06

Pair Your Device

Device pairing allows you to approve devices that connect to your Moltworker instance. When a new device requests access, it may appear as pending until you approve it.

  1. Open the Moltworker admin interface.
  2. Navigate to the /_admin/ route.
  3. Find the pending device request.
  4. Review the device and approve it only if you trust it.
  5. Return to the Control UI and check the connection.

Allow a short time for newly requested devices to appear in the admin interface. Never approve an unfamiliar device automatically.

07

Enable Persistent Storage with Cloudflare R2

Persistent storage helps protect your configuration and conversation data when the sandbox container restarts. Without R2, some data stored inside the container can be lost after a restart.

Create an R2 bucket in your Cloudflare account and generate the required credentials. Then configure the following secrets:

npx wrangler secret put R2_ACCESS_KEY_ID
npx wrangler secret put R2_SECRET_ACCESS_KEY
npx wrangler secret put CF_ACCOUNT_ID

Enter the corresponding values when prompted. Keep your R2 credentials private.

The repository includes automatic backup functionality. Check the admin interface for R2 status and available backup controls.

Remember: R2 configuration and backup behavior should be verified in your deployed environment. The repository documents that R2 functionality is intended for production rather than local wrangler dev testing.

08

Connect Telegram to Moltworker

You can connect Telegram to communicate with your AI agent through a messaging interface.

  1. Open Telegram and find the official BotFather account.
  2. Create a new bot and follow the prompts.
  3. Copy the generated bot token.
  4. Add the token to your Worker secrets.
npx wrangler secret put TELEGRAM_BOT_TOKEN

Enter your bot token and follow the current repository instructions for enabling and testing the Telegram integration.

09

Connect Discord and Slack

Moltworker also documents support for additional messaging integrations. You can configure the required credentials for Discord and Slack.

Discord configuration

npx wrangler secret put DISCORD_BOT_TOKEN

Create a Discord application and bot, then provide the appropriate token. Review the official integration instructions for permissions and setup requirements.

Slack configuration

npx wrangler secret put SLACK_BOT_TOKEN
npx wrangler secret put SLACK_APP_TOKEN

Configure your Slack app and provide the required bot and app-level tokens. Use the permissions required by your intended integration.

10

Configure Browser Automation

Moltworker's architecture can use Cloudflare Browser Rendering for browser-related tasks. This can support workflows that require web page interaction or browser-based information gathering.

Review the current repository configuration and Cloudflare Browser Rendering documentation before enabling browser capabilities. The available features depend on the deployed version and its configured services.

Cloudflare Browser Rendering documentation ↗
11

Configure Container Sleep Settings

You can adjust how long the sandbox container remains active before going to sleep. The repository documents SANDBOX_SLEEP_AFTER as a configuration option.

For example, the following values represent different sleep settings:

SANDBOX_SLEEP_AFTER=never
SANDBOX_SLEEP_AFTER=10m
SANDBOX_SLEEP_AFTER=1h

The appropriate setting depends on your usage and cost requirements. A container that sleeps may need to start again when the next request arrives. Persistent storage helps retain supported data across container restarts.

How to Check Your Moltworker Configuration

After completing the setup, verify that your secrets and deployment are working correctly. Wrangler provides useful commands for checking configuration and monitoring Worker activity.

List Configured Worker Secrets

npx wrangler secret list

Use this command to check which secrets have been configured. It does not reveal their secret values.

Monitor Worker Logs

npx wrangler tail

Review the logs to identify deployment or runtime issues. Avoid sharing logs publicly if they contain sensitive information.

Common Moltworker Setup Problems and Solutions

If your AI agent does not work as expected, check the configuration, credentials, and deployment logs before changing multiple settings.

Problem What to Check
AI model is not responding Verify the provider API key, gateway credentials, and model configuration.
Control UI access denied Check Cloudflare Access policies, team domain, and Application Audience.
Device is not connected Check pending device requests and approve only trusted devices.
Data disappears after restart Verify R2 credentials, bucket configuration, and backup status.
Messaging integration fails Check the bot or app token and the integration's required permissions.
Container takes time to start Allow time for the sandbox to initialize and inspect Worker logs.
Local development issue on Windows Check Git line endings if shell scripts fail with an exit code such as 126.

For more detailed troubleshooting, review the official Moltworker GitHub repository.

Important Moltworker Security Tips

Your AI agent may have access to connected services, messaging platforms, and other resources. Protecting its credentials and access points is essential.

🔐

Protect API Keys

Store credentials as Worker secrets. Do not place private API keys in public code or browser-side scripts.

🛡

Use Access Policies

Restrict dashboard access to trusted users with Cloudflare Access.

✓

Review Device Requests

Approve only devices you recognize and trust.

How Much Does Moltworker Setup Cost?

Moltworker uses Cloudflare services, but running it is not necessarily free. The official repository identifies a Cloudflare Workers Paid plan as a requirement for Sandbox containers. The plan has a baseline subscription cost, and additional usage may result in extra charges.

Your total cost can depend on container compute, AI model requests, storage, and the services you enable. AI provider usage may be billed separately depending on your configuration.

Before deploying: Check the latest Cloudflare Workers pricing and the pricing of your selected AI provider. Pricing and free-tier allowances can change.

Moltworker Setup Checklist

Use this checklist to review the main configuration tasks.

Initial deployment completed
AI provider configured
Gateway token generated
Control UI access checked
Cloudflare Access configured
Device pairing completed
R2 storage configured if required
Messaging integrations tested
Browser capabilities reviewed
Worker logs checked

Frequently Asked Questions

What is Moltworker used for?

Moltworker provides an approach to running an OpenClaw-based AI agent using Cloudflare infrastructure. It connects the agent runtime with services such as Sandbox containers, R2 storage, Cloudflare Access, and optional AI Gateway capabilities.

Do I need a Cloudflare Paid plan for Moltworker?

Yes. The official Moltworker repository identifies a Workers Paid plan as a requirement for Cloudflare Sandbox containers. Additional usage charges may also apply.

Can I use Moltworker without an AI Gateway?

Yes. The repository documents direct AI provider configuration, including Anthropic API access. Cloudflare AI Gateway is an optional way to route and monitor supported model requests.

Why should I enable Cloudflare Access?

Cloudflare Access adds an authentication layer to protect the remote Control UI. It helps restrict access to approved users instead of leaving the administrative interface publicly accessible.

Does Moltworker support Telegram?

The official repository documents Telegram integration using a bot token configured as a Worker secret. Follow the current repository instructions to complete the integration.

What is Cloudflare R2 used for in Moltworker?

R2 provides persistent storage and backup functionality for supported Moltworker data. It helps preserve information that could otherwise be lost when a sandbox container restarts.

Is Moltworker production-ready?

Cloudflare describes the repository as an experimental proof of concept rather than an officially supported product. Review the latest documentation and assess the security and reliability requirements before using it for important workloads.

Where can I find the latest Moltworker instructions?

The official Cloudflare Moltworker GitHub repository is the best place to check the latest installation, configuration, and troubleshooting instructions.

Ready to Configure Moltworker?

Complete your configuration, secure your Control UI, and connect the services required for your AI agent. Always refer to the official repository for the latest changes.

View Official Documentation ↗