Create AI Avatar Videos with Claude Code and HeyGen CLI
Learn how to automate video production by using HeyGen AI agents directly within your CLI and Claude Code. This guide covers setting up API keys, prompting agents for edited videos, and scaling your content creation without a manual editor.
00:00 - Intro: AI Video Agents
00:35 - Getting Your HeyGen API Key
01:31 - Setting Up Claude Code
02:25 - Generating Your First AI Video
03:29 - How the Video Factory Works
04:47 - Retrieving Avatar and Voice IDs
05:47 - Reviewing the AI Results
07:20 - Cost Analysis and Templates
Full transcript
So you can now use Haygen with your CLI, which means basically you can create videos with Cloud Code, right? And this basically removes the need for video editors, and you can use AI agents to create videos inside your CLI now with this AI agent for videos, right, from Haygen. Now, Haygen is great at creating, for example, avatars, and it's great, for example, for creating videos in general. So we're gonna be testing this out today and seeing how it performs.
There's a full documentation on it right here. We're gonna be going through that and setting this up so that we can create videos directly from our CLI, right? Now, the way that you do this, first of all, is you wanna get an API key from Haygen. So we're gonna start with that right now, which you can see right here.
So we've got that ready, and we can create a new one if we want to as well. Now, when you create a new API key, you've got a choice now between developers and AI agents. So if you want to code with your CLI, you would just grab this one right here. And there is a full article on X on exactly how to set up Haygen CLI, right, the visualization layer for AI agents.
So what you can actually do with this, for example, is you could use Haygen and the CLI and then generate videos with Cloud Code, with OpenCore, with Hermes, with all your AI agents, right? And it's way easier to do. And also you could run scheduled tasks to run these two automatically. So let's get started with this.
First of all, we need to get an API key. And then what we need to do is send a prompt to the video agent and let it handle the rest, right? And you see how you just insert your API key that we generated earlier into this response. That's all we need to do inside the terminal.
So let's get started on that. I'm actually gonna test this inside Cloud Code directly inside the new app. And then what we'll do over here is start a new session inside Cloud Code. And I'm gonna open up a new folder here, call this Haygen CLI, open that up.
If you haven't seen the new desktop app from Cloud Code, it's beautiful, by the way, it's really nice for using. And then from here, what we're gonna do is we are going to give the documentation from Haygen to Cloud Code. And then I'm just gonna give it the API key as well. And I'll tell it I'll delete it after, but please use this for generating videos with Haygen.
I'll grab an API key, which we've got over here, click trust the workspace. Now it can start getting to work. Now, whilst we're waiting for that to get set up, we're gonna generate a video with the Haygen Video Agent API. So we're gonna put number one, generate a video.
So you can see here, it said, I've opened it up. Okay, I've got the documentation, what should the video be about? So I'm gonna put, okay, just an explainer of how to use AI for AI SEO, something like that. Very simple explainer.
Now, in the meantime, you might be wondering what this is. Well, imagine you had like an AI agent that writes reports for you. And that robot hands you a giant wall of boring text every morning, nobody wants to read that, right? So what if instead a friendly AI avatar appeared on your screen and talk to you like a news presenter?
Well, that's what Haygen CLI. And so Haygen is a tool that turns written tasks into a professional looking video with a real looking AI human face. CLI stands for command line interface, right? That means you type commands into a black terminal screen on your computer and you don't need to click buttons.
You can just type one command and the video gets made automatically. So you can see here, it says we need to top up the credits on the account, so let's do that. So inside the billing section, inside your settings, you see here in API, go to billing, and then we're gonna add a card here. And then we're gonna top up like just $10, just see what happens here.
And now we've topped up, so let's try that again. And it's now generating the video, right? So we can now generate videos inside Cloud Code for creating videos and using this to create whatever we want. So how does a Haygen CLI actually work?
Well, you wanna think of it like a factory of three rooms. You've got the script room, you or your agent can write some text, a summary, a report, and an update or anything like that. Then you've got the avatar room, right? So Haygen takes that text and assigns it to an AI generated human avatar.
The avatar has a face, a voice, and lip movements that match the words perfectly. So you've got the script and then you've got the avatar room. And then you have the delivery room, right? The finished video gets packaged up and delivered automatically so you don't need any editing software.
There's no camera required. There's not even a human required, right? And the whole process runs through one command inside your terminal, or you can use it inside Cloud Code like I'm doing today. And all you need is a Haygen account, API credits, Node.js installed, and a terminal, right?
That's it to start running this. Now you can also go inside your terminal here and start using the CLI directly if you want. So the reason I don't use this is like, I don't particularly like using CLIs and terminals and that sort of thing, but you can if you want. And basically, all you need to do is get this set up.
Then you can create your script source, right? That could be an AI agent, for example. It could be Claw, OpenClaw, Hermes, whatever you want. From there, you're going to generate the video, which is what we're doing right now, right?
So it's checking for completion. And then what you can actually do from here is actually automate this, right? So you can set up scheduled tasks with your AI agent to generate AI avatars directly using this as well. Now, if you want to retrieve all the avatars, if you built a custom avatar on Haygen like I have, like for example, you can see here, then you can actually run this command inside your terminal with your API key and get a list of all the avatars that we've got here, right?
So you see how we've got a list of all the avatars inside the list, and this is the one that we're using right now. So now that we've got the avatar ID, we can grab our voice ID, right? Which is the voice that we would use for generating the avatar videos as well, right? We've got those there, as you can see.
The one that I want to use is this one, right? So you can see I've got my avatar voice plugged in right there. And now we can run this, right? And you see how this has got a script inside here?
We can plug that in, and now we've got the voice, and we've got the avatar, and this will generate the video for us. And from there, what we can do is just check the status, right? So it's going to take a little while for the video to generate, and then you can check back in a couple of minutes. You see how it says status on the processing right there?
We need to wait for that to be finished, right? So you can see here, it's processing right now. We need to come back once it's ready, and once it's done, and then we can pull that in. Now, also, if we go back to Cloud Code, we can also see the video has now fully finished, right?
So it generated the video itself. It's done. It created a full 42-second video, and we've got the link on Haygen right here. And that is our video generated, right?
And you see how it's nicely animated and edited as well? It's even got a nice watch on. So it's looking pretty good. Easy to set up.
I would say Cloud Code is the easiest way, but if you do want to use it in the CLI, you can as well. The main thing is here, you can get edited videos, and you can use this with AI, and all you do is you give it the topic. That was literally it, right? And you can do that inside the terminal.
You can do it inside Cloud Code, and you can do it inside OpenCLL, and it's a fully edited video. It's not just like the raw avatar video, right? It looks a lot more interesting than just the normal sort of avatar videos you get. Now, if we go back to the terminal, let's check on whether the video is done.
Might still be processing. Oh, it's completed now. Look at that. So now we've got the video URL.
Let's open up. It's downloading it. Boom. Look at that.
Right, that was fully generated with AI, which is crazy. So you can do this inside the terminal. You can do it with the video editor, but it's so easy to do, right? I don't code.
I can't use APIs, but between Cloud Code, between getting the documentation and pasting it into an AI agent, I can do this inside my CLI. I can do it inside Cloud Code, and I can create AI avatar videos with Cloud, with OpenCLL, however I want it, right? And it's really easy. Even explains it all in plain English, as you can see, and then we've got a fully edited video ready to go.
If we check how much that costs, that was $1.67. Yeah, so $1.67, right, to generate those two videos, which is not bad at all. Now, if you want to get a full step-by-step guide on exactly how to use Haygen, how to generate videos using the CLI, how to get API keys, how to set up the commands inside CLI as well, with everything customizable, we've actually created templates and a full step-by-step guide based on what's working for me, as you can see right here, that shows you exactly all the CLI terminal commands in a simple, easy-to-understand guide. That's all inside the AI Profit Boardroom.
Link in the comments description, or just go to the AIProfitBoardroom.com, and inside there, you can get all of my best trainings on how to create AI avatar videos, how to automate your business with AI, how to save time, and that was far easier and more powerful than I expected, actually. I didn't expect it to actually edit the videos as well. That is pretty mind-blowing. Bear in mind, video editors are pretty expensive, and you've got to manage them, whereas now video agents can pretty much do that for you.
So if you want to join, you can, and inside the community, there's 2,800 people, which means you can ask questions, get help and support whenever you want to. You can jump on the weekly coaching course where we go deep on this sort of stuff. If you want to learn how I create AI avatar videos for my business, we have training on that right here, and if you want to get the full guide on Haygen CLI and video agents, you can get that inside this section here too. We also have full courses on Hermes, on OpenClaw, and we add new training guides as they drop day-to-day right here.
So feel free to get all of that inside the AI Profit Boardroom. You can also connect with people in your local city from the map and meet people in your local city who are using AI agents and video agents and all that sort of cool stuff inside the AI Profit Boardroom. Link in the comments description, or just go to the AIProfitBoardroom.com. Thanks for watching.
More episodes