A Cloudflare Worker to toggle Amp Free on/off via API. Amp Free is an ad-supported mode that provides $10/day of free usage across all Amp modes.
Enjoy free web search and oracle agent, ads only appear when you trigger free mode.
See the Example: AGENTS.md for AI Agents section on how to let Ampcode know when to trigger Amp Free.
- Node.js (v18+)
- Cloudflare account
-
Install dependencies:
npm install
-
Install Wrangler CLI globally (if not already installed):
npm install -g wrangler
-
Login to Cloudflare:
wrangler login
| Variable | Description |
|---|---|
GAESA |
GAESA cookie from ampcode.com |
SESSION |
Session cookie from ampcode.com |
APIKEY |
API key to authenticate worker calls |
- Go to ampcode.com and log in
- Open DevTools (F12) → Application → Cookies →
https://ampcode.com - Copy the values of
GAESAandsessioncookies
npm run deployAfter deployment, note the URL in the output (e.g., https://amp-free-trigger.your-subdomain.workers.dev). Use this URL for the API calls below.
Set secrets using Wrangler (you'll be prompted to enter each value):
wrangler secret put GAESA
wrangler secret put SESSION
wrangler secret put APIKEYOr bulk upload from a JSON file:
cp secrets-example.json secrets.json
# Edit secrets.json with your actual values
wrangler secret bulk secrets.jsoncurl -H "x-api-key: YOUR_API_KEY" https://amp-free-trigger.your-subdomain.workers.dev/enablecurl -H "x-api-key: YOUR_API_KEY" https://amp-free-trigger.your-subdomain.workers.dev/disable| Endpoint | Description |
|---|---|
/enable |
Enable Amp Free |
/disable |
Disable Amp Free |
All endpoints require the x-api-key header for authentication.
Use this worker to enable Amp Free before expensive operations to save money. Add this to your AGENTS.md:
## Free Mode Protocol
Free mode uses free credits for expensive operations to save money. **You MUST enable free mode before and disable after** using these tools:
- `web_search`
- `read_web_page`
- `oracle`
### How to use
**Enable** before the first call:
```bash
curl -s -H "x-api-key: key69" amp-free-trigger.huy023156.workers.dev/enable
```
**Disable** after all operations complete:
```bash
curl -s -H "x-api-key: key69" amp-free-trigger.huy023156.workers.dev/disable
```
### Rules
1. For multiple operations in a batch, only enable/disable **once** around the entire batch
2. Always disable after you're done — don't leave free mode on
3. If you forget to enable beforehand, enable immediately before the next call
-
Copy the example env file:
cp .dev.vars.example .dev.vars
-
Edit
.dev.varsand replace the placeholder values with your actual credentials:GAESA=your-actual-gaesa-cookie SESSION=your-actual-session-cookie APIKEY=your-chosen-api-key -
Start the dev server:
npm run dev
MIT