Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6e67b7b
first commit with all the artifacts
ucegbe Oct 7, 2025
eebf503
Delete 02-samples/16-ai-ads-generation-agent-with-crypto-payments/pai…
ucegbe Oct 7, 2025
a641e1e
uploaded clean server script for the solution
ucegbe Oct 7, 2025
cfd5ea5
Update requirements.txt
ucegbe Oct 7, 2025
a172c44
Delete 02-samples/16-ai-ads-generation-agent-with-crypto-payments/age…
ucegbe Oct 7, 2025
4212953
Delete 02-samples/16-ai-ads-generation-agent-with-crypto-payments/pai…
ucegbe Oct 7, 2025
a634101
updated files to cater to security findings
ucegbe Oct 7, 2025
f9f8d45
Delete 02-samples/16-ai-ads-generation-agent-with-crypto-payments/out…
ucegbe Oct 10, 2025
3de5c67
Delete 02-samples/16-ai-ads-generation-agent-with-crypto-payments/ad_…
ucegbe Oct 10, 2025
8c01d0a
Add files via upload
ucegbe Oct 10, 2025
538c8b6
Update README.md
ucegbe Oct 10, 2025
29774f8
Create .env.example
ucegbe Oct 10, 2025
c0f9606
Delete 02-samples/16-ai-ads-generation-agent-with-crypto-payments/age…
ucegbe Oct 10, 2025
1de3a2c
Add files via upload
ucegbe Oct 10, 2025
1ac894d
Update requirements.txt
ucegbe Oct 10, 2025
3775d61
Update README.md
ucegbe Oct 13, 2025
2816aac
Update .env.example
ucegbe Oct 13, 2025
067c626
Update README.md
ucegbe Nov 5, 2025
8039afc
Merge branch 'strands-agents:main' into main
ucegbe Nov 6, 2025
37a120e
Update README.md
ucegbe Nov 6, 2025
5235cde
Add files via upload
ucegbe Nov 6, 2025
4e7534e
Update README.md
ucegbe Nov 6, 2025
697e549
Create 18-ai-ads-generation-agent-with-crypto-payments
ucegbe Nov 6, 2025
e24b1fe
Update and rename 02-samples/18-ai-ads-generation-agent-with-crypto-p…
ucegbe Nov 6, 2025
9de5343
Revert "Update README.md"
ucegbe Nov 6, 2025
3a88a1d
Revert "Update and rename 02-samples/18-ai-ads-generation-agent-with-…
ucegbe Nov 6, 2025
f5d2b88
Revert "Create 18-ai-ads-generation-agent-with-crypto-payments"
ucegbe Nov 6, 2025
2765914
update
ucegbe Nov 6, 2025
78e824f
Update README.md
ucegbe Nov 6, 2025
63cff5a
Update README.md
ucegbe Nov 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CDP_API_KEY_ID=""
CDP_API_KEY_SECRET=""
CDP_WALLET_SECRET=""
ADDRESS=""
OPENWEATHER_API_KEY=""
# If not working in an already configured AWS environment, provide values for the following
# AWS_BEARER_TOKEN_BEDROCK=""
# OR
# AWS_ACCESS_KEY_ID=""
# AWS_SECRET_ACCESS_KEY=""
# AWS_REGION=""
131 changes: 131 additions & 0 deletions 02-samples/16-ai-ads-generation-agent-with-crypto-payments/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Autonomous AI Advertising Agent with Crypto Payments

An AI agent that creates complete advertising campaigns while autonomously paying for premium services using cryptocurrency via the X402 payment protocol.

## Overview

### Sample Details

| Information | Details |
|------------------------|------------------------------------------------------------|
| **Agent Architecture** | Single-agent |
| **Native Tools** | image_reader |
| **Custom Tools** | list_available_services, get_service_schema, create_ad_html |
| **MCP Servers** | None |
| **Use Case Vertical** | Marketing & Advertising |
| **Complexity** | Advanced |
| **Model Provider** | Amazon Bedrock (Claude Sonnet 4) |
| **SDK Used** | Strands Agents SDK + Coinbase AgentKit |

### Architecture

The sample demonstrates integration between multiple systems:
- **Strands AI Framework** → Agent reasoning and tool orchestration
- **Coinbase AgentKit** → Blockchain wallet and transaction management
- **X402 Protocol** → HTTP-based micropayment standard for API access
- **External APIs** → Payment-gated image generation and weather services

### Key Features

- **Economic Agency**: AI agent manages its own budget and purchases services autonomously
- **Crypto-Native Payments**: Uses USDC on Base Sepolia testnet for service payments
- **Multi-Service Integration**: Combines weather data and AI image generation for enhanced campaigns
- **Complete Campaign Generation**: Produces ready-to-deploy HTML advertising assets

## Prerequisites

- Python **3.10+**
- [AWS CLI configured with appropriate credentials](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html)
- [Model access](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-prereq.html) for Claude Sonnet 4 on Amazon Bedrock
- [Coinbase Developer Platform account](https://docs.cdp.coinbase.com/get-started/quickstart) to get your coinbase API credentials and Wallet secret.
- [OpenWeather API key](https://openweathermap.org/guide)
- **⚠️ TESTNET ONLY**: Base Sepolia testnet wallet with test USDC

## Setup

1. **Configure environment variables:**
```bash
cp .env.example .env
# Edit .env with your configuration:
# - CDP_API_KEY_ID, CDP_API_KEY_SECRET, CDP_WALLET_SECRET (Coinbase Developer credentials)
# - ADDRESS (Receiving Address of payment)
# - OPENWEATHER_API_KEY
```

2. **Install dependencies:**
```bash
uv pip install requirements.txt
```

3. **Start the payment server:**
```bash
uv run paid_server.py
```

## Usage

**Run the advertising agent:**

**Execute the `agentkit-x402-strands` notebook:**
1. Open the notebook and run cells sequentially
2. The agent will automatically:
- Discover available services
- Make cryptocurrency payments for premium APIs
- Generate weather-responsive ad campaigns
- Create visual assets using AI image generation
- Output complete HTML advertising campaigns

**Example interaction:**
```python
response = advertising_agent("""Generate an ad for:
product="ice cream shop promotion",
city="Miami,US",
platform="social-media"
""")
```

## Example Output

The agent produces:
- Weather-responsive ad copy based on real-time conditions
- AI-generated tropical imagery for campaigns stored in `output` dir
- Complete HTML files with embedded visuals stored in `ad-creative` dir
- Multi-platform advertising assets (social media, display, email)

## Troubleshooting

| Symptom | Likely Cause | Fix |
|---------|-------------|-----|
| Payment failures | Insufficient testnet USDC | Fund wallet via Base Sepolia faucet |
| API key errors | Missing environment variables | Verify all required keys in `.env` |
| Image generation fails | Payment server not running | Start `paid_server.py` first |

## Safety Notice

**⚠️ TESTNET ONLY - DO NOT USE REAL FUNDS**
- This sample uses Base Sepolia testnet exclusively
- Only use test credentials and testnet tokens
- Never run with production wallets or mainnet addresses
- Educational demonstration purposes only

## Cleanup

Stop the payment server:
```bash
# Press Ctrl+C to stop paid_server.py
```

No additional infrastructure cleanup required.

---

## Disclaimer

This sample is provided for educational and demonstration purposes only. It is not intended for production use without further development, testing, and hardening.

For production deployments, consider:
- Implementing appropriate content filtering and safety measures
- Following security best practices for cryptocurrency handling
- Conducting thorough testing on testnets before any mainnet deployment
- Reviewing and adjusting payment amounts and security configurations
- Implementing proper wallet management and key security practices
Loading