Skip to content
Tutorial

Create and run adverts on AUTOPILOT with Claude Code

Create With51:40337 views

Summary

James demonstrates building a complete AI-powered advertising automation system using Claude Code, the Gemini API (Nano Banana 2), and Meta Marketing API. Starting from a blank folder, he creates a creative matrix system that generates hundreds of ad variations across different personas and templates, builds a local preview UI for curation, and automatically uploads ads to Meta while monitoring campaign performance—all through natural language conversation with Claude Code.

What You'll Learn

Building an Autonomous Ad Generation System With AI

Managing Facebook ad campaigns traditionally involves endless hours in Meta's ad manager, manually creating variations, uploading creative assets, and monitoring performance. For small teams without dedicated designers, running more than a handful of ads becomes impractical. But what if you could generate hundreds of targeted ad variations, upload them automatically, and monitor their performance—all through natural language conversation?

This tutorial walks through building exactly that: a complete AI-powered advertising automation system using Claude Code, the Gemini API, and Meta's Marketing API. The entire system runs locally on your machine, requires minimal technical knowledge, and can produce 500+ ad variations in the time it would take to manually create five.

The Three Prerequisites

Before diving into the build, you need three things:

Meta Marketing API Access: Visit developers.facebook.com, create a new app, and enable Marketing API mode in the settings. Generate an access token with full permissions—since this runs locally, there's no security concern. This token allows Claude Code to interact with your Facebook ad account.

Gemini API Key: Head to Google AI Studio and set up billing. The Gemini 3.1 Flash model ("Nano Banana 2") powers the image generation. The API costs are competitive and minimal compared to the value generated. The quality has improved dramatically—text rendering and logo reproduction are now reliable enough for production ads.

Brand Assets Collection: Gather every relevant asset: logos, event photos, product screenshots, community images, conference pictures—anything that represents your brand. These feed the AI's creative process. The more diverse your asset library, the more varied and authentic your generated ads will be.

The Creative Matrix: Forcing Diversity

Without guidance, AI tends to generate variations that look similar with minimal messaging differences. The solution is a creative matrix—a structured approach that combines personas, topics, and templates to ensure genuine diversity.

The matrix defines three dimensions:

Personas: Target audience segments like builders, founders, career switchers, or the FOMO-driven curious. Each persona has distinct pain points and motivations.

Topics: Core themes such as vibe coding, AI agents, no-code development, automation, and app building. These align with what each persona cares about most.

Templates: Visual layouts including testimonials, comparison charts, iMessage conversation mockups, community snapshots, and event highlights.

Multiplying these dimensions creates 94 unique combinations. A "founder interested in AI agents" gets both a testimonial ad and a community ad. A "career switcher exploring no-code" receives comparison and event highlight variations. This systematic approach produces ads with genuinely different messaging and visual approaches, not just cosmetic tweaks.

Claude Code helps define these parameters through conversation. You describe your product, typical customers, and preferred ad styles. It suggests personas and templates, which you refine until the matrix accurately represents your marketing strategy.

The Local Preview UI

Generating hundreds of ads is pointless if you can't review them. The system includes a simple web interface that runs locally, displaying all generated ads organized by persona and topic. You can filter by category, preview feed versus story formats, and delete unsuccessful generations.

This UI serves two critical purposes. First, it lets you validate the initial outputs before generating the full matrix. You run two or three test generations, verify the AI captured your branding correctly, then scale up. Second, it provides quality control—some generations will fail or include odd elements. The UI makes it trivial to identify and remove these outliers before upload.

Building this UI requires no coding from you. Through natural language prompts, Claude Code creates the interface, handles file organization, and sets up the preview server. You simply open a browser to localhost and start reviewing.

Meta Upload and Campaign Structure

Once you've curated your approved ads, uploading to Meta happens automatically. The system uses Meta's Marketing API to create campaigns, ad sets, and individual ads with proper targeting and budget allocation.

The integration handles the technical complexity: generating properly formatted creative payloads, managing image uploads, setting up A/B testing structures, and organizing ads into logical campaign hierarchies. You can specify budget distribution, audience targeting parameters, and testing strategies through conversation.

This automation revealed something surprising: the ads performing best weren't the ones expected. Manual campaigns tend to reflect creator bias—you make ads you think will work. When generating hundreds of variations systematically, Meta's algorithm identifies winners you would never have created. Different personas respond to different angles, and only broad testing reveals these patterns.

Performance Monitoring

The system tracks campaign performance, pulling metrics directly from Meta's API. You can ask Claude Code questions like "Which persona has the highest click-through rate?" or "Show me the top five performing ads this week." It formats the data clearly, highlighting trends and suggesting optimizations.

This conversational analytics approach makes data accessible without navigating Meta's reporting interface. You get insights when you need them, in the format you need them, without building dashboards or writing queries.

Technical Implementation Details

The entire system runs locally—no web deployment necessary. Claude Code manages the backend processes, API integrations, and file organization. The Gemini API generates images based on detailed prompts constructed from your creative matrix. Meta's Marketing API handles uploads and campaign management.

All prompts and technical setup instructions are documented for replication. You can copy the prompt sequences and adapt them to your brand, products, and target audiences. The time investment is surprisingly small: initial setup takes a few hours, generating the first batch of ads takes under an hour, and subsequent campaigns become faster as the system learns your preferences.

Cost Considerations

Running this system involves several subscription costs. Claude Code (through Anthropic or Cursor) provides the orchestration layer. The Gemini API charges per image generated—costs are minimal, typically a few cents per image. Meta ad spend is separate and depends on your campaign budget.

Compare this to hiring designers, paying for stock photos, or subscribing to design tools. For teams running regular campaigns, the ROI is clear. You're trading manual labor hours for small API fees while dramatically increasing testing volume.

Future Extensions

This foundation enables several advanced capabilities. Video ad generation using Remotion could automate motion graphics. Integration with OpenClaw could expand beyond Meta to other platforms. Custom landing pages could be generated per campaign, creating fully automated marketing funnels.

The long-term vision is autonomous marketing agents: systems that generate creative, launch campaigns, monitor performance, and optimize automatically. This project represents a practical first step toward that future.

Getting Started

Start small. Gather your assets, set up API access, and generate ten ads. Review them, refine your creative matrix, then scale up. The system improves with iteration as you learn which prompts produce the best results and which personas respond to which messages.

The Create With community provides support for builders exploring these techniques. The annual conference showcases similar projects and connects people building AI-powered tools. Whether you're automating marketing, building AI agents, or exploring vibe-coded solutions, the fundamental approach remains the same: use AI to handle repetitive creative work while you focus on strategy and optimization.

Key Learnings

1Creative Matrix Architecture Ensures Ad Diversity

Structuring ad generation around a three-dimensional matrix of personas, topics, and templates produces 94+ genuinely different variations rather than superficial copies. This systematic approach forces the AI to create ads with distinct messaging and visual approaches tailored to specific audience segments.

Learn more about Claude

2Gemini 3.1 Flash Delivers Production-Quality Ad Images

The Nano Banana 2 model now renders text and logos accurately enough for real campaigns, a significant improvement from months prior. This makes it viable for generating hundreds of finished ad creatives without manual design work, all through API calls at minimal cost.

Learn more about Gemini

3Local Preview UI Enables Quality Control at Scale

Building a simple localhost interface for reviewing generated ads allows you to validate outputs before uploading 500+ variations to Meta. This two-stage process—test generation followed by full batch—prevents wasting ad spend on flawed creative.

Learn more about Claude

4Meta Marketing API Enables Full Campaign Automation

Direct API integration handles campaign creation, ad set configuration, creative uploads, and performance monitoring without touching Meta's ad manager interface. This removes the primary friction point in scaling ad testing for small teams.

5Algorithmic Testing Reveals Non-Intuitive Winners

Running hundreds of systematic variations surfaces high-performing ads that manual creation would never produce. The AI explores messaging angles and persona combinations that don't match creator intuition, letting Meta's algorithm identify what actually resonates.

Learn more about Claude

Resources Mentioned

Claude AI Official Website

Anthropic's conversational AI assistant that powers Claude Code for building applications through natural language. Available as desktop app or through Cursor integration.

Visit

Cursor IDE

AI-powered code editor that integrates Claude Code and provides split-pane preview windows. Used throughout this tutorial for the local development environment.

Visit

Google AI Studio - Gemini API

Access point for Gemini API keys and documentation. Includes pricing information for the 3.1 Flash image generation model used for ad creative.

Visit

Meta Marketing API Documentation

Official Facebook developer documentation for programmatic ad management, campaign creation, and performance tracking through the Marketing API.

Visit

Create With Community

UK-based community for AI agents and vibe-coded software builders. Provides support, tutorials, and connections for people building similar automation systems.

Visit

Create With Newsletter

Free newsletter covering no-code, AI, and automation techniques. Includes tutorials, case studies, and community project highlights.

Visit

Frequently Asked Questions

Can I build this system using Claude Co-Work instead of Claude Code?

You can generate the images and handle basic automation in Claude Co-Work, but you won't get the local preview UI that makes reviewing hundreds of ads practical. Claude Code (either through the desktop app or Cursor integration) is recommended because it provides the three-panel interface with file navigation, chat, and preview window that streamlines the workflow.

How much does it cost to generate 500 ads with this system?

The main costs are Claude Code subscription (through Anthropic or Cursor), Gemini API charges (a few cents per image, roughly $5-15 for 500 images), and your Meta ad spend budget. This is significantly cheaper than hiring designers or subscribing to multiple design tools, especially for teams running regular campaigns.

Do I need coding experience to set this up?

No. The system runs entirely through natural language conversation with Claude Code. You need to follow three setup steps—getting Meta and Gemini API keys and gathering brand assets—but the actual building happens through prompts. All prompt sequences are documented for copying and adapting.

Why do some generated ads outperform ones I would have created manually?

Manual ad creation reflects creator bias—you make ads you think will work based on assumptions. Generating hundreds of systematic variations lets Meta's algorithm test messaging angles and persona combinations you wouldn't have considered. The data often reveals that different audience segments respond to unexpected approaches.

Can this system create video ads or extend to other platforms?

Yes. The tutorial mentions Remotion integration for video ad generation as a natural extension. The same approach—creative matrix, local preview, API upload—applies to other advertising platforms beyond Meta. The core architecture is platform-agnostic, requiring only different API integrations.

More content like this

Never miss a video

Get weekly updates on the best AI tutorials, conference recordings, and community content.

Keep Watching

Related Videos

View all videos
55. We're Back! Conference Recap, Running Events with AI & Self-Healing Apps
Podcast35:53

55. We're Back! Conference Recap, Running Events with AI & Self-Healing Apps

James and Kieran return to the Create With Podcast after their summer break to recap the 2026 Create With Conference in Brighton. They discuss how 550 attendees experienced workshops, a charity hackathon where functional apps were built in 30 minutes, and an innovative conference operating system built entirely with AI. The episode covers the latest developments in AI development tools including Anthropic's Fable model, scheduled tasks in Codex, and self-healing applications using PostHog.

The Biggest AI Opportunities for Non-Technical Builders in 2026
Conference38:09

The Biggest AI Opportunities for Non-Technical Builders in 2026

A closing panel discussion from Create With featuring leaders from Glide, Softr, Bubble, Momen, and TechFoundHer examining how AI and no-code platforms are democratizing software development. The panelists explore what non-technical builders can now create, how AI is transforming service businesses, and where expertise still matters when prototypes become production applications.

Everyone Can Build with AI. What Should Companies Do Next?
Conference29:07

Everyone Can Build with AI. What Should Companies Do Next?

A leadership panel from Create With conference exploring how companies should approach AI adoption when building tools becomes accessible to everyone. Four experts debate the gap between technical capability and strategic judgment, discussing governance frameworks, safe experimentation, product sense development, and organizational learning pathways for AI transformation.

How to Get Your Product Recommended by Google and ChatGPT
Conference30:12

How to Get Your Product Recommended by Google and ChatGPT

Tanya Van Gastel presents the APEX framework for making products discoverable in AI-powered search engines like ChatGPT and Google's AI Overviews. She explains how AI is fundamentally changing product discovery and buyer behavior, then breaks down five critical components: Authority (being cited as a solution), Presence (visibility across search platforms), Expertise (creating high-quality money pages), Endorsements (off-site validation), and Extractability (making content easy for AI to process). The talk emphasizes quality over quantity, with data showing 50% of SaaS SEO revenue comes from fewer than 10 high-performing pages.

Inside a 60-Skill Claude Code System Running AI Agents in Parallel
Conference35:21

Inside a 60-Skill Claude Code System Running AI Agents in Parallel

Stephany Oliveros, CEO of Lyra AI, presents a production-ready Claude Code architecture for running dozens of AI agents in parallel. She demonstrates a 60-skill system built on progressive disclosure, layered memory, and reusable components that enable coordinated multi-agent workflows without burning through tokens. The talk covers practical folder structures, guardrails, and token economics for building scalable agentic systems.

The AI-Native Solopreneur: Build Without a Technical Co-Founder
Conference34:21

The AI-Native Solopreneur: Build Without a Technical Co-Founder

Effie Bersoux presents a paradigm shift in entrepreneurship where AI enables solo founders to build, validate, and scale businesses without technical co-founders or significant capital. Drawing from Growth Girls' experience building 40+ companies in one year and going from a £4m exit (7 years) to a £40m acquisition target (1 year), she demonstrates how AI breaks the traditional capital-talent-traction loop that disadvantages undercapitalized founders. The talk provides concrete frameworks for AI-native operating models, automation decision-making, and rapid idea-to-market validation.