Use this file to discover all available pages before exploring further.
Genkit flows are plain functions. You choose how to expose them over HTTP — either with the built-in flow server or with a framework adapter like Express, Flask, or FastAPI. Once they are wrapped in an HTTP handler they can run anywhere: Cloud Run, Firebase Cloud Functions, Fly.io, AWS, bare-metal servers, or any container platform.
The flow server is the fastest path to a running HTTP API. Each language has a slightly different API.
Node.js
Python
Go
Use startFlowServer from @genkit-ai/express to start an Express server that exposes each flow at POST /<flowName>.
import { genkit } from 'genkit';import { googleAI } from '@genkit-ai/google-genai';import { startFlowServer } from '@genkit-ai/express';const ai = genkit({ plugins: [googleAI()] });const menuFlow = ai.defineFlow('menuSuggestion', async (theme: string) => { const { text } = await ai.generate(`Suggest a menu for a ${theme} restaurant.`); return text;});startFlowServer({ flows: [menuFlow], port: 8080,});
The server reads the PORT environment variable if port is not set, and defaults to 3400.
Use genkit_flask_handler from genkit-flask or genkit_fastapi_handler from genkit-fastapi to mount individual flows. For a full app, use the Flask or FastAPI framework directly:
from flask import Flaskfrom genkit import Genkitfrom genkit.plugins.flask import genkit_flask_handlerfrom genkit.plugins.google_genai import GoogleAIai = Genkit(plugins=[GoogleAI()], model='googleai/gemini-2.0-flash')app = Flask(__name__)@app.post('/menuSuggestion')@genkit_flask_handler(ai)@ai.flow()async def menu_suggestion(theme: str) -> str: response = await ai.generate(prompt=f'Suggest a menu for a {theme} restaurant.') return response.textif __name__ == '__main__': app.run(host='0.0.0.0', port=8080)
For more control — custom auth middleware, additional routes, or integration with an existing service — mount flows individually inside a framework you already use.
Node.js (Express)
Python (Flask)
Go
import { expressHandler } from '@genkit-ai/express';import express from 'express';import { UserFacingError } from 'genkit';import type { ContextProvider, RequestData } from 'genkit/context';const authProvider: ContextProvider<{ user: string }> = (req: RequestData) => { const token = req.headers['authorization']; if (!token) throw new UserFacingError('UNAUTHENTICATED', 'Missing auth token'); return { user: verifyToken(token) };};const app = express();app.use(express.json());app.post('/menuSuggestion', expressHandler(menuFlow, { contextProvider: authProvider }));app.listen(8080);
In development, Genkit starts a local reflection API server on port 4000 (used by the Dev UI). This server must not run in production.
Never run the Genkit reflection server (GENKIT_ENV=dev) in a production deployment. It exposes an unauthenticated API for inspecting and invoking all registered flows and actions.
Set the environment variable before starting your server:
export GENKIT_ENV=production
In Python and Go the reflection server is only started automatically when GENKIT_ENV=dev; removing that variable is sufficient.