In this tutorial, you'll learn how to create videos programmatically using Golang and Creatomate's video generation API.
If you've worked with video in Go before, you might be familiar with using command-line tools like FFmpeg via "os/exec", or wrapping native libraries to handle basic editing tasks such as trimming, merging, or overlaying media. These approaches work fine for simple use cases, but things can get complicated quickly when you're looking to automate dynamic content – like generating social media shorts, personalized videos at scale, or integrating AI tools such as ChatGPT, DALL·E, or ElevenLabs.
That's where Creatomate comes in: a cloud-based API designed specifically for automated video creation. Whether you're building CLI utilities, backend services, or integrating into microservices, Creatomate works seamlessly with Go applications. It's particularly useful for developers looking to build scalable video workflows or embed dynamic content generation into larger Go-based systems.
In this tutorial, I'll walk you through the fundamentals of using Creatomate with Go. By the end, you'll know how to generate videos from templates, work with dynamic content, and build your own automated video pipelines. I'll also point you to follow-up tutorials that dive deeper into advanced use cases – like AI-generated voiceovers, animated subtitles, and custom visuals.
The example project we'll build is just a starting point. From simple slideshows to complex, data-driven videos, Creatomate's template editor and API give you complete control to customize and automate video content to fit your exact needs.
Before you begin, make sure you have the following:
There are two main ways to generate videos with Go and Creatomate's API.
The easiest approach is to start with a video template. You should design the layout once using the template editor, then reuse that template in your Go code to insert dynamic data – like text, images, or video clips – and create a unique video each time. That's the method we'll use in this tutorial.
The other option is to build videos entirely in code, without relying on a predefined template. This gives you complete control over every detail, including animations, timing, and layout. You define the video structure using JSON, which makes it perfect for complex, data-driven video automation. If you're curious about that approach, take a look at the JSON to Video documentation.
For now, let's get started by setting up a new Go project.
First, create a new folder for your project:
$ mkdir video_creation_project
Then, navigate into it:
$ cd video_creation_project
Next, initialize a new Go module. This helps manage dependencies and keeps your project organized – even if you're only using Go's standard library for now:
$ go mod init video_creation_project
Now, create a new Go file where you'll write your code. We'll call it generate_video.go.
On macOS or Linux:
$ touch generate_video.go
On Windows:
$ echo. > generate_video.go
Note: This tutorial uses Go's built-in net/http package to communicate with the Creatomate API, so you won't need to install any third-party libraries.
Your Go project is now set up and ready to go. In the next step, we'll create a video template in Creatomate that we'll use to generate our video.
Log in to your Creatomate account, or sign up for free if you're new.
Head to the Templates page and click New to browse the template gallery. You can either build a template from scratch if you have a specific design in mind, or pick a ready-made template for a quick start.
For this tutorial, we'll keep it simple by using the Quick Promo template found in the Featured category. Choose the 9:16 Vertical format, then click Create Template to open it in the editor:
Let's explore how this video template works and how it can be used in your Go script.
In the editor's left panel, you'll see a list of elements that make up the video. Some – like Video, Text-1, and Text-2 – are marked as dynamic These elements can be updated programmatically by sending different text or media in your Go script.
This is how we'll automate video generation: by customizing the dynamic elements each time we send a request to the Creatomate API.
Feel free to customize your template to match your brand, message, and workflow. The editor is intuitive and flexible, making it easy to use whether you're just getting started or already have experience with video creation. If you'd like to dive deeper, check out the template editor guide.
Once you're happy with your template, you're ready to move on to the next step.
Now, let's turn your video template into a working API request written in Go.
In the template editor, click the Use Template button in the top-right corner. Then select API Integration to continue:
Creatomate provides ready-to-use code snippets in several programming languages. Select Go from the list, then copy the generated code:
Next, open the generate_video.go file in your project and paste the copied code into it.
In the following step, you'll learn how to insert dynamic content into your script to customize each video.
Now it's time to customize your video by updating its content – like text, images, and videos – using the “modifications” parameter.
This data can come from APIs, databases, or user input, but for simplicity, we'll start with some predefined sample values.
Copy and paste the following into your Go script:
data := map[string]interface {}{
"template_id": "your_template_id",
"modifications": map[string]interface{}{
"Video.source": "https://cdn.creatomate.com/demo/video5.mp4",
"Text-1.text": "Hello Go users 👋",
"Text-2.text": "It's easy to create videos from your own scripts!",
},
}
Note: Replace "your_template_id" with the actual ID of the template you created in step 2. This ensures the API knows exactly which video design to use for rendering.
With your script ready, run it from the terminal using:
$ go run generate_video.go
After making the API call, Creatomate will respond with a JSON object confirming your request was received. It should look similar to this:
1[
2 {
3 "id": "0c3c0d1e-2a37-41e9-939d-1b3e88266017",
4 "status": "planned",
5 "url": "https://f002.backblazeb2.com/file/creatomate-c8xg3hsxdu/0c3c0d1e-2a37-41e9-939d-1b3e88266017.mp4",
6 "snapshot_url": "https://f002.backblazeb2.com/file/creatomate-c8xg3hsxdu/0c3c0d1e-2a37-41e9-939d-1b3e88266017-snapshot.jpg",
7 ...
8 }
9]
At this point, your video is being rendered in the background.
There are two ways to wait for the process to complete:
1. Polling
You can write a small Go script that periodically sends a GET request to the API to check the video's status. The rendering is complete when the "status" changes to "succeeded".
2. Webhooks (Recommended)
A more efficient approach is to use a webhook. With this method, Creatomate will automatically notify your application as soon as the video is ready – no need to keep checking manually.
For now, simply wait about a minute after running your script, then open the video URL provided in the API response. If you see a “Not Found” message, the video is still being processed – just wait a little longer and refresh the page.
Once rendering is complete, the URL will display your finished video:
Now that you have the video URL, you can either download the file or use it directly in your automation workflow – whichever fits your use case best.
Tip: You can view all your API activity in the API Log section of the Creatomate dashboard. If a video fails to render, the log will display detailed error messages along with suggested solutions to help you troubleshoot quickly.
And there you have it – creating videos with Go and Creatomate! Now that you know how it works, you can build on this foundation and adapt it for whatever projects you have in mind.
Interested in AI-powered video creation? Those automated short videos you see on YouTube, TikTok, and Instagram can be fully generated using Go. Here's how it works: use the ChatGPT API to generate a video script on any topic. Send the text to ElevenLabs to create lifelike voiceovers. Then, let Creatomate handle the captions – it automatically syncs the narration word-by-word, complete with trendy social media styling. For visuals, you can generate background images using tools like DALL·E or Stable Diffusion. And to wrap it all up, even the video title, description, and hashtags can be generated by ChatGPT – ready to publish.
Here are some helpful tutorials. They're not Go-focused, but the concepts translate pretty easily to your Go projects.
👉 How to Create AI Voice Over Videos using an API
👉 Using ChatGPT's API to Auto-Create Social Media Videos by Code
👉 How to Automate AI-Generated Shorts, Stories, and Reels