text
stringlengths
0
59.1k
- `lib/agent.ts`: VoltAgent `Agent` plus `getCurrentTime` tool
- `lib/bot.ts`: Chat SDK adapter setup, mention/subscribed/action handlers
- `app/api/webhooks/[platform]/route.ts`: dynamic webhook route with `waitUntil`
If Slack credentials are missing, the webhook route returns a clear runtime error instead of failing the build.
<|endoftext|>
# source: VoltAgent__voltagent/website/recipes/ad-creator.md type: docs
---
id: ad-creator
slug: ai-instagram-ad-agent
title: AI Ads Generator Agent
description: Build Instagram ads with VoltAgent, BrowserBase and Gemini.
repository: https://github.com/VoltAgent/voltagent/tree/main/examples/with-ad-creator
---
This example implements an Instagram ad generator with VoltAgent. The system uses BrowserBase Stagehand to analyze landing pages, extracts brand data, and generates visuals through Google Gemini AI.
The implementation includes:
- Web page navigation and analysis via BrowserBase Stagehand
- Brand data extraction (tone, audience, value propositions)
- Screenshot capture for visual reference
- Creative brief generation through AI models
- Ad visual generation using Google Gemini
- Multi-agent workflow orchestration
### Setup
<Info title="Required accounts and API keys:">
- Sign in to [VoltOps LLM Observability platform](https://console.voltagent.dev/login)
- A [BrowserBase account](https://browserbase.com) with API key and project ID
- Google Generative AI access for [Gemini API](https://ai.google.dev/gemini-api)
- An OpenAI API key from [platform.openai.com](https://platform.openai.com/api-keys)
</Info>
#### Get the example code
Clone the ad generator example using the VoltAgent CLI:
```bash
npm create voltagent-app@latest -- --example with-ad-creator
cd with-ad-creator
```
You can find the source code of this example [here](https://github.com/VoltAgent/voltagent/tree/main/examples/with-ad-creator).
#### Configure environment variables
Create a `.env` file with your API keys:
```env
# Language models
GOOGLE_GENERATIVE_AI_API_KEY=your_google_generative_ai_api_key
OPENAI_API_KEY=your_openai_api_key
# BrowserBase Stagehand
BROWSERBASE_API_KEY=your_browserbase_api_key
BROWSERBASE_PROJECT_ID=your_browserbase_project_id
# Optional VoltOps tracing
VOLTAGENT_PUBLIC_KEY=your_public_key
VOLTAGENT_SECRET_KEY=your_secret_key
```
#### Set Up BrowserBase
Configure BrowserBase:
1. Create a BrowserBase account at [browserbase.com](https://browserbase.com)
2. Navigate to your dashboard and create a new project
3. Copy your API key from the API Keys section
4. Copy your Project ID from the project settings
5. Add both values to your `.env` file
For BrowserBase configuration details, see [BrowserBase documentation](https://docs.browserbase.com/introduction).
![browserbase dashboard](https://cdn.voltagent.dev/examples/with-ad-generator/browserbase.png)
#### Configure Google Gemini API
Set up Google Gemini for image generation:
1. Go to [Google AI Studio](https://aistudio.google.com/apikey)
2. Click "Get API Key" and create a new API key
3. Enable the Generative AI API in your Google Cloud Console if needed
4. Add the API key to your `.env` file as `GOOGLE_GENERATIVE_AI_API_KEY`
Google Gemini handles creative brief generation and image creation.
#### Start the Development Server
```bash
npm run dev
```
After server startup:
```bash