toastsim/scripts/cf-flux.py
type-two 720e4dd5df THE CRITIC'S FACE: he brings his own portraits now
Five moods generated on the Cloudflare Workers AI FLUX lane (10k free
neurons a day — scripts/cf-flux.py is the tap): a gaunt man in a black
three-piece suit, burgundy scarf, small round glasses, tiny notebook and
fountain pen, same claymation family as the judge and unmistakably not
him. Fixed seed, expression-only prompt deltas, so he is the same figure
across all five — the horrified one recoils mid-note, the impressed one
wears the small smile of a man betrayed by a good meal.

The grayscale filter is gone: the scorecard and the corner eye both
route by critic day (critic_* / judge_* prefix), demos and dailies stay
the judge's own. Also fixed 'the the count betrayed you' — his rows
already start with THE and he would never stammer in print.

Verified live: day 20 corner eye critic_neutral, scorecard
critic_impressed at 10.0 and critic_disappointed at 4.9 (C stamp, his
lines), day 21 back to the judge everywhere.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 02:25:40 +10:00

33 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
"""One FLUX-1-schnell image via Cloudflare Workers AI (10k free neurons/day).
Usage: cf-flux.py <outfile.png> <prompt> [steps] [seed]
Creds come from backnforth/.env — never printed, never committed."""
import base64
import json
import os
import sys
import urllib.request
out, prompt = sys.argv[1], sys.argv[2]
steps = int(sys.argv[3]) if len(sys.argv) > 3 else 8
seed = int(sys.argv[4]) if len(sys.argv) > 4 else 0
env = {}
with open(os.path.expanduser('~/Documents/backnforth/.env')) as f:
for line in f:
if '=' in line and not line.startswith('#'):
k, _, v = line.strip().partition('=')
env[k] = v
req = urllib.request.Request(
f"https://api.cloudflare.com/client/v4/accounts/{env['CLOUDFLARE_ACCOUNT_ID']}/ai/run/@cf/black-forest-labs/flux-1-schnell",
data=json.dumps({'prompt': prompt, 'steps': steps, 'seed': seed}).encode(),
headers={'Authorization': f"Bearer {env['CLOUDFLARE_API_TOKEN']}", 'Content-Type': 'application/json'},
)
r = json.load(urllib.request.urlopen(req, timeout=120))
if not r.get('success'):
sys.exit('CF error: ' + json.dumps(r.get('errors')))
with open(out, 'wb') as f:
f.write(base64.b64decode(r['result']['image']))
print(out)