Skip to main content
Cloud Run is a fully managed container platform that scales to zero and supports all three Genkit runtimes. It is a good choice when you need more control over the runtime than Firebase Cloud Functions provides — custom base images, background processes, Python or Go flows, or longer request timeouts.

Node.js

1

Create the flow server

startFlowServer from @genkit-ai/express starts an Express server on the port Cloud Run expects ($PORT, defaulting to 8080).
For a custom Express app (e.g. to add health-check routes or middleware):
2

Write the Dockerfile

Build TypeScript before building the image:
3

Deploy

Cloud Run injects the PORT environment variable automatically. The service account attached to the revision provides Application Default Credentials, so Vertex AI works without any additional configuration.

Python

1

Create the Flask or FastAPI app

2

Write the Dockerfile

3

Deploy

Using --source . triggers Cloud Build to build and push the image automatically. Alternatively build the image manually and use --image.

Go

1

Create the HTTP server

Use genkit.Handler to register each flow and server.Start (from the server plugin) to manage the HTTP server lifecycle with graceful shutdown.
2

Write the Dockerfile

3

Deploy

Authentication with Workload Identity

When you use Vertex AI (rather than the Gemini API key) on Cloud Run, no API key is required. The Cloud Run service account provides Application Default Credentials (ADC) automatically. Grant the service account the roles/aiplatform.user role:
Using Vertex AI with Workload Identity is the recommended approach for production Cloud Run services. It avoids storing long-lived API keys and automatically rotates credentials.

Disable the dev reflection server

Do not deploy with GENKIT_ENV=dev. The Genkit reflection server exposes an unauthenticated API for invoking all registered flows. Remove GENKIT_ENV from your environment or set it to production.
Set it in your Dockerfile or as a Cloud Run environment variable:

Context providers and auth

For flows that should only be called by authenticated clients, add a contextProvider (Node.js/Python) or WithContextProviders (Go):

Next steps

Observability

Enable Cloud Trace and Cloud Monitoring for your Cloud Run service.

Firebase

Deploy Node.js flows as Firebase Cloud Functions.