

Leveraging the Gemini CLI and the underlying Gemini LLM for code generation to add support for deploying AI applications built in the Rust Language.
Gemini CLI Code Generation
This tutorial aims to port existing API code from Typescript to Rust. Google provides a sample store based on a micro service architecture— the Cymbal Super Store. This sample code includes an inventory API implemented in Typescript with a Firestore backing Database. This Typescript project is meant to be called on traditional routes to provide inventory management via an API.
What is this Tutorial Trying to Do?
Traditionally, ML and AI tools have been deployed in interpreted languages like Python, and Java. One of the key goals of this tutorial is to validate that a compiled language like Rust can be used for AI software development beyond the traditional interpreted languages.
What is Rust?
Rust is a high performance, memory safe, compiled language:
Rust provides memory safe operations beyond C/C++ and also can provide exceptional performance gains as it is compiled directly to native binaries.
Initial Environment Setup
The environment is meant to be run from a Bash like shell. You can run this from a Linux VM, ChromeOS Linux VM, Firebase Studio environment, or any environment that provides a basic shell. You will also need a working Docker environment.
Rust Setup
Instructions to install Rust are available here:
For a Linux like environment the command looks like this:
curl — proto ‘=https’ — tlsv1.2 -sSf https://sh.rustup.rs | sh
Gemini CLI
If not pre-installed you can download the Gemini CLI to interact with the source files and provide real-time assistance:
sudo npm install -g @google/gemini-cli
Note- if you are an a non standard environment — you will need to make sure to have at least Node version 20 available in order to run Gemini CLI.
Testing the CLI Environment from the VM
Once you have all the tools and the correct Node.js version in place- you can test the startup of Gemini CLI. You will need to authenticate with a Key or your Google Account:
gemini
Clone the Repo and Setup the Basic Environment
Now that the Gemini CLI has been validated from the base shell — you can clone the GitHub Repo with support scripts:
cd ~
git clone https://github.com/xbill9/gemini-cli-codeassist
Then run init.sh from the cloned directory. The script will attempt to determine your shell environment and set the correct variables:
cd gemini-cli-codeassist
source init.sh
Build and Deploy the Typescript Backend to Cloud Run
A sample script is provided to push a basic API deployment to Cloud Run. This build will deploy the Typescript version of the Cymbal inventory API that has been extended with MCP support:
cd mcp-ts
make deploy
Check the messages in the console for the direct URL to the Backend endpoint hosted on Cloud Run:
https://inventory-1056842563084.us-central1.run.app/
🍎 Hello! This is the Cymbal Superstore Inventory API.
Verify the /products endpoint
The first call to the endpoint will populate the Firestore database with sample product data. It may take a few minutes for the entire setup to complete. You can validate the Data has been loaded by accessing the /products endpoint :
https://inventory-1056842563084.us-central1.run.app/products
Rust Deployment Strategy
Rust has not been the typical deployment path for AI based software development — so a step by step approach is used with validation at each milestone.
Testing the Waters — Rust On Google Cloud with Cloud Run
There has been some initial exploration of using Rust inside a container deployed to Cloud Run. A greater starter GitHub repo is available here:
This repository and article provide the basic minimum viable proof of concept that compiled Rust Code can be successfully deployed to a container hosted on Google Cloud Run.
Validate Rust Container Approach with Gemini CLI
The next step is to build a project with Rust code based on the minimally viable sample. Conceptually this is a bit different than Node or Python containers. Node and Python are interpreted languages- so the supporting runtimes are usually copied into the container along with the application code to run. Rust is a compiled language like C or C++. The final binary must be fully built from source and inserted as the entry point of the container.
Updating the Minimally Viable Sample
Gemini CLI is used to analyze and update the sample Rust code and generate recommendations to follow for current best practices:
Then, cloudbuild.yaml is reviewed with Gemini CLI:
Finally — Gemini CLI performs a basic code review of all the project files:
Build and Deploy the Container on Cloud Run
With the Makefile, Dockerfile, and cloudbuild.yaml verified — submit the build to Cloud Build. This will compile the source code and deploy the final binary into the container for Cloud Run:
xbill@penguin:~/gemini-cli-codeassist/cloudrun-rust$ make deploy
Submitting build to Google Cloud Build...
gcloud builds submit . --config cloudbuild.yaml --substitutions=_SERVICE_NAME=cloudrun-rust,_REGION=us-central1,SHORT_SHA=6d72570
Creating temporary archive of 1162 file(s) totalling 421.4 MiB before compression.
When the build is complete — the Cloud Run endpoint will be available:
Step #2 - "Deploy": Service [cloudrun-rust] revision [cloudrun-rust-00022-2xn] has been deployed and is serving 100 percent of traffic.
Step #2 - "Deploy": Service URL: https://cloudrun-rust-1056842563084.us-central1.run.app
Check the Container on Cloud Run
Verify that the simple message is returned when accessing the deployed container:
You can validate that the entire build process works by varying the message in the src/main.rs.
Update the message in the source code from “Hello Rust!!!” to “Rust Never Sleeps!!!” and re-run the deployment. You can verify that the complete build is successful by checking the message on the deployed URL after the update build has completed:
xbill@penguin:~/gemini-cli-codeassist/cloudrun-rust$ curl -i https://cloudrun-rust-1056842563084.us-central1.run.app/
HTTP/2 200
date: Mon, 22 Sep 2025 18:20:24 GMT
content-length: 20
server: Google Frontend
traceparent: 00-5a286b0d8b202697574216546d9c1c2b-4ae391fb6f10f1ca-01
x-cloud-trace-context: 5a286b0d8b202697574216546d9c1c2b/5396317287606186442;o=1
content-type: text/html; charset=UTF-8
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000Rust Never Sleeps!!!
Rust Best Practices
The project Makefile includes Rust best practice targets for formatting and linting. In the Rust conventions — these are cargo format and clippy:
Validate Firestore Database Support from Rust
The initial proof of concept only deployed a minimal viable “Hello World” type Rust program into a Cloud Run container. For more complete support, the GEMINI.md file was updated to include details about the Firestore Database interaction:
Rust Version of the Cymbal Inventory API
The next step is to build and deploy a Rust version of the Cymbal Inventory API with Firebase support. Gemini CLI was used to generate a compatible Rust version of the API and all the required build components including the Cargo.toml, Makefile, Dockerfile, and cloudbuild.yaml.
Build and Deploy to Cloud Run
A Rust build is typically started from a Makefile. The build uses the Cargo.toml to determine dependencies. The Dockerfile and cloudbuild.yaml are used to submit the build to Google Cloud Build.
Kick off the build from the command line:
xbill@penguin:~/gemini-cli-codeassist/backend-rust$ make deploy
Submitting build to Google Cloud Build...
Creating temporary archive of 6 file(s) totalling 70.7 KiB before compression.
Uploading tarball of [.] to [gs://comglitn_cloudbuild/source/1758563752.225758-2beeacee9fcb401987e00fe3ba9b5d8b.tgz]
Go and get a coffee.
It will be 5–10 minutes before everything fully deploys. Many containerized applications are interpreted languages- which means most of the time Cloud Build will just be moving files around. Rust is a compiled language — so the build process needs to pull all the source files, dependencies, and packages and then execute a complete build from source code to generate the final binary that will be deployed inside the container.
For reference — a basic build took about 8 mins:
Step #1: Service [backend-rust] revision [backend-rust-00020-8db] has been deployed and is serving 100 percent of traffic.
Step #1: Service URL: https://backend-rust-1056842563084.us-central1.run.app
Finished Step #1
PUSH
DONE
--------------------------------------------------------------------------------------------------------------------------------------------------------
ID CREATE_TIME DURATION SOURCE IMAGES STATUS
2bf82628-90f4-47a1-a6c8-533605d727ad 2025-09-22T17:55:53+00:00 8M26S gs://comglitn_cloudbuild/source/1758563752.225758-2beeacee9fcb401987e00fe3ba9b5d8b.tgz - SUCCESS
Validate the End Points
Once the container has fully deployed, you can check the endpoints.
The main endpoint (/) just prints a banner:
Check the /products endpoint:
The /health endpoint returns the “OK” status:
xbill@penguin:~/gemini-cli-codeassist/backend-rust$ curl https://backend-rust-1056842563084.us-central1.run.app/health
✅ ok
Validate the Rust Project
As a cross-check, Gemini CLI is used to summarize the new Rust native implementation of the Cymbal Inventory API:
Summary
The Google provided Cymbal sample inventory API code was deployed to Cloud Run. Then, Gemini CLI was used to generate a basic viable Rust enabled Cloud Run container along with all the required build scripts. Firebase database support was added to the Rust project. The original Typescript API source code was used with the Gemini 2.5 pro LLM to generate an equivalent Rust version. This native Rust implementation of the API was then containerized and deployed to Cloud Run. The migrated Rust API endpoint outputs were compared to the original Typescript API.
What’s Next?
The next steps are to enable Model Context Support (MCP) on the Rust Version of the Cymbal API and compare it to the original Typescript version.
Source Credit: https://medium.com/google-cloud/ai-software-development-with-rust-firestore-cloud-run-and-gemini-cli-d61b2e759a93?source=rss—-e52cf94d98af—4