Skip to main content
Glama
README.md
# Image Generator MCP

AI image generation with DALL-E 3 and x402 micropayments on Base.

## Features

- šŸŽØ **AI Image Generation** - Generate high-quality images from text prompts using OpenAI DALL-E 3
- šŸ’³ **x402 Payments** - Pay $0.010 USDC per image via Base mainnet
- šŸ“ **Multiple Sizes** - 1024x1024, 1024x1792 (portrait), 1792x1024 (landscape)
- ⚔ **Fast Generation** - Images generated in seconds
- šŸ”’ **Payment Verification** - Secure payment verification via Coinbase CDP Facilitator

## Live Demo

🌐 **Service URL:** [https://image-generator-mcp.vercel.app](https://image-generator-mcp.vercel.app)

## API Endpoints

### POST /api/generate
Generate AI image from text prompt

**Request:**
```json
{
  "prompt": "A serene mountain landscape at sunset",
  "size": "1024x1024",
  "quality": "standard"
}
```

**Parameters:**
- `prompt` (required) - Text description of the image
- `size` (optional) - Image dimensions: `1024x1024`, `1024x1792`, `1792x1024` (default: `1024x1024`)
- `quality` (optional) - Image quality: `standard`, `hd` (default: `standard`)

**Response:**
```json
{
  "success": true,
  "prompt": "A serene mountain landscape at sunset",
  "revisedPrompt": "A tranquil mountain scene...",
  "imageUrl": "https://oaidalleapiprodscus.blob.core.windows.net/...",
  "size": "1024x1024",
  "quality": "standard",
  "generatedAt": "2026-09-06T10:45:00.000Z",
  "payment": {
    "verified": true,
    "amount": "0.010",
    "currency": "USDC"
  }
}
```

### GET /.well-known/x402
x402 Bazaar discovery endpoint (free)

### GET /mcp/tools
MCP tool metadata (free)

### GET /health
Health check endpoint (free)

## Payment Details

- **Network:** Base Mainnet (eip155:8453)
- **Currency:** USDC
- **Price:** $0.010 per image
- **Protocol:** x402 v2 "exact" scheme
- **Payment Address:** `0xf081ee84c0d85278a6242bc265f0b312021ebeb1`

## Setup

### Prerequisites
- Node.js 18+
- OpenAI API key
- Vercel account (for deployment)

### Installation

```bash
npm install
```

### Environment Variables

Create a `.env` file:

```env
OPENAI_API_KEY=your_openai_api_key_here
X402_FACILITATOR_URL=https://api.cdp.coinbase.com/platform/v2/x402
PORT=3000
```

### Local Development

```bash
npm start
```

Server runs on http://localhost:3000

## Deployment

### Deploy to Vercel

```bash
# Install Vercel CLI
npm i -g vercel

# Deploy
vercel

# Set environment variable
vercel env add OPENAI_API_KEY
```

Add your OpenAI API key when prompted.

## How x402 Payment Works

1. Agent calls `/api/generate` without payment
2. Server returns 402 with payment details in `PAYMENT-REQUIRED` header
3. Agent pays $0.010 USDC on Base via CDP Facilitator
4. Agent retries with `PAYMENT-SIGNATURE` header
5. Server verifies payment and generates image

## Tech Stack

- **Express.js** - Web server
- **@x402/core** - Payment verification
- **OpenAI API** - DALL-E 3 image generation
- **Base Mainnet** - Low-fee L2 blockchain
- **Vercel** - Serverless deployment

## License

MIT

## Support

For issues or questions, open an issue on GitHub.