How to use Googles evolutionary coding agent to evolve a function that beats your own baseline, on Google Cloud.
My Honest Take, Up Front
AlphaEvolve on Google Cloud is the real deal. I pointed it at the most expensive function in my own macOS app, the per-frame webcam background blur, and it made that function 3.4x faster with visually identical output, in ten candidates, with no human in the loop.
⚠️⚠️ But forcing us into a Gemini Enterprise subscription to use it is the wrong call. Plain and simple.
This is a developer API. It has no UI, no workspace, no assistant. Nothing about it is an enterprise seat product.
The heavy lifting on my side runs on my own hardware. And yet I still need a per-user license for an enterprise suite before I can make a single API call.
Google already has the right home for this. It is called Vertex AI and the Agent Platform. Consumption-based, pay for what you run, the model every developer on this platform already knows and trusts.
There is no technical reason AlphaEvolve is not there. Only a packaging decision.
And that decision hurts exactly the wrong people. Researchers, indie developers, and small teams are the ones who will find the surprising wins and tell the world about them.
They will not buy an enterprise seat bundle to try an API. They will close the tab. The blog title says AlphaEvolve is available for everyone. It is not. It is available only to Gemini Enterprise customers. Put it on Agent Platform (formerly Vertex AI) with per-use pricing.
What We Will Build
In today’s article, we take the most expensive function in a real shipping app, the per-frame webcam background blur from https://stagestudio.tv , a native macOS streaming studio, and let AlphaEvolve make it faster without changing how it looks. We read the real speedup together. AlphaEvolve is the Gemini powered evolutionary coding agent from DeepMind, the one famous for discovering a faster matrix multiplication and tuning Google’s own datacenters.
This is for AI and Google Cloud developers who have an optimization problem they can score. Not a chatbot, not autocomplete, a real “make this number go up” problem. If you can write a function that scores an answer, you can point AlphaEvolve at it.
It is DeepMind research from 2025. What actually shipped, and what makes this article possible, is that it went generally available on Google Cloud, and Google published an open source client library. So for the first time you can run it on your own code instead of reading a paper about it.

Jump to the Code
The complete, reproducible experiment is on GitHub, in gen-ai-livestream/alphaevolve/examples/camera-background-blur, the seed, the evaluator, the bench harness, and the winning program. The same folder’s parent ships a generic evolve.py you can point at any Python function, and it is packaged as an agent skill you can install, more on that near the end.
What Is AlphaEvolve
AlphaEvolve runs a closed evolutionary loop. You give it a seed program and a scoring function. It uses a mixture of Gemini models to propose variations of your code, runs your scorer on each candidate, keeps the winners, and climbs toward a better score over many generations. It is Darwin, pointed at your code.
The clever part is the split. The generation half is a managed service in Google Cloud, a prompt sampler, a Gemini ensemble, and a program database. The evaluation half is your code, running wherever you want. You own exactly one piece, the evaluator, because scoring is domain specific and only you know what better means for your problem.

Mark It, and Score It
Two things make a program evolvable. First, you wrap the region you want rewritten in two comment markers. AlphaEvolve only ever touches what is between them, everything else it leaves alone. Our seed is a faithful copy of the app’s real blur kernel, and the region it may rewrite is the per-frame process function.
// EVOLVE-BLOCK-START
func process(_ pixelBuffer: CVPixelBuffer, frameIndex: Int, ...) -> CIImage {
// person segmentation, feather the mask, two full-res Gaussian blurs, composite
... // AlphaEvolve rewrites this
}
// EVOLVE-BLOCK-END
Yes, that is Swift. AlphaEvolve is Python first, but evaluation is entirely your code, so any language you can compile and score works. Our evaluator compiles each candidate with swiftc and runs it over a fixed webcam clip.
Second, and this is the whole craft, you write an evaluator that returns numbers AlphaEvolve cannot game. Here is the trap that catches everyone. AlphaEvolve never sees the blurred frame. It cannot look at the picture. It only reads the scalars your evaluator returns. So if you score raw speed, the fastest “blur” is the one that does nothing at all.
The fix is to score speed, gated by quality.
speedup = baseline_ms_per_frame / candidate_ms_per_frame
ssim = mean_ssim_vs_golden # golden frames are the seed's own output
if ssim < 0.98 or worst_frame_ssim < 0.95:
return {"speedup": -1e12} # below the floor, it does not count
return {"speedup": speedup, "ssim": ssim}
Quality is a rule, not a tradeoff. The only way to score is to look identical to today’s app and be faster. That gate is the entire experiment, and getting it right is where your effort goes, not the client wiring. If your metric has a loophole, evolution finds the loophole, not the optimization.
Kick Off the Evolution
The controller loop asks the backend for candidates, and for each one your evaluator compiles it, runs it over the clip, and reports the numbers back. The whole thing is a few lines around the example’s evolve.py.
cd alphaevolve/examples/camera-background-blur
gcloud auth application-default login
export PROJECT_ID=your-project GE_APP_ID=your-gemini-enterprise-engine-id
python evolve.py # compiles and scores each candidate on your Mac
Now watch it work. Progress is non monotonic, some candidates come back slower, and some fail the quality gate and get the sentinel score, minus 1e12. That is not a bug, it is how evolutionary search works, like a hiker who has to walk downhill to reach a taller peak, do not stop a run early because a candidate regressed. Each failure also returns an insight string, a compile error versus an SSIM miss, so the evolver learns why a candidate died, not just that it died. After ten candidates it had converged.
The Result
So does the machine actually beat hand-written production code? The seed, the app’s real blur, cost 17.95 ms per frame at 1080p, more than half the 33 ms budget of a 30fps loop. The evolved kernel cost 5.26 ms, a 3.4x speedup, at SSIM 0.998 against the original, visually identical. Timing is noisy, independent re-runs land between 2.8x and 5.4x, so the honest headline is the clean-run median, 3.4x.

And it did not just tune constants. The winning kernel cached the person segmentation and recomputed it only every third frame, ran the whole blur pipeline at quarter resolution and upscaled, and kept the full-resolution mask only for the final composite. It even reached for VNSequenceRequestHandler, Vision’s video-stream API, an idea that was nowhere in the prompt. That is the part that still gets me, it found techniques, not just numbers. It is search, not magic, and the quality of your evaluator decides what it finds.
The Honest Part
This is the section I never skip. A few things will bite you, and you should know them before you plan a project around this.
It needs a Gemini Enterprise license. Any tier works, including a trial, but AlphaEvolve is not on a free tier. No license, no access. Budget for that first.
Your evaluator is the whole game, and it can be fooled. The clip I benchmark on has to contain a person. Vision returns an all-background mask on empty footage, so a lazy candidate that just blurs the whole frame scores near-perfect SSIM and cheats the gate. I caught this only because a deliberately-broken test candidate passed when it should have failed. If your metric has a hole, evolution finds the hole.
Keep evaluation concurrency low. Candidates share one GPU and the score is wall-clock milliseconds, so parallel evaluations skew each other’s timing. Two at a time was the ceiling for a trustworthy number.
It is an optimizer, not a coding assistant. Do not reach for this for general code generation or linting. You need a problem with a number you can push up. If you cannot write the scorer, this is the wrong tool.
Take It Home as an Agent Skill
Everything above is packaged as an agent skill. After installing, your agent knows the whole loop, wrap a function in EVOLVE-BLOCK markers, write a scoring function, drive the controller loop against your own Gemini Enterprise engine, and read back the best program. It also carries the sharp edges from this article, the license gate, the non monotonic patience, the ADC login.
npx skills add https://github.com/SaschaHeyer/gen-ai-livestream/tree/main/alphaevolve/skill
It sits on top of Google’s own open source client library, which is genuinely good and worth reading. That library is the API surface, the skill is the specialist that carries what the runs earned.
Conclusion
I like this a lot. Handing a machine the real bottleneck from my own app and getting back a version that is 3.4x faster and pixel-for-pixel identical, with the whole search visible on screen, is the kind of thing that felt like a research demo a year ago and is now a python evolve.py away. Watching it reach for a Vision API I had not mentioned was the moment it clicked for me.
You already know my one real reservation, I opened the article with it. The capability is genuinely exciting. I just want it on Vertex AI/Agent Platform with per-use pricing, in the hands of the researchers and indie developers who will do the most surprising things with it instead of a subscription model.
You Made It To The End.
I hope you enjoyed the article.
Got thoughts? Feedback? Discovered a bug while running the code? I’d love to hear about it.
- Connect with me on LinkedIn. Let’s network! Send a connection request, tell me what you’re working on, or just say hi.
- AND Subscribe to my YouTube Channel ❤️
Running AlphaEvolve on Your Own Code was originally published in Google Cloud – Community on Medium, where people are continuing the conversation by highlighting and responding to this story.
Source Credit: https://medium.com/google-cloud/running-alphaevolve-on-your-own-code-f8aeebceb4d0?source=rss—-e52cf94d98af—4
