OpenClaw tricks: change models, SSH & more
最初直播時間:9月13日,上午11:00 - 上午11:30 [EDT]
English
文字記錄 (測試版)
Hello, everyone. Welcome back to the channel. My name is Confidence and I am a Developer Advocate at Cloudflare and it's great to have you all back here.
In the previous videos, we showed you a detailed guide on how to set up Mote Worker or OpenClaw on Cloudflare Workers.
I'll have a link to the top corner here and also in the description.
And in the last video we made on this topic, we also showed you how to securely access your OpenClaw instance if you choose to go self-hosted on a device you own like a Raspberry Pi or Mac Mini and how to access it through Worker's VPC.
I'm also going to leave a link to the top corner and also in the description so you can go check that out.
But in this video specifically, I'm going to be sharing with you tips and tricks to optimize your Mote Worker or OpenClaw instance that's hosted on Cloudflare Workers.
So I'm going to show you everything you need to know including how to access your instance via SSH, how to save cost and all of the goodies in between.
So let's get started with it. The first tip I'm going to be showing you is how to save cost by optimizing your instance.
And that's because Mote Worker or OpenClaw on Cloudflare runs inside of a container sandbox.
And containers are actually really cool because they enable you to run Linux containers that can access up to 6TB of RAM, 1500 virtual CPUs and 30TB of SSD.
But the truth is you don't need all of that horsepower to run OpenClaw on Cloudflare.
So you can actually tweak things a bit so that you don't end up spending a lot on your instance.
And one cool thing about containers on Cloudflare is that you only build when your instance is running.
So I'm going to go to the browser real quick and show you some of the instance types on Cloudflare.
So I'm just going to open this in a new tab. And this is the developer docs.
And you can see all of the instances you have access to the standard instances. So you have the light you have basic, you would need at least a standard one to run OpenClaw on Cloudflare.
But you can go up to standard for in fact, set a custom instance type.
So let me go to my instance, my motorworker instance or OpenClaw instance.
And let's get this configured. I'm just going to open up the wrangler.json in my editor.
And down here, you just scroll down to the bottom where it says instance type, you can change that from a standard four to anything you want.
I'm just going to set this to a standard two.
Let's give this a save. And we can deploy the application.
So npm run deploy. And that's going to get the new instance configuration I have deployed to Cloudflare.
The beautiful thing about instances is that you can also set a custom instance type to specifically request for like the exact kind of hardware you want to run your instance on.
So I'll also show you how to do that real quick.
Okay, that's done. So let's go open up the wrangler.json file.
And I'm just going to give this a custom instance type. So let's go delete the instance string, this is going to be custom instance type, which is an object.
And here I can specify the number of CPU cores, I want to give this instance, the number of RAM in megabytes, this is going to be four gigs, and also the disk space, which is going to be SSD.
So you can also specify the exact custom instance type if you want to do that.
But we'll just be using standard two for this, because I think that's generous enough.
One other thing you can do to optimize your instance cost is to set it to go to sleep after it's been inactive for a while.
So you can do that by setting an environment variable. And you do that by writing this command mpx wrangler secret puts and sandbox sleep after.
So I'm just going to hit enter.
And I want my instance to go to sleep after three hours of inactivity.
So this is going to be three h, you're not going to see what I've typed in, but that three h, which is three hours.
And when I hit that, it's going to get that environment variable configured and deployed to my Cloudflare worker.
And then that's going to get applied to my container instance.
And of course, you can run npm run deploy, to make sure that that change has been applied.
Moving on to the second trick, I'm going to be showing you another cool thing you can do is tweak the model your open cloud instance runs on.
By default, open cloud and Cloudflare Workers runs on antropics.
So net 4.5, that's a cheaper model compared to Opus. But you can actually use whatever model you want from whatever provider you want, including open AI, and even also using Cloudflare workers AI.
So I'm just going to quickly show you how to get that done.
And that's also by updating the API key of the provider you want to use.
Anthropic and open AI are supported directly by configuring the respective environment variables.
But you can use any provider you want by using the Cloudflare AI gateway, I'll show you that in a bit.
So if you want to use open AI, for instance, go ahead to set this environment variable, which is the open API key, or you could go configure it using Cloudflare AI gateway.
And if we switch over to my dash, I'm just going to show you all the providers supported.
So this is my dashboard, I'm going to go to AI, I'm going to go to AI gateway.
And I already have my AI gateway setup, which was done using the guide in the previous video.
Again, I'll link to it in the description below. So this is my AI gateway for this video.
And look at all the providers that are supported, we support like literally every provider out there, including replicate, shout out to replicate.
Also, you can use models from replicate. But I think the really cool thing here you can also do is use models on Cloudflare Workers AI.
And these models are very generous, we give 10,000 neurons per day free of charge to any user.
So you actually don't even have to spend money using this models with open claw like whatsoever.
So I'm just going to go up here. And to see how that's done, go to workers AI.
And I should be going to models here. So that's models. And you can see all of the models that are supported, I think GLM 4.7 is actually really great.
And this is the model ID.
So I'm just going to get this copied. And what I want to do here is go set my mode to work out open claw instance to this model.
So I'm going to grab the right secret.
So this is going to be I'm just going to quit that this is going to be the secret I need to update.
And for the value, what I want to set this to is the name of the model prefixed by the worker AI provider.
So I'm just going to set that here, I'll show you what I entered in a bit.
So I have that set up right now.
And I'm just going to show you what I entered in that field. So this is workers AI, followed by the model ID, which in this case is GLM 4.7 flash, and you get the model ID from this path right here, where we copied it from the model page.
And that it's going to be the same for any model you choose, whether it's GLM, or maybe you prefer to use open AI is GPT OSS.
This is GPT OSS 120. B, this is where you grab the model ID.
And you just have to prefix that by the workers AI provider, and enter that into the CF AI gator model environment variable.
So I already have that entered, and that's been deployed. And now if I go check my instance, so I'm just going to go to the dashboard.
Let's refresh this because we've made a deployment.
And this is running now. So I can try to interact with my instance and say hello.
And you can see we have the response coming back.
But this is using the model on workers AI, which is the GLM 4.7 flash.
And how you know is you head back to your gateway, the gator you have configured for your open core instance or your motor worker instance.
And if you go to logs, you should see the request that just came in right now is being run on the cloud for workers AI model, which is completely free to use, you get 10,000 neurons per day.
And that should cover your usage costs without you having to pay for using a premium model hosted somewhere else.
The third thing I'm going to be sharing with you is how to securely SSH into your container instance.
Because we're actually running a container in the background, I forgot to compute go to containers.
This is the container where I have my open core instance running.
So how do I access it and manage it because the truth is the control UI is really great, you can do a lot of stuff here to customize your instance.
But in certain situations, you just want to have shell access into the instance so that you can make certain changes you want to make in a Linux environment.
So how do you do that? I'm going to show you how to do set that up right now.
So let's head back to my wrangler configuration for my work worker. So that's the wrangler.json C file.
And what I want to do here is set up SSH access by entering in this configuration value.
Alright, so this is the value I have just entered, we just enabled SSH wrangler, this has been enabled.
And the next thing we want to do here is set up the authorized keys that can access this instance, you want to give this any name, this could be any name you like to and identify this SSH key.
And then you want to also add your public SSH key. And you can grab that from your home directory.
So this is going to be where you have LS in your home forward slash dot SSH forward slash dot pub, it's going to be that file, that's where you grab the value from and paste that in here.
I'm going to have mine configured off screen so you don't see my public SSH key.
And then when you have that done, feel free to go ahead to run the NPM run deploy command.
And that's going to get that configuration deployed so you can SSH into your instance.
Alright, I already have mine set up off screen with my public SSH key.
So I'm this is going to get my SSH configuration deployed.
So I can SSH into the container instance and make changes to it.
Alright, that is deployed. And if I head over to the dashboard here, I'm just going to close this tab.
So I'm not using anymore. Right over to the dashboard.
And we take a look at the container. Yeah, it's, it's running.
I think I have everything running without needing to restart the container. That's cool.
And the next thing I need to do is actually SSH into this instance. So this is the command you need to SSH into your container instance.
It's mpx wrangler containers SSH, and then the ID of the container you want to SSH into.
To grab the ID, I'm going to head back to the dashboard, head back to instances, click on the one instance I have running.
And then I'm going to grab the container ID, which is this ID over here, I have that copied, I'll paste that in right here, hit enter, and I should be able to SSH into that instance.
And you can see we are in that instance.
So I'm just going to do a cat etc. issue, you can see that we're running Ubuntu 22.04.
And if we do a quick LS, you can see this is the skills directory of the multi worker, or the open core instance.
And we can actually go into manage most of here.
So this is really cool. And I'm just going to exit out of this.
And that's how you SSH into your open core instance on cover. The last step I'm going to be showing you is how to add more members to your open core instance or your multi worker instance.
This is because in some cases, you want to share your instance with family members, friends or colleagues.
So how do you actually get them added to the instance.
To do that, head back to the dashboard, and you want to go to workers and pages and go select your modes bot instance, go over to settings, go to the URL where you have Cloudflare access configured.
And you want to click on manage Cloudflare access.
And that's going to take you to the Zero Trust dashboard where you have that application, the access application configured.
And you can see all of the rules here, what we want to do is go to the policies tab.
And you can go add a new policy or edit the policy you already have, which in this case is the mode bot sandbox production policy.
I'm just going to edit this. And here I can add more email, emails if I want to.
So I can add my email to for instance, and keep adding more emails.
And that's going to get that email added. And of course, I can go save this.
And anyone who has access to the emails that are listed in the access list can access my instance, which is really cool.
Awesome. So that's it for this video.
Multi worker instance is a open claw on Cloudflare. It's really cool because you get to run your instance without buying a new hardware.
And I hope these tips and tricks have been useful to help you optimize your instance and show you a few things you may not already know how to do.
So if you're already using OpenGL, please let me know in the comments below.
I'd like to see what automations you are using it for.
And with that, I'll catch you in the next video.
Don't forget to like, share and subscribe and I'll see you in the next one.
Take care.
