惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
Apple Machine Learning Research
Apple Machine Learning Research
宝玉的分享
宝玉的分享
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
爱范儿
爱范儿
罗磊的独立博客
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
U
Unit 42
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
T
Tailwind CSS Blog
H
Help Net Security
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
人人都是产品经理
人人都是产品经理

Hacker News - Newest: "AI"

AI can't read an investor deck AI as an attorney? Student uses ChatGPT, Gemini to sue UW over alleged racial discrimination Hacking MCP Servers in AI Systems – The Rug Pull: Tool Changes After Approval GitHub - MeepCastana/KubeezCut: Free Web based video editor Can AI judge journalism? A Thiel-backed startup says yes, even if it risks chilling whistleblowers Coming soon: 10 Things That Matter in AI Right Now DARPA built an AI to fact-check enemy weapons claims What explains heterogeneity in AI adoption? When AI Meets Muscle: Context-Aware Electrical Stimulation Promises a New Way to Guide Human Movements - Department of Computer Science AI Changed How We Build. It Did Not Change What Matters. Linux rules on using AI-generated code - Copilot is OK, but humans must take 'full responsibility for the… Meta spins up AI version of Mark Zuckerberg to engage with employees Code Mode: Let Your AI Write Programs, Not Just Call Tools | TanStack Blog GitHub - Delavalom/graft: Go framework for building AI agents. Type-safe tools, multi-provider (OpenAI, Anthropic, Gemini, Bedrock), zero vendor SDKs. India's TCS tops estimates, says new AI models did not dent services demand Gen Z's fading AI hype Strong feeling: we are in a folded AI reality GitHub - machinarii/total-recall-catalog: A reference catalog of latest knowledge retrieval, memory & RAG systems GitHub - mensfeld/code-on-incus: Give each AI agent its own isolated machine with root, Docker, and systemd. Active defense detects and stops threats automatically.. Quantization, LoRA, and the 8% Problem: Benchmarking Local LLMs for Production AI Iran war: We spoke to the man making Lego-style AI videos that experts say are powerful propaganda Powell, Bessent discussed Anthropic's Mythos AI cyber threat with major U.S. banks GitHub - immartian/bellamem: Persistent belief-graph memory for AI agents. Retrieves decisive context by importance — not recency, not RAG, not /compact. recursive-mode: The Repo-Native Operating System for AI Engineering After the attack on Sam Altman's home, will AI CEO's go on the offensive? The biggest advance in AI since the LLM Opus 4.6 vs GPT 5.4 One Prompt Unity World Generation Test “AI polls” are fake polls Client Challenge Can AI be a 'child of God'? Inside Anthropic's meeting with Christian leaders
AI Image Generation from CFML in One Function Call
Paul Kukiel · 2026-06-16 · via Hacker News - Newest: "AI"

I wanted to generate images from CFML. Not call out to some heavyweight Python service, not stand up a GPU — just write a prompt in Lucee and get a picture back. So I built a small library that wraps Cloudflare’s Workers AI image models, and the whole thing comes down to this:

cf  = new cloudflareimages.CloudflareImages();   // creds from env
img = cf.generate( prompt = "a lighthouse on a rocky coast at sunset, painterly" );
img.toFile( expandPath( "./lighthouse.jpg" ) );

That call produced this:

A lighthouse on a rocky coast at sunset

Try it right now

I put a public demo up — type a prompt, hit generate, get an image:

cfml-image-with-cloudflare.kukiel.dev

The demo page

It’s capped at a handful of images a day so it stays free, but it’s a real, live CFML app calling real AI models. Here are a few things people (well, me) have made with it:

A gallery of generated images

The annoying part it hides

Cloudflare gives you a bunch of text-to-image models, and they don’t agree on how to answer. Most of the Stable Diffusion family hand you raw image bytes. Flux hands you JSON with the image base64-encoded inside it. If you call the API directly you end up writing two code paths and a pile of content-type sniffing.

The library makes that disappear. Whatever model you pick, you get back the same GenerationResult:

img.getBinary();    // the raw bytes
img.toBase64();     // base64 (handy for a data: URI)
img.toFile( path ); // write it to disk

The ugly part lives in exactly one place — a response normalizer — so you never think about it. Swap @cf/black-forest-labs/flux-1-schnell for @cf/stabilityai/stable-diffusion-xl-base-1.0 and your code doesn’t change.

More than just generate

It also does image-to-image and inpainting, and it can list the available models:

// reimagine an existing picture
img = cf.imageToImage( prompt = "make it winter", image = expandPath("./summer.png") );

// paint something into a masked region
img = cf.inpaint( prompt = "a hat", image = photo, mask = maskBytes );

// what can I use?
models = cf.listModels();

When something goes wrong it throws typed exceptions, so you can actually react to what failed — a missing token (ConfigError), Cloudflare saying no (APIError, with its real message and code), a network blip (TransportError). The demo uses that to show a friendly “that prompt was blocked” message when the safety filter trips, instead of a raw stack trace.

Testing without burning money

The bit I’m happiest with: the test suite never calls Cloudflare. The one place that touches the network — a tiny Transport component — is swappable, so the tests inject a fake that returns canned responses (raw bytes for SDXL, base64 JSON for Flux). The whole suite runs offline, in milliseconds, costs nothing, and still proves the SDXL-vs-Flux normalization actually works. There’s one live smoke test that only wakes up if real credentials are present.

flowchart: your code → facade → (validate) → Transport (the only cfhttp)
           → Cloudflare → normalizer → GenerationResult → back to you

Each piece is one small CFC with one job. That’s what makes it a drop-in: copy the folder, point it at a Cloudflare account, ask for a picture.

Getting a key

You need a free Cloudflare account and a Workers AI API token (dashboard → AI → Workers AI → REST API). The free tier gives you 10,000 “Neurons” a day at no charge — enough for a few hundred images depending on size. A 512×512 image is cheap; 1024×1024 costs about 4× more, so the demo runs at 512 to stretch the free allowance.

Grab the code

It’s all open source — cloudflareimages on GitHub. Clone it, copy the cloudflareimages/ folder into your app, and you’re away. The README has the full API, a Mermaid diagram of how the pieces fit, and the TestBox suite. Use it, fork it, send a PR, and please share it around — the CFML world could use more of this.

If you give the demo a spin, let me know what you make.